KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > print > DocFlavor


1 /*
2  * @(#)DocFlavor.java 1.17 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.print;
9
10 import java.io.IOException JavaDoc;
11 import java.io.ObjectInputStream JavaDoc;
12 import java.io.ObjectOutputStream JavaDoc;
13 import java.io.Serializable JavaDoc;
14
15 import java.util.Map JavaDoc;
16
17 /**
18  * Class <code>DocFlavor</code> encapsulates an object that specifies the
19  * format in which print data is supplied to a {@link DocPrintJob}.
20  * "Doc" is a short, easy-to-pronounce term that means "a piece of print data."
21  * The print data format, or "doc flavor", consists of two things:
22  * <UL>
23  * <LI>
24  * <B>MIME type.</B> This is a Multipurpose Internet Mail Extensions (MIME)
25  * media type (as defined in <A HREF="http://www.ietf.org/rfc/rfc2045.txt">RFC
26  * 2045</A> and <A HREF="http://www.ietf.org/rfc/rfc2046.txt">RFC 2046</A>)
27  * that specifies how the print data is to be interpreted.
28  * The charset of text data should be the IANA MIME-preferred name, or its
29  * canonical name if no preferred name is specified. Additionally a few
30  * historical names supported by earlier versions of the Java platform may
31  * be recognized.
32  * See <a HREF="../../java/lang/package-summary.html#charenc">
33  * character encodings</a> for more information on the character encodings
34  * supported on the Java platform.
35  * <P>
36  * <LI>
37  * <B>Representation class name.</B> This specifies the fully-qualified name of
38  * the class of the object from which the actual print data comes, as returned
39  * by the {@link java.lang.Class#getName() <CODE>Class.getName()</CODE>} method.
40  * (Thus the class name for <CODE>byte[]</CODE> is <CODE>"[B"</CODE>, for
41  * <CODE>char[]</CODE> it is <CODE>"[C"</CODE>.)
42  * </UL>
43  * <P>
44  * A <code>DocPrintJob</code> obtains its print data by means of interface
45  * {@link Doc Doc}. A <code>Doc</code> object lets the <code>DocPrintJob</code>
46  * determine the doc flavor the client can supply. A <code>Doc</code> object
47  * also lets the <code>DocPrintJob</code> obtain an instance of the doc flavor's
48  * representation class, from which the <code>DocPrintJob</code> then obtains
49  * the actual print data.
50  * <P>
51  * <HR>
52  * <H3>Client Formatted Print Data</H3>
53  * There are two broad categories of print data, client formatted print data
54  * and service formatted print data.
55  * <P>
56  * For <B>client formatted print data</B>, the client determines or knows the
57  * print data format.
58  * For example the client may have a JPEG encoded image, a URL for
59  * HTML code, or a disk file containing plain text in some encoding,
60  * possibly obtained from an external source, and
61  * requires a way to describe the data format to the print service.
62  * <p>
63  * The doc flavor's representation class is a conduit for the JPS
64  * <code>DocPrintJob</code> to obtain a sequence of characters or
65  * bytes from the client. The
66  * doc flavor's MIME type is one of the standard media types telling how to
67  * interpret the sequence of characters or bytes. For a list of standard media
68  * types, see the Internet Assigned Numbers Authority's (IANA's) <A
69  * HREF="http://www.isi.edu/in-notes/iana/assignments/media-types/">Media Types
70  * Directory</A>. Interface {@link Doc Doc} provides two utility operations,
71  * {@link Doc#getReaderForText() getReaderForText} and
72  * {@link Doc#getStreamForBytes() getStreamForBytes()}, to help a
73  * <code>Doc</code> object's client extract client formatted print data.
74  * <P>
75  * For client formatted print data, the print data representation class is
76  * typically one of the following (although other representation classes are
77  * permitted):
78  * <UL>
79  * <LI>
80  * Character array (<CODE>char[]</CODE>) -- The print data consists of the
81  * Unicde characters in the array.
82  * <P>
83  * <LI>
84  * <code>String</code> --
85  * The print data consists of the Unicode characters in the string.
86  * <P>
87  * <LI>
88  * Character stream ({@link java.io.Reader java.io.Reader})
89  * -- The print data consists of the Unicode characters read from the stream
90  * up to the end-of-stream.
91  * <P>
92  * <LI>
93  * Byte array (<CODE>byte[]</CODE>) -- The print data consists of the bytes in
94  * the array. The bytes are encoded in the character set specified by the doc
95  * flavor's MIME type. If the MIME type does not specify a character set, the
96  * default character set is US-ASCII.
97  * <P>
98  * <LI>
99  * Byte stream ({@link java.io.InputStream java.io.InputStream}) --
100  * The print data consists of the bytes read from the stream up to the
101  * end-of-stream. The bytes are encoded in the character set specified by the
102  * doc flavor's MIME type. If the MIME type does not specify a character set,
103  * the default character set is US-ASCII.
104
105  * <LI>
106  * Uniform Resource Locator ({@link java.net.URL URL})
107  * -- The print data consists of the bytes read from the URL location.
108  * The bytes are encoded in the character set specified by the doc flavor's
109  * MIME type. If the MIME type does not specify a character set, the default
110  * character set is US-ASCII.
111  * <P>
112  * When the representation class is a URL, the print service itself accesses
113  * and downloads the document directly from its URL address, without involving
114  * the client. The service may be some form of network print service which
115  * is executing in a different environment.
116  * This means you should not use a URL print data flavor to print a
117  * document at a restricted URL that the client can see but the printer cannot
118  * see. This also means you should not use a URL print data flavor to print a
119  * document stored in a local file that is not available at a URL
120  * accessible independently of the client.
121  * For example, a file that is not served up by an HTTP server or FTP server.
122  * To print such documents, let the client open an input stream on the URL
123  * or file and use an input stream data flavor.
124  * </UL>
125  * <p>
126  * <HR>
127  * <h3>Default and Platform Encodings</h3>
128  * <P>
129  * For byte print data where the doc flavor's MIME type does not include a
130  * <CODE>charset</CODE> parameter, the Java Print Service instance assumes the
131  * US-ASCII character set by default. This is in accordance with
132  * <A HREF="http://www.ietf.org/rfc/rfc2046.txt">RFC 2046</A>, which says the
133  * default character set is US-ASCII. Note that US-ASCII is a subset of
134  * UTF-8, so in the future this may be widened if a future RFC endorses
135  * UTF-8 as the default in a compatible manner.
136  * <p>
137  * Also note that this is different than the behaviour of the Java runtime
138  * when interpreting a stream of bytes as text data. That assumes the
139  * default encoding for the user's locale. Thus, when spooling a file in local
140  * encoding to a Java Print Service it is important to correctly specify
141  * the encoding. Developers working in the English locales should
142  * be particularly conscious of this, as their platform encoding corresponds
143  * to the default mime charset. By this coincidence that particular
144  * case may work without specifying the encoding of platform data.
145  * <p>
146  * Every instance of the Java virtual machine has a default character encoding
147  * determined during virtual-machine startup and typically depends upon the
148  * locale and charset being used by the underlying operating system.
149  * In a distributed environment there is no gurantee that two VM's share
150  * the same default encoding. Thus clients which want to stream platform
151  * encoded text data from the host platform to a Java Print Service instance
152  * must explicitly declare the charset and not rely on defaults.
153  * <p>
154  * The preferred form is the official IANA primary name for an encoding.
155  * Applications which stream text data should always specify the charset
156  * in the mime type, which necessitates obtaining the encoding of the host
157  * platform for data (eg files) stored in that platform's encoding.
158  * A CharSet which corresponds to this and is suitable for use in a
159  * mime-type for a DocFlavor can be obtained
160  * from {@link DocFlavor#hostEncoding <CODE>DocFlavor.hostEncoding</CODE>}
161  * This may not always be the primary IANA name but is guaranteed to be
162  * understood by this VM.
163  * For common flavors, the pre-defined *HOST DocFlavors may be used.
164  * <p>
165  * <p>
166  * See <a HREF="../../java/lang/package-summary.html#charenc">
167  * character encodings</a> for more information on the character encodings
168  * supported on the Java platform.
169  * <p>
170  * <HR>
171  * <h3>Recommended DocFlavors</h3>
172  * <P>
173  * The Java Print Service API does not define any mandatorily supported
174  * DocFlavors.
175  * However, here are some examples of MIME types that a Java Print Service
176  * instance might support for client formatted print data.
177  * Nested classes inside class DocFlavor declare predefined static
178  * constant DocFlavor objects for these example doc flavors; class DocFlavor's
179  * constructor can be used to create an arbitrary doc flavor.
180  * <UL>
181  * <LI>Preformatted text
182  * <P>
183  * <TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 SUMMARY="MIME-Types and their descriptions">
184  * <TR>
185  * <TH>MIME-Type</TH><TH>Description</TH>
186  * </TR>
187  * <TR>
188  * <TD><CODE>"text/plain"</CODE></TD>
189  * <TD>Plain text in the default character set (US-ASCII)</TD>
190  * </TR>
191  * <TR>
192  * <TD><CODE>"text/plain; charset=<I>xxx</I>"</CODE></TD>
193  * <TD>Plain text in character set <I>xxx</I></TD>
194  * </TR>
195  * <TR>
196  * <TD><CODE>"text/html"</CODE></TD>
197  * <TD>HyperText Markup Language in the default character set (US-ASCII)</TD>
198  * </TR>
199  * <TR>
200  * <TD><CODE>"text/html; charset=<I>xxx</I>"</CODE></TD>
201  * <TD>HyperText Markup Language in character set <I>xxx</I></TD>
202  * </TR>
203  * </TABLE>
204  * <P>
205  * In general, preformatted text print data is provided either in a character
206  * oriented representation class (character array, String, Reader) or in a
207  * byte oriented representation class (byte array, InputStream, URL).
208  * <P>
209  * <LI>Preformatted page description language (PDL) documents
210  *<P>
211  * <TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 SUMMARY="MIME-Types and their descriptions">
212  * <TR>
213  * <TH>MIME-Type</TH><TH>Description</TH>
214  * </TR>
215  *<TR>
216  * <TD><CODE>"application/pdf"</CODE></TD>
217  * <TD>Portable Document Format document</TD>
218  * </TR>
219  * <TR>
220  * <TD><CODE>"application/postscript"</CODE></TD>
221  * <TD>PostScript document</TD>
222  * </TR>
223  * <TR>
224  * <TD><CODE>"application/vnd.hp-PCL"</CODE></TD>
225  * <TD>Printer Control Language document</TD>
226  * </TR>
227  * </TABLE>
228  * <P>
229  * In general, preformatted PDL print data is provided in a byte oriented
230  * representation class (byte array, InputStream, URL).
231  * <P>
232  * <LI>Preformatted images
233  *<P>
234  * <TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 SUMMARY="MIME-Types and their descriptions">
235  * <TR>
236  * <TH>MIME-Type</TH><TH>Description</TH>
237  * </TR>
238  *
239  * <TR>
240  * <TD><CODE>"image/gif"</CODE></TD>
241  * <TD>Graphics Interchange Format image</TD>
242  * </TR>
243  * <TR>
244  * <TD><CODE>"image/jpeg"</CODE></TD>
245  * <TD>Joint Photographic Experts Group image</TD>
246  * </TR>
247  * <TR>
248  * <TD><CODE>"image/png"</CODE></TD>
249  * <TD>Portable Network Graphics image</TD>
250  * </TR>
251  * </TABLE>
252  * <P>
253  * In general, preformatted image print data is provided in a byte oriented
254  * representation class (byte array, InputStream, URL).
255  * <P>
256  * <LI>Preformatted autosense print data
257  * <P>
258  * <TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 SUMMARY="MIME-Types and their descriptions">
259  * <TR>
260  * <TH>MIME-Type</TH><TH>Description</TH>
261  * </TR>
262  *
263  * <TR>
264  * <TD><CODE>"application/octet-stream"</CODE></TD>
265  * <TD>The print data format is unspecified (just an octet stream)</TD>
266  * </TABLE>
267  * <P>
268  * The printer decides how to interpret the print data; the way this
269  * "autosensing" works is implementation dependent. In general, preformatted
270  * autosense print data is provided in a byte oriented representation class
271  * (byte array, InputStream, URL).
272  *
273  * <P>
274  * <HR>
275  * <H3>Service Formatted Print Data</H3>
276  * <P>
277  * For <B>service formatted print data</B>, the Java Print Service instance
278  * determines the print data format. The doc flavor's representation class
279  * denotes an interface whose methods the <code>DocPrintJob</code> invokes to
280  * determine the content to be printed -- such as a renderable image
281  * interface or a Java 2 printable interface.
282  * The doc flavor's MIME type is the special value
283  * <CODE>"application/x-java-jvm-local-objectref"</CODE> indicating the client
284  * will supply a reference to a Java object that implements the interface
285  * named as the representation class.
286  * This MIME type is just a placeholder; what's
287  * important is the print data representation class.
288  * <P>
289  * For service formatted print data, the print data representation class is
290  * typically one of the following (although other representation classes are
291  * permitted). Nested classes inside class DocFlavor declare predefined static
292  * constant DocFlavor objects for these example doc flavors; class DocFlavor's
293  * constructor can be used to create an arbitrary doc flavor.
294  * <UL>
295  * <LI>
296  * Renderable image object -- The client supplies an object that implements
297  * interface
298  * {@link java.awt.image.renderable.RenderableImage RenderableImage}. The
299  * printer calls methods
300  * in that interface to obtain the image to be printed.
301  * <P>
302  * <LI>
303  * Printable object -- The client supplies an object that implements interface
304  * {@link java.awt.print.Printable Printable}.
305  * The printer calls methods in that interface to obtain the pages to be
306  * printed, one by one.
307  * For each page, the printer supplies a graphics context, and whatever the
308  * client draws in that graphics context gets printed.
309  * <P>
310  * <LI>
311  * Pageable object -- The client supplies an object that implements interface
312  * {@link java.awt.print.Pageable Pageable}. The printer calls
313  * methods in that interface to obtain the pages to be printed, one by one.
314  * For each page, the printer supplies a graphics context, and whatever
315  * the client draws in that graphics context gets printed.
316  * </UL>
317  * <P>
318  * <HR>
319  * <P>
320  * <HR>
321  * <H3>Pre-defined Doc Flavors</H3>
322  * A Java Print Service instance is not <B><I>required</I></B> to support the
323  * following print data formats and print data representation classes. In
324  * fact, a developer using this class should <b>never</b> assume that a
325  * particular print service supports the document types corresponding to
326  * these pre-defined doc flavors. Always query the print service
327  * to determine what doc flavors it supports. However,
328  * developers who have print services that support these doc flavors are
329  * encouraged to refer to the predefined singleton instances created here.
330  * <UL>
331  * <LI>
332  * Plain text print data provided through a byte stream. Specifically, the
333  * following doc flavors are recommended to be supported:
334  * <BR>&#183;&nbsp;&nbsp;
335  * <CODE>("text/plain", "java.io.InputStream")</CODE>
336  * <BR>&#183;&nbsp;&nbsp;
337  * <CODE>("text/plain; charset=us-ascii", "java.io.InputStream")</CODE>
338  * <BR>&#183;&nbsp;&nbsp;
339  * <CODE>("text/plain; charset=utf-8", "java.io.InputStream")</CODE>
340  * <P>
341  * <LI>
342  * Renderable image objects. Specifically, the following doc flavor is
343  * recommended to be supported:
344  * <BR>&#183;&nbsp;&nbsp;
345  * <CODE>("application/x-java-jvm-local-objectref", "java.awt.image.renderable.RenderableImage")</CODE>
346  * </UL>
347  * <P>
348  * A Java Print Service instance is allowed to support any other doc flavors
349  * (or none) in addition to the above mandatory ones, at the implementation's
350  * choice.
351  * <P>
352  * Support for the above doc flavors is desirable so a printing client can rely
353  * on being able to print on any JPS printer, regardless of which doc flavors
354  * the printer supports. If the printer doesn't support the client's preferred
355  * doc flavor, the client can at least print plain text, or the client can
356  * convert its data to a renderable image and print the image.
357  * <P>
358  * Furthermore, every Java Print Service instance must fulfill these
359  * requirements for processing plain text print data:
360  * <UL>
361  * <LI>
362  * The character pair carriage return-line feed (CR-LF) means
363  * "go to column 1 of the next line."
364  * <LI>
365  * A carriage return (CR) character standing by itself means
366  * "go to column 1 of the next line."
367  * <LI>
368  * A line feed (CR) character standing by itself means
369  * "go to column 1 of the next line."
370  * <LI>
371  * </UL>
372  * <P>
373  * The client must itself perform all plain text print data formatting not
374  * addressed by the above requirements.
375  * <P>
376  * <H3>Design Rationale</H3>
377  * <P>
378  * Class DocFlavor in package javax.print.data is similar to class
379  * {@link java.awt.datatransfer.DataFlavor DataFlavor}. Class
380  * <code>DataFlavor</code>
381  * is not used in the Java Print Service (JPS) API
382  * for three reasons which are all rooted in allowing the JPS API to be
383  * shared by other print services APIs which may need to run on Java profiles
384  * which do not include all of the Java 2 Standard Edition.
385  * <OL TYPE=1>
386  * <LI>
387  * The JPS API is designed to be used in Java profiles which do not support
388  * AWT.
389  * <P>
390  * <LI>
391  * The implementation of class <code>java.awt.datatransfer.DataFlavor</code>
392  * does not guarantee that equivalent data flavors will have the same
393  * serialized representation. DocFlavor does, and can be used in services
394  * which need this.
395  * <P>
396  * <LI>
397  * The implementation of class <code>java.awt.datatransfer.DataFlavor</code>
398  * includes a human presentable name as part of the serialized representation.
399  * This is not appropriate as part of a service matching constraint.
400  * </OL>
401  * <P>
402  * Class DocFlavor's serialized representation uses the following
403  * canonical form of a MIME type string. Thus, two doc flavors with MIME types
404  * that are not identical but that are equivalent (that have the same
405  * canonical form) may be considered equal.
406  * <UL>
407  * <LI> The media type, media subtype, and parameters are retained, but all
408  * comments and whitespace characters are discarded.
409  * <LI> The media type, media subtype, and parameter names are converted to
410  * lowercase.
411  * <LI> The parameter values retain their original case, except a charset
412  * parameter value for a text media type is converted to lowercase.
413  * <LI> Quote characters surrounding parameter values are removed.
414  * <LI> Quoting backslash characters inside parameter values are removed.
415  * <LI> The parameters are arranged in ascending order of parameter name.
416  * </UL>
417  * <P>
418  * Class DocFlavor's serialized representation also contains the
419  * fully-qualified class <I>name</I> of the representation class
420  * (a String object), rather than the representation class itself
421  * (a Class object). This allows a client to examine the doc flavors a
422  * Java Print Service instance supports without having
423  * to load the representation classes, which may be problematic for
424  * limited-resource clients.
425  * <P>
426  *
427  * @author Alan Kaminsky
428  */

429 public class DocFlavor implements Serializable JavaDoc, Cloneable JavaDoc {
430
431     private static final long serialVersionUID = -4512080796965449721L;
432
433     /**
434      * A String representing the host operating system encoding.
435      * This will follow the conventions documented in
436      * <a HREF="http://ietf.org/rfc/rfc2278.txt">
437      * <i>RFC&nbsp;2278:&nbsp;IANA Charset Registration Procedures</i></a>
438      * except where historical names are returned for compatibility with
439      * previous versions of the Java platform.
440      * The value returned from method is valid only for the VM which
441      * returns it, for use in a DocFlavor.
442      * This is the charset for all the "HOST" pre-defined DocFlavors in
443      * the executing VM.
444      */

445     public static final String JavaDoc hostEncoding;
446     
447     static {
448     hostEncoding =
449         (String JavaDoc)java.security.AccessController.doPrivileged(
450                   new sun.security.action.GetPropertyAction("file.encoding"));
451     }
452
453     /**
454      * MIME type.
455      */

456     private transient MimeType JavaDoc myMimeType;
457
458     /**
459      * Representation class name.
460      * @serial
461      */

462     private String JavaDoc myClassName;
463
464     /**
465      * String value for this doc flavor. Computed when needed and cached.
466      */

467     private transient String JavaDoc myStringValue = null;
468
469
470     /**
471      * Constructs a new doc flavor object from the given MIME type and
472      * representation class name. The given MIME type is converted into
473      * canonical form and stored internally.
474      *
475      * @param mimeType MIME media type string.
476      * @param className Fully-qualified representation class name.
477      *
478      * @exception NullPointerException
479      * (unchecked exception) Thrown if <CODE>mimeType</CODE> is null or
480      * <CODE>className</CODE> is null.
481      * @exception IllegalArgumentException
482      * (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
483      * obey the syntax for a MIME media type string.
484      */

485     public DocFlavor(String JavaDoc mimeType, String JavaDoc className) {
486         if (className == null) {
487         throw new NullPointerException JavaDoc();
488     }
489         myMimeType = new MimeType JavaDoc (mimeType);
490         myClassName = className;
491     }
492
493     /**
494      * Returns this doc flavor object's MIME type string based on the
495      * canonical form. Each parameter value is enclosed in quotes.
496      * @return the mime type
497      */

498     public String JavaDoc getMimeType() {
499         return myMimeType.getMimeType();
500     }
501
502     /**
503      * Returns this doc flavor object's media type (from the MIME type).
504      * @return the media type
505      */

506     public String JavaDoc getMediaType() {
507         return myMimeType.getMediaType();
508     }
509
510     /**
511      * Returns this doc flavor object's media subtype (from the MIME type).
512      * @return the media sub-type
513      */

514     public String JavaDoc getMediaSubtype() {
515         return myMimeType.getMediaSubtype();
516     }
517
518     /**
519      * Returns a <code>String</code> representing a MIME
520      * parameter.
521      * Mime types may include parameters which are usually optional.
522      * The charset for text types is a commonly useful example.
523      * This convenience method will return the value of the specified
524      * parameter if one was specified in the mime type for this flavor.
525      * <p>
526      * @param paramName the name of the paramater. This name is internally
527      * converted to the canonical lower case format before performing
528      * the match.
529      * @return String representing a mime parameter, or
530      * null if that parameter is not in the mime type string.
531      * @exception throws NullPointerException if paramName is null.
532      */

533     public String JavaDoc getParameter(String JavaDoc paramName) {
534     return
535         (String JavaDoc)myMimeType.getParameterMap().get(paramName.toLowerCase());
536     }
537
538     /**
539      * Returns the name of this doc flavor object's representation class.
540      * @return the name of the representation class.
541      */

542     public String JavaDoc getRepresentationClassName() {
543         return myClassName;
544     }
545
546     /**
547      * Converts this <code>DocFlavor</code> to a string.
548      *
549      * @return MIME type string based on the canonical form. Each parameter
550      * value is enclosed in quotes.
551      * A "class=" parameter is appended to the
552      * MIME type string to indicate the representation class name.
553      */

554     public String JavaDoc toString() {
555         return getStringValue();
556     }
557
558     /**
559      * Returns a hash code for this doc flavor object.
560      */

561     public int hashCode() {
562         return getStringValue().hashCode();
563     }
564
565     /**
566      * Determines if this doc flavor object is equal to the given object.
567      * The two are equal if the given object is not null, is an instance
568      * of <code>DocFlavor</code>, has a MIME type equivalent to this doc
569      * flavor object's MIME type (that is, the MIME types have the same media
570      * type, media subtype, and parameters), and has the same representation
571      * class name as this doc flavor object. Thus, if two doc flavor objects'
572      * MIME types are the same except for comments, they are considered equal.
573      * However, two doc flavor objects with MIME types of "text/plain" and
574      * "text/plain; charset=US-ASCII" are not considered equal, even though
575      * they represent the same media type (because the default character
576      * set for plain text is US-ASCII).
577      *
578      * @param obj Object to test.
579      *
580      * @return True if this doc flavor object equals <CODE>obj</CODE>, false
581      * otherwise.
582      */

583     public boolean equals(Object JavaDoc obj) {
584         return
585         obj != null &&
586         obj instanceof DocFlavor JavaDoc &&
587         getStringValue().equals (((DocFlavor JavaDoc) obj).getStringValue());
588     }
589
590     /**
591      * Returns this doc flavor object's string value.
592      */

593     private String JavaDoc getStringValue() {
594         if (myStringValue == null) {
595         myStringValue = myMimeType + "; class=\"" + myClassName + "\"";
596     }
597         return myStringValue;
598     }
599
600     /**
601      * Write the instance to a stream (ie serialize the object).
602      */

603     private void writeObject(ObjectOutputStream JavaDoc s) throws IOException JavaDoc {
604
605     s.defaultWriteObject();
606     s.writeObject(myMimeType.getMimeType());
607     }
608
609     /**
610      * Reconstitute an instance from a stream (that is, deserialize it).
611      *
612      * @serialData
613      * The serialised form of a DocFlavor is the String naming the
614      * representation class followed by the String representing the canonical
615      * form of the mime type.
616      */

617     private void readObject(ObjectInputStream JavaDoc s)
618     throws ClassNotFoundException JavaDoc, IOException JavaDoc {
619     
620     s.defaultReadObject();
621     myMimeType = new MimeType JavaDoc((String JavaDoc)s.readObject());
622     }
623
624     /**
625      * Class DocFlavor.BYTE_ARRAY provides predefined static constant
626      * DocFlavor objects for example doc flavors using a byte array
627      * (<CODE>byte[]</CODE>) as the print data representation class.
628      * <P>
629      *
630      * @author Alan Kaminsky
631      */

632     public static class BYTE_ARRAY extends DocFlavor JavaDoc {
633
634     private static final long serialVersionUID = -9065578006593857475L;
635
636         /**
637          * Constructs a new doc flavor with the given MIME type and a print
638          * data representation class name of <CODE>"[B"</CODE> (byte array).
639          *
640          * @param mimeType MIME media type string.
641          *
642          * @exception NullPointerException
643          * (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
644          * @exception IllegalArgumentException
645          * (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
646          * obey the syntax for a MIME media type string.
647          */

648         public BYTE_ARRAY (String JavaDoc mimeType) {
649         super (mimeType, "[B");
650     }
651
652         /**
653          * Doc flavor with MIME type = <CODE>"text/plain"</CODE>,
654      * encoded in the host platform encoding.
655      * See {@link DocFlavor#hostEncoding <CODE>hostEncoding</CODE>}
656          * Print data representation class name =
657      * <CODE>"[B"</CODE> (byte array).
658          */

659         public static final BYTE_ARRAY TEXT_PLAIN_HOST =
660         new BYTE_ARRAY ("text/plain; charset="+hostEncoding);
661
662         /**
663          * Doc flavor with MIME type =
664      * <CODE>"text/plain; charset=utf-8"</CODE>,
665          * print data representation class name = <CODE>"[B"</CODE> (byte
666          * array).
667          */

668         public static final BYTE_ARRAY TEXT_PLAIN_UTF_8 =
669         new BYTE_ARRAY ("text/plain; charset=utf-8");
670
671     /**
672          * Doc flavor with MIME type =
673      * <CODE>"text/plain; charset=utf-16"</CODE>,
674          * print data representation class name = <CODE>"[B"</CODE> (byte
675          * array).
676          */

677         public static final BYTE_ARRAY TEXT_PLAIN_UTF_16 =
678         new BYTE_ARRAY ("text/plain; charset=utf-16");
679
680
681     /**
682          * Doc flavor with MIME type =
683      * <CODE>"text/plain; charset=utf-16be"</CODE>
684      * (big-endian byte ordering),
685          * print data representation class name = <CODE>"[B"</CODE> (byte
686          * array).
687          */

688         public static final BYTE_ARRAY TEXT_PLAIN_UTF_16BE =
689         new BYTE_ARRAY ("text/plain; charset=utf-16be");
690
691     /**
692          * Doc flavor with MIME type =
693      * <CODE>"text/plain; charset=utf-16le"</CODE>
694      * (little-endian byte ordering),
695          * print data representation class name = <CODE>"[B"</CODE> (byte
696          * array).
697          */

698         public static final BYTE_ARRAY TEXT_PLAIN_UTF_16LE =
699         new BYTE_ARRAY ("text/plain; charset=utf-16le");
700
701         /**
702          * Doc flavor with MIME type =
703      * <CODE>"text/plain; charset=us-ascii"</CODE>,
704      * print data representation class name =
705      * <CODE>"[B"</CODE> (byte array).
706          */

707         public static final BYTE_ARRAY TEXT_PLAIN_US_ASCII =
708         new BYTE_ARRAY ("text/plain; charset=us-ascii");
709
710
711         /**
712          * Doc flavor with MIME type = <CODE>"text/html"</CODE>,
713      * encoded in the host platform encoding.
714      * See {@link DocFlavor#hostEncoding <CODE>hostEncoding</CODE>}
715          * Print data representation class name =
716      * <CODE>"[B"</CODE> (byte array).
717          */

718         public static final BYTE_ARRAY TEXT_HTML_HOST =
719         new BYTE_ARRAY ("text/html; charset="+hostEncoding);
720
721         /**
722          * Doc flavor with MIME type =
723      * <CODE>"text/html; charset=utf-8"</CODE>,
724          * print data representation class name = <CODE>"[B"</CODE> (byte
725          * array).
726          */

727         public static final BYTE_ARRAY TEXT_HTML_UTF_8 =
728         new BYTE_ARRAY ("text/html; charset=utf-8");
729
730     /**
731          * Doc flavor with MIME type =
732      * <CODE>"text/html; charset=utf-16"</CODE>,
733          * print data representation class name = <CODE>"[B"</CODE> (byte
734          * array).
735          */

736         public static final BYTE_ARRAY TEXT_HTML_UTF_16 =
737         new BYTE_ARRAY ("text/html; charset=utf-16");
738
739     /**
740          * Doc flavor with MIME type =
741      * <CODE>"text/html; charset=utf-16be"</CODE>
742      * (big-endian byte ordering),
743          * print data representation class name = <CODE>"[B"</CODE> (byte
744          * array).
745          */

746         public static final BYTE_ARRAY TEXT_HTML_UTF_16BE =
747         new BYTE_ARRAY ("text/html; charset=utf-16be");
748
749     /**
750          * Doc flavor with MIME type =
751      * <CODE>"text/html; charset=utf-16le"</CODE>
752      * (little-endian byte ordering),
753          * print data representation class name = <CODE>"[B"</CODE> (byte
754          * array).
755          */

756         public static final BYTE_ARRAY TEXT_HTML_UTF_16LE =
757         new BYTE_ARRAY ("text/html; charset=utf-16le");
758
759         /**
760          * Doc flavor with MIME type =
761      * <CODE>"text/html; charset=us-ascii"</CODE>,
762      * print data representation class name =
763      * <CODE>"[B"</CODE> (byte array).
764          */

765         public static final BYTE_ARRAY TEXT_HTML_US_ASCII =
766         new BYTE_ARRAY ("text/html; charset=us-ascii");
767
768
769         /**
770          * Doc flavor with MIME type = <CODE>"application/pdf"</CODE>, print
771          * data representation class name = <CODE>"[B"</CODE> (byte array).
772          */

773         public static final BYTE_ARRAY PDF = new BYTE_ARRAY ("application/pdf");
774
775         /**
776          * Doc flavor with MIME type = <CODE>"application/postscript"</CODE>,
777          * print data representation class name = <CODE>"[B"</CODE> (byte
778          * array).
779          */

780         public static final BYTE_ARRAY POSTSCRIPT =
781         new BYTE_ARRAY ("application/postscript");
782
783         /**
784          * Doc flavor with MIME type = <CODE>"application/vnd.hp-PCL"</CODE>,
785          * print data representation class name = <CODE>"[B"</CODE> (byte
786          * array).
787          */

788         public static final BYTE_ARRAY PCL =
789         new BYTE_ARRAY ("application/vnd.hp-PCL");
790
791         /**
792          * Doc flavor with MIME type = <CODE>"image/gif"</CODE>, print data
793          * representation class name = <CODE>"[B"</CODE> (byte array).
794          */

795         public static final BYTE_ARRAY GIF = new BYTE_ARRAY ("image/gif");
796
797         /**
798          * Doc flavor with MIME type = <CODE>"image/jpeg"</CODE>, print data
799          * representation class name = <CODE>"[B"</CODE> (byte array).
800          */

801         public static final BYTE_ARRAY JPEG = new BYTE_ARRAY ("image/jpeg");
802
803         /**
804          * Doc flavor with MIME type = <CODE>"image/png"</CODE>, print data
805          * representation class name = <CODE>"[B"</CODE> (byte array).
806          */

807         public static final BYTE_ARRAY PNG = new BYTE_ARRAY ("image/png");
808
809         /**
810          * Doc flavor with MIME type =
811      * <CODE>"application/octet-stream"</CODE>,
812          * print data representation class name = <CODE>"[B"</CODE> (byte
813          * array). The client must determine that data described
814      * using this DocFlavor is valid for the printer.
815          */

816         public static final BYTE_ARRAY AUTOSENSE =
817         new BYTE_ARRAY ("application/octet-stream");
818
819     }
820
821     /**
822      * Class DocFlavor.INPUT_STREAM provides predefined static constant
823      * DocFlavor objects for example doc flavors using a byte stream ({@link
824      * java.io.InputStream <CODE>java.io.InputStream</CODE>}) as the print
825      * data representation class.
826      * <P>
827      *
828      * @author Alan Kaminsky
829      */

830     public static class INPUT_STREAM extends DocFlavor JavaDoc {
831
832     private static final long serialVersionUID = -7045842700749194127L;
833
834         /**
835          * Constructs a new doc flavor with the given MIME type and a print
836          * data representation class name of
837      * <CODE>"java.io.InputStream"</CODE> (byte stream).
838          *
839          * @param mimeType MIME media type string.
840          *
841          * @exception NullPointerException
842          * (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
843          * @exception IllegalArgumentException
844          * (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
845          * obey the syntax for a MIME media type string.
846          */

847         public INPUT_STREAM (String JavaDoc mimeType) {
848         super (mimeType, "java.io.InputStream");
849     }
850
851         /**
852          * Doc flavor with MIME type = <CODE>"text/plain"</CODE>,
853      * encoded in the host platform encoding.
854      * See {@link DocFlavor#hostEncoding <CODE>hostEncoding</CODE>}
855          * Print data representation class name =
856      * <CODE>"java.io.InputStream"</CODE> (byte stream).
857          */

858         public static final INPUT_STREAM TEXT_PLAIN_HOST =
859         new INPUT_STREAM ("text/plain; charset="+hostEncoding);
860
861         /**
862          * Doc flavor with MIME type =
863      * <CODE>"text/plain; charset=utf-8"</CODE>,
864          * print data representation class name =
865      * <CODE>"java.io.InputStream"</CODE> (byte stream).
866          */

867         public static final INPUT_STREAM TEXT_PLAIN_UTF_8 =
868         new INPUT_STREAM ("text/plain; charset=utf-8");
869
870     /**
871          * Doc flavor with MIME type =
872      * <CODE>"text/plain; charset=utf-16"</CODE>,
873          * print data representation class name =
874          * <CODE>"java.io.InputStream"</CODE> (byte stream).
875          */

876         public static final INPUT_STREAM TEXT_PLAIN_UTF_16 =
877         new INPUT_STREAM ("text/plain; charset=utf-16");
878
879     /**
880          * Doc flavor with MIME type =
881      * <CODE>"text/plain; charset=utf-16be"</CODE>
882      * (big-endian byte ordering),
883          * print data representation class name =
884      * <CODE>"java.io.InputStream"</CODE> (byte stream).
885          */

886         public static final INPUT_STREAM TEXT_PLAIN_UTF_16BE =
887         new INPUT_STREAM ("text/plain; charset=utf-16be");
888
889     /**
890          * Doc flavor with MIME type =
891      * <CODE>"text/plain; charset=utf-16le"</CODE>
892      * (little-endian byte ordering),
893          * print data representation class name =
894      * <CODE>"java.io.InputStream"</CODE> (byte stream).
895          */

896         public static final INPUT_STREAM TEXT_PLAIN_UTF_16LE =
897         new INPUT_STREAM ("text/plain; charset=utf-16le");
898
899         /**
900          * Doc flavor with MIME type =
901      * <CODE>"text/plain; charset=us-ascii"</CODE>,
902      * print data representation class name =
903      * <CODE>"java.io.InputStream"</CODE> (byte stream).
904          */

905         public static final INPUT_STREAM TEXT_PLAIN_US_ASCII =
906             new INPUT_STREAM ("text/plain; charset=us-ascii");
907
908         /**
909          * Doc flavor with MIME type = <CODE>"text/html"</CODE>,
910      * encoded in the host platform encoding.
911      * See {@link DocFlavor#hostEncoding <CODE>hostEncoding</CODE>}
912          * Print data representation class name =
913      * <CODE>"java.io.InputStream"</CODE> (byte stream).
914          */

915         public static final INPUT_STREAM TEXT_HTML_HOST =
916         new INPUT_STREAM ("text/html; charset="+hostEncoding);
917
918         /**
919          * Doc flavor with MIME type =
920      * <CODE>"text/html; charset=utf-8"</CODE>,
921          * print data representation class name =
922      * <CODE>"java.io.InputStream"</CODE> (byte stream).
923          */

924         public static final INPUT_STREAM TEXT_HTML_UTF_8 =
925         new INPUT_STREAM ("text/html; charset=utf-8");
926
927     /**
928          * Doc flavor with MIME type =
929      * <CODE>"text/html; charset=utf-16"</CODE>,
930          * print data representation class name =
931      * <CODE>"java.io.InputStream"</CODE> (byte stream).
932          */

933         public static final INPUT_STREAM TEXT_HTML_UTF_16 =
934         new INPUT_STREAM ("text/html; charset=utf-16");
935
936     /**
937          * Doc flavor with MIME type =
938      * <CODE>"text/html; charset=utf-16be"</CODE>
939      * (big-endian byte ordering),
940          * print data representation class name =
941      * <CODE>"java.io.InputStream"</CODE> (byte stream).
942          */

943         public static final INPUT_STREAM TEXT_HTML_UTF_16BE =
944         new INPUT_STREAM ("text/html; charset=utf-16be");
945
946     /**
947          * Doc flavor with MIME type =
948      * <CODE>"text/html; charset=utf-16le"</CODE>
949      * (little-endian byte ordering),
950          * print data representation class name =
951      * <CODE>"java.io.InputStream"</CODE> (byte stream).
952          */

953         public static final INPUT_STREAM TEXT_HTML_UTF_16LE =
954         new INPUT_STREAM ("text/html; charset=utf-16le");
955
956         /**
957          * Doc flavor with MIME type =
958      * <CODE>"text/html; charset=us-ascii"</CODE>,
959      * print data representation class name =
960      * <CODE>"java.io.InputStream"</CODE> (byte stream).
961          */

962         public static final INPUT_STREAM TEXT_HTML_US_ASCII =
963         new INPUT_STREAM ("text/html; charset=us-ascii");
964
965     
966         /**
967          * Doc flavor with MIME type = <CODE>"application/pdf"</CODE>, print
968          * data representation class name = <CODE>"java.io.InputStream"</CODE>
969          * (byte stream).
970          */

971         public static final INPUT_STREAM PDF = new INPUT_STREAM ("application/pdf");
972
973         /**
974          * Doc flavor with MIME type = <CODE>"application/postscript"</CODE>,
975          * print data representation class name =
976          * <CODE>"java.io.InputStream"</CODE> (byte stream).
977          */

978         public static final INPUT_STREAM POSTSCRIPT =
979         new INPUT_STREAM ("application/postscript");
980
981         /**
982          * Doc flavor with MIME type = <CODE>"application/vnd.hp-PCL"</CODE>,
983          * print data representation class name =
984          * <CODE>"java.io.InputStream"</CODE> (byte stream).
985          */

986         public static final INPUT_STREAM PCL =
987         new INPUT_STREAM ("application/vnd.hp-PCL");
988
989         /**
990          * Doc flavor with MIME type = <CODE>"image/gif"</CODE>, print data
991          * representation class name =
992      * <CODE>"java.io.InputStream"</CODE> (byte stream).
993          */

994         public static final INPUT_STREAM GIF = new INPUT_STREAM ("image/gif");
995
996         /**
997          * Doc flavor with MIME type = <CODE>"image/jpeg"</CODE>, print data
998          * representation class name =
999      * <CODE>"java.io.InputStream"</CODE> (byte stream).
1000         */

1001        public static final INPUT_STREAM JPEG = new INPUT_STREAM ("image/jpeg");
1002
1003        /**
1004         * Doc flavor with MIME type = <CODE>"image/png"</CODE>, print data
1005         * representation class name =
1006     * <CODE>"java.io.InputStream"</CODE> (byte stream).
1007         */

1008        public static final INPUT_STREAM PNG = new INPUT_STREAM ("image/png");
1009
1010        /**
1011         * Doc flavor with MIME type =
1012     * <CODE>"application/octet-stream"</CODE>,
1013         * print data representation class name =
1014         * <CODE>"java.io.InputStream"</CODE> (byte stream).
1015     * The client must determine that data described
1016     * using this DocFlavor is valid for the printer.
1017         */

1018        public static final INPUT_STREAM AUTOSENSE =
1019        new INPUT_STREAM ("application/octet-stream");
1020
1021    }
1022
1023    /**
1024     * Class DocFlavor.URL provides predefined static constant DocFlavor
1025     * objects.
1026     * For example doc flavors using a Uniform Resource Locator ({@link
1027     * java.net.URL <CODE>java.net.URL</CODE>}) as the print data
1028     * representation class.
1029     * <P>
1030     *
1031     * @author Alan Kaminsky
1032     */

1033    public static class URL extends DocFlavor JavaDoc {
1034
1035        /**
1036         * Constructs a new doc flavor with the given MIME type and a print
1037         * data representation class name of <CODE>"java.net.URL"</CODE>.
1038         *
1039         * @param mimeType MIME media type string.
1040         *
1041         * @exception NullPointerException
1042         * (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
1043         * @exception IllegalArgumentException
1044         * (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
1045         * obey the syntax for a MIME media type string.
1046         */

1047        public URL (String JavaDoc mimeType) {
1048        super (mimeType, "java.net.URL");
1049    }
1050
1051        /**
1052         * Doc flavor with MIME type = <CODE>"text/plain"</CODE>,
1053     * encoded in the host platform encoding.
1054     * See {@link DocFlavor#hostEncoding <CODE>hostEncoding</CODE>}
1055         * Print data representation class name =
1056     * <CODE>"java.net.URL"</CODE> (byte stream).
1057         */

1058        public static final URL TEXT_PLAIN_HOST =
1059        new URL ("text/plain; charset="+hostEncoding);
1060
1061        /**
1062         * Doc flavor with MIME type =
1063     * <CODE>"text/plain; charset=utf-8"</CODE>,
1064         * print data representation class name =
1065     * <CODE>"java.net.URL"</CODE> (byte stream).
1066         */

1067        public static final URL TEXT_PLAIN_UTF_8 =
1068        new URL ("text/plain; charset=utf-8");
1069
1070    /**
1071         * Doc flavor with MIME type =
1072     * <CODE>"text/plain; charset=utf-16"</CODE>,
1073         * print data representation class name =
1074     * <CODE>java.net.URL""</CODE> (byte stream).
1075         */

1076        public static final URL TEXT_PLAIN_UTF_16 =
1077        new URL ("text/plain; charset=utf-16");
1078
1079    /**
1080         * Doc flavor with MIME type =
1081     * <CODE>"text/plain; charset=utf-16be"</CODE>
1082     * (big-endian byte ordering),
1083         * print data representation class name =
1084     * <CODE>"java.net.URL"</CODE> (byte stream).
1085         */

1086        public static final URL TEXT_PLAIN_UTF_16BE =
1087        new URL ("text/plain; charset=utf-16be");
1088    
1089    /**
1090         * Doc flavor with MIME type =
1091     * <CODE>"text/plain; charset=utf-16le"</CODE>
1092     * (little-endian byte ordering),
1093         * print data representation class name =
1094     * <CODE>"java.net.URL"</CODE> (byte stream).
1095         */

1096        public static final URL TEXT_PLAIN_UTF_16LE =
1097        new URL ("text/plain; charset=utf-16le");
1098
1099        /**
1100         * Doc flavor with MIME type =
1101     * <CODE>"text/plain; charset=us-ascii"</CODE>,
1102     * print data representation class name =
1103     * <CODE>"java.net.URL"</CODE> (byte stream).
1104         */

1105        public static final URL TEXT_PLAIN_US_ASCII =
1106        new URL ("text/plain; charset=us-ascii");
1107
1108        /**
1109         * Doc flavor with MIME type = <CODE>"text/html"</CODE>,
1110     * encoded in the host platform encoding.
1111     * See {@link DocFlavor#hostEncoding <CODE>hostEncoding</CODE>}
1112         * Print data representation class name =
1113     * <CODE>"java.net.URL"</CODE> (byte stream).
1114         */

1115        public static final URL TEXT_HTML_HOST =
1116        new URL ("text/html; charset="+hostEncoding);
1117
1118        /**
1119         * Doc flavor with MIME type =
1120     * <CODE>"text/html; charset=utf-8"</CODE>,
1121         * print data representation class name =
1122     * <CODE>"java.net.URL"</CODE> (byte stream).
1123         */

1124        public static final URL TEXT_HTML_UTF_8 =
1125        new URL ("text/html; charset=utf-8");
1126
1127    /**
1128         * Doc flavor with MIME type =
1129     * <CODE>"text/html; charset=utf-16"</CODE>,
1130         * print data representation class name =
1131     * <CODE>"java.net.URL"</CODE> (byte stream).
1132         */

1133        public static final URL TEXT_HTML_UTF_16 =
1134        new URL ("text/html; charset=utf-16");
1135
1136    /**
1137         * Doc flavor with MIME type =
1138     * <CODE>"text/html; charset=utf-16be"</CODE>
1139     * (big-endian byte ordering),
1140         * print data representation class name =
1141     * <CODE>"java.net.URL"</CODE> (byte stream).
1142         */

1143        public static final URL TEXT_HTML_UTF_16BE =
1144        new URL ("text/html; charset=utf-16be");
1145
1146    /**
1147         * Doc flavor with MIME type =
1148     * <CODE>"text/html; charset=utf-16le"</CODE>
1149     * (little-endian byte ordering),
1150         * print data representation class name =
1151     * <CODE>"java.net.URL"</CODE> (byte stream).
1152         */

1153        public static final URL TEXT_HTML_UTF_16LE =
1154        new URL ("text/html; charset=utf-16le");
1155
1156        /**
1157         * Doc flavor with MIME type =
1158     * <CODE>"text/html; charset=us-ascii"</CODE>,
1159     * print data representation class name =
1160     * <CODE>"java.net.URL"</CODE> (byte stream).
1161         */

1162        public static final URL TEXT_HTML_US_ASCII =
1163        new URL ("text/html; charset=us-ascii");
1164
1165
1166        /**
1167         * Doc flavor with MIME type = <CODE>"application/pdf"</CODE>, print
1168         * data representation class name = <CODE>"java.net.URL"</CODE>.
1169         */

1170        public static final URL PDF = new URL ("application/pdf");
1171
1172        /**
1173         * Doc flavor with MIME type = <CODE>"application/postscript"</CODE>,
1174         * print data representation class name = <CODE>"java.net.URL"</CODE>.
1175         */

1176        public static final URL POSTSCRIPT = new URL ("application/postscript");
1177
1178        /**
1179         * Doc flavor with MIME type = <CODE>"application/vnd.hp-PCL"</CODE>,
1180         * print data representation class name = <CODE>"java.net.URL"</CODE>.
1181         */

1182        public static final URL PCL = new URL ("application/vnd.hp-PCL");
1183
1184        /**
1185         * Doc flavor with MIME type = <CODE>"image/gif"</CODE>, print data
1186         * representation class name = <CODE>"java.net.URL"</CODE>.
1187         */

1188        public static final URL GIF = new URL ("image/gif");
1189
1190        /**
1191         * Doc flavor with MIME type = <CODE>"image/jpeg"</CODE>, print data
1192         * representation class name = <CODE>"java.net.URL"</CODE>.
1193         */

1194        public static final URL JPEG = new URL ("image/jpeg");
1195
1196        /**
1197         * Doc flavor with MIME type = <CODE>"image/png"</CODE>, print data
1198         * representation class name = <CODE>"java.net.URL"</CODE>.
1199         */

1200        public static final URL PNG = new URL ("image/png");
1201
1202        /**
1203         * Doc flavor with MIME type =
1204     * <CODE>"application/octet-stream"</CODE>,
1205         * print data representation class name = <CODE>"java.net.URL"</CODE>.
1206     * The client must determine that data described
1207     * using this DocFlavor is valid for the printer.
1208         */

1209        public static final URL AUTOSENSE = new URL ("application/octet-stream");
1210
1211    }
1212
1213    /**
1214     * Class DocFlavor.CHAR_ARRAY provides predefined static constant
1215     * DocFlavor objects for example doc flavors using a character array
1216     * (<CODE>char[]</CODE>) as the print data representation class. As such,
1217     * the character set is Unicode.
1218     * <P>
1219     *
1220     * @author Alan Kaminsky
1221     */

1222    public static class CHAR_ARRAY extends DocFlavor JavaDoc {
1223
1224    private static final long serialVersionUID = -8720590903724405128L;
1225
1226        /**
1227         * Constructs a new doc flavor with the given MIME type and a print
1228         * data representation class name of
1229     * <CODE>"[C"</CODE> (character array).
1230         *
1231         * @param mimeType MIME media type string. If it is a text media
1232         * type, it is assumed to contain a
1233         * <CODE>"charset=utf-16"</CODE> parameter.
1234         *
1235         * @exception NullPointerException
1236         * (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
1237         * @exception IllegalArgumentException
1238         * (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
1239         * obey the syntax for a MIME media type string.
1240         */

1241        public CHAR_ARRAY (String JavaDoc mimeType) {
1242        super (mimeType, "[C");
1243    }
1244
1245        /**
1246         * Doc flavor with MIME type = <CODE>"text/plain;
1247         * charset=utf-16"</CODE>, print data representation class name =
1248         * <CODE>"[C"</CODE> (character array).
1249         */

1250        public static final CHAR_ARRAY TEXT_PLAIN =
1251        new CHAR_ARRAY ("text/plain; charset=utf-16");
1252
1253        /**
1254         * Doc flavor with MIME type = <CODE>"text/html;
1255         * charset=utf-16"</CODE>, print data representation class name =
1256         * <CODE>"[C"</CODE> (character array).
1257         */

1258        public static final CHAR_ARRAY TEXT_HTML =
1259        new CHAR_ARRAY ("text/html; charset=utf-16");
1260
1261    }
1262
1263    /**
1264     * Class DocFlavor.STRING provides predefined static constant DocFlavor
1265     * objects for example doc flavors using a string ({@link java.lang.String
1266     * <CODE>java.lang.String</CODE>}) as the print data representation class.
1267     * As such, the character set is Unicode.
1268     * <P>
1269     *
1270     * @author Alan Kaminsky
1271     */

1272    public static class STRING extends DocFlavor JavaDoc {
1273
1274    private static final long serialVersionUID = 4414407504887034035L;
1275    
1276        /**
1277         * Constructs a new doc flavor with the given MIME type and a print
1278         * data representation class name of <CODE>"java.lang.String"</CODE>.
1279         *
1280         * @param mimeType MIME media type string. If it is a text media
1281         * type, it is assumed to contain a
1282         * <CODE>"charset=utf-16"</CODE> parameter.
1283         *
1284         * @exception NullPointerException
1285         * (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
1286         * @exception IllegalArgumentException
1287         * (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
1288         * obey the syntax for a MIME media type string.
1289         */

1290        public STRING (String JavaDoc mimeType) {
1291        super (mimeType, "java.lang.String");
1292    }
1293
1294        /**
1295         * Doc flavor with MIME type = <CODE>"text/plain;
1296         * charset=utf-16"</CODE>, print data representation class name =
1297         * <CODE>"java.lang.String"</CODE>.
1298         */

1299        public static final STRING TEXT_PLAIN =
1300        new STRING ("text/plain; charset=utf-16");
1301
1302        /**
1303         * Doc flavor with MIME type = <CODE>"text/html;
1304         * charset=utf-16"</CODE>, print data representation class name =
1305         * <CODE>"java.lang.String"</CODE>.
1306         */

1307        public static final STRING TEXT_HTML =
1308        new STRING ("text/html; charset=utf-16");
1309    }
1310
1311    /**
1312     * Class DocFlavor.READER provides predefined static constant DocFlavor
1313     * objects for example doc flavors using a character stream ({@link
1314     * java.io.Reader <CODE>java.io.Reader</CODE>}) as the print data
1315     * representation class. As such, the character set is Unicode.
1316     * <P>
1317     *
1318     * @author Alan Kaminsky
1319     */

1320    public static class READER extends DocFlavor JavaDoc {
1321
1322    private static final long serialVersionUID = 7100295812579351567L;
1323
1324        /**
1325         * Constructs a new doc flavor with the given MIME type and a print
1326         * data representation class name of\
1327     * <CODE>"java.io.Reader"</CODE> (character stream).
1328         *
1329         * @param mimeType MIME media type string. If it is a text media
1330         * type, it is assumed to contain a
1331         * <CODE>"charset=utf-16"</CODE> parameter.
1332         *
1333         * @exception NullPointerException
1334         * (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
1335         * @exception IllegalArgumentException
1336         * (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
1337         * obey the syntax for a MIME media type string.
1338         */

1339        public READER (String JavaDoc mimeType) {
1340        super (mimeType, "java.io.Reader");
1341    }
1342
1343        /**
1344         * Doc flavor with MIME type = <CODE>"text/plain;
1345         * charset=utf-16"</CODE>, print data representation class name =
1346         * <CODE>"java.io.Reader"</CODE> (character stream).
1347         */

1348        public static final READER TEXT_PLAIN =
1349        new READER ("text/plain; charset=utf-16");
1350
1351        /**
1352         * Doc flavor with MIME type = <CODE>"text/html;
1353         * charset=utf-16"</CODE>, print data representation class name =
1354         * <CODE>"java.io.Reader"</CODE> (character stream).
1355         */

1356        public static final READER TEXT_HTML =
1357        new READER ("text/html; charset=utf-16");
1358
1359    }
1360
1361    /**
1362     * Class DocFlavor.SERVICE_FORMATTED provides predefined static constant
1363     * DocFlavor objects for example doc flavors for service formatted print
1364     * data.
1365     * <P>
1366     *
1367     * @author Alan Kaminsky
1368     */

1369    public static class SERVICE_FORMATTED extends DocFlavor JavaDoc {
1370
1371    private static final long serialVersionUID = 6181337766266637256L;
1372
1373        /**
1374         * Constructs a new doc flavor with a MIME type of
1375         * <CODE>"application/x-java-jvm-local-objectref"</CODE> indicating
1376         * service formatted print data and the given print data
1377         * representation class name.
1378         *
1379         * @param className Fully-qualified representation class name.
1380         *
1381         * @exception NullPointerException
1382         * (unchecked exception) Thrown if <CODE>className</CODE> is
1383         * null.
1384         */

1385        public SERVICE_FORMATTED (String JavaDoc className) {
1386        super ("application/x-java-jvm-local-objectref", className);
1387    }
1388
1389        /**
1390         * Service formatted print data doc flavor with print data
1391         * representation class name =
1392         * <CODE>"java.awt.image.renderable.RenderableImage"</CODE>
1393     * (renderable image object).
1394         */

1395        public static final SERVICE_FORMATTED RENDERABLE_IMAGE =
1396        new SERVICE_FORMATTED("java.awt.image.renderable.RenderableImage");
1397
1398        /**
1399         * Service formatted print data doc flavor with print data
1400         * representation class name = <CODE>"java.awt.print.Printable"</CODE>
1401         * (printable object).
1402         */

1403        public static final SERVICE_FORMATTED PRINTABLE =
1404        new SERVICE_FORMATTED ("java.awt.print.Printable");
1405
1406        /**
1407         * Service formatted print data doc flavor with print data
1408         * representation class name = <CODE>"java.awt.print.Pageable"</CODE>
1409         * (pageable object).
1410         */

1411        public static final SERVICE_FORMATTED PAGEABLE =
1412        new SERVICE_FORMATTED ("java.awt.print.Pageable");
1413
1414        }
1415
1416}
1417
Popular Tags