159 return printData;
160 }
161
162 /**
163 * Obtains a reader for extracting character print data from this doc.
164 * The <code>Doc</code> implementation is required to support this
165 * method if the <code>DocFlavor</code> has one of the following print
166 * data representation classes, and return <code>null</code>
167 * otherwise:
168 * <UL>
169 * <LI> <code>char[]</code>
170 * <LI> <code>java.lang.String</code>
171 * <LI> <code>java.io.Reader</code>
172 * </UL>
173 * The doc's print data representation object is used to construct and
174 * return a <code>Reader</code> for reading the print data as a stream
175 * of characters from the print data representation object.
176 * However, if the print data representation object is itself a
177 * <code>Reader</code> then the print data representation object is
178 * simply returned.
179 * <P>
180 * @return a <code>Reader</code> for reading the print data
181 * characters from this doc.
182 * If a reader cannot be provided because this doc does not meet
183 * the criteria stated above, <code>null</code> is returned.
184 *
185 * @exception IOException if there was an I/O error while creating
186 * the reader.
187 */
188 public Reader getReaderForText() throws IOException {
189
190 if (printData instanceof Reader) {
191 return (Reader)printData;
192 }
193
194 synchronized (this) {
195 if (reader != null) {
196 return reader;
197 }
198
199 if (printData instanceof char[]) {
207 }
208
209 /**
210 * Obtains an input stream for extracting byte print data from
211 * this doc.
212 * The <code>Doc</code> implementation is required to support this
213 * method if the <code>DocFlavor</code> has one of the following print
214 * data representation classes; otherwise this method
215 * returns <code>null</code>:
216 * <UL>
217 * <LI> <code>byte[]</code>
218 * <LI> <code>java.io.InputStream</code>
219 * </UL>
220 * The doc's print data representation object is obtained. Then, an
221 * input stream for reading the print data
222 * from the print data representation object as a stream of bytes is
223 * created and returned.
224 * However, if the print data representation object is itself an
225 * input stream then the print data representation object is simply
226 * returned.
227 * <P>
228 * @return an <code>InputStream</code> for reading the print data
229 * bytes from this doc. If an input stream cannot be
230 * provided because this doc does not meet
231 * the criteria stated above, <code>null</code> is returned.
232 *
233 * @exception IOException
234 * if there was an I/O error while creating the input stream.
235 */
236 public InputStream getStreamForBytes() throws IOException {
237
238 if (printData instanceof InputStream) {
239 return (InputStream)printData;
240 }
241
242 synchronized (this) {
243 if (inStream != null) {
244 return inStream;
245 }
246
247 if (printData instanceof byte[]) {
|
159 return printData;
160 }
161
162 /**
163 * Obtains a reader for extracting character print data from this doc.
164 * The <code>Doc</code> implementation is required to support this
165 * method if the <code>DocFlavor</code> has one of the following print
166 * data representation classes, and return <code>null</code>
167 * otherwise:
168 * <UL>
169 * <LI> <code>char[]</code>
170 * <LI> <code>java.lang.String</code>
171 * <LI> <code>java.io.Reader</code>
172 * </UL>
173 * The doc's print data representation object is used to construct and
174 * return a <code>Reader</code> for reading the print data as a stream
175 * of characters from the print data representation object.
176 * However, if the print data representation object is itself a
177 * <code>Reader</code> then the print data representation object is
178 * simply returned.
179 *
180 * @return a <code>Reader</code> for reading the print data
181 * characters from this doc.
182 * If a reader cannot be provided because this doc does not meet
183 * the criteria stated above, <code>null</code> is returned.
184 *
185 * @exception IOException if there was an I/O error while creating
186 * the reader.
187 */
188 public Reader getReaderForText() throws IOException {
189
190 if (printData instanceof Reader) {
191 return (Reader)printData;
192 }
193
194 synchronized (this) {
195 if (reader != null) {
196 return reader;
197 }
198
199 if (printData instanceof char[]) {
207 }
208
209 /**
210 * Obtains an input stream for extracting byte print data from
211 * this doc.
212 * The <code>Doc</code> implementation is required to support this
213 * method if the <code>DocFlavor</code> has one of the following print
214 * data representation classes; otherwise this method
215 * returns <code>null</code>:
216 * <UL>
217 * <LI> <code>byte[]</code>
218 * <LI> <code>java.io.InputStream</code>
219 * </UL>
220 * The doc's print data representation object is obtained. Then, an
221 * input stream for reading the print data
222 * from the print data representation object as a stream of bytes is
223 * created and returned.
224 * However, if the print data representation object is itself an
225 * input stream then the print data representation object is simply
226 * returned.
227 *
228 * @return an <code>InputStream</code> for reading the print data
229 * bytes from this doc. If an input stream cannot be
230 * provided because this doc does not meet
231 * the criteria stated above, <code>null</code> is returned.
232 *
233 * @exception IOException
234 * if there was an I/O error while creating the input stream.
235 */
236 public InputStream getStreamForBytes() throws IOException {
237
238 if (printData instanceof InputStream) {
239 return (InputStream)printData;
240 }
241
242 synchronized (this) {
243 if (inStream != null) {
244 return inStream;
245 }
246
247 if (printData instanceof byte[]) {
|