2 Copyright (C) 2004, 2006 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
41 import java
.io
.IOException
;
42 import java
.io
.InputStream
;
43 import java
.io
.Reader
;
45 import javax
.print
.attribute
.DocAttributeSet
;
48 * <code>Doc</code> specifies the interface for print services how to obtain
49 * the print data and document specific attributes for printing.
51 * The print data is always passed to a {@link javax.print.DocPrintJob} object
52 * as a <code>Doc</code> object which allows the print services to:
54 * <li>Determine the actual document format of the supplied print data. This
55 * is supplied as a {@link javax.print.DocFlavor} object with the MIME type
56 * and the representation class of the print data.</li>
57 * <li>Obtain the print data either in its representation class or depending
58 * on the document format through convenience methods as a
59 * {@link java.io.Reader} or an {@link java.io.InputStream}.</li>
60 * <li>Obtain the document's attribute set specifying the attributes which
61 * apply to this document instance.</li>
64 * Every method of a <code>Doc</code> implementation has to return always the
65 * same object on every method call. Therefore if the print job consumes the
66 * print data via a stream or a reader object it can read only once the
67 * supplied print data. Implementations of this interface have to be thread
71 * @author Michael Koch (konqueror@gmx.de)
76 * Returns the unmodifiable view of the attributes of this doc object.
78 * The attributes of this doc's attributes set overrides attributes of
79 * the same category in the print job's attribute set. If an attribute
80 * is not available in this doc's attributes set or <code>null</code>
81 * is returned the attributes of the same category of the print job are
85 * @return The unmodifiable attributes set, or <code>null</code>.
87 DocAttributeSet
getAttributes();
90 * Returns the flavor of this doc objects print data.
92 * @return The document flavor.
94 DocFlavor
getDocFlavor();
97 * Returns the print data of this doc object.
99 * The returned object is an instance as described by the associated
100 * document flavor ({@link DocFlavor#getRepresentationClassName()})
101 * and can be cast to this representation class.
104 * @return The print data in the representation class.
105 * @throws IOException if representation class is a stream and I/O
108 Object
getPrintData() throws IOException
;
111 * Returns a <code>Reader</code> object for extracting character print data
112 * from this document.
114 * This method is supported if the document flavor is of type:
116 * <li><code>char[]</code></li>
117 * <li><code>java.lang.String</code></li>
118 * <li><code>java.io.Reader</code></li>
120 * otherwise this method returns <code>null</code>.
123 * @return The <code>Reader</code> object, or <code>null</code>.
125 * @throws IOException if an error occurs.
127 Reader
getReaderForText() throws IOException
;
130 * Returns an <code>InputStream</code> object for extracting byte print data
131 * from this document.
133 * This method is supported if the document flavor is of type:
135 * <li><code>byte[]</code></li>
136 * <li><code>java.io.InputStream</code></li>
138 * otherwise this method returns <code>null</code>.
141 * @return The <code>InputStream</code> object, or <code>null</code>.
143 * @throws IOException if an error occurs.
145 InputStream
getStreamForBytes() throws IOException
;