1 /*
   2  * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.print;
  27 
  28 import java.io.IOException;
  29 import java.io.ObjectInputStream;
  30 import java.io.ObjectOutputStream;
  31 import java.io.Serializable;
  32 
  33 
  34 /**
  35  * Class <code>DocFlavor</code> encapsulates an object that specifies the
  36  * format in which print data is supplied to a {@link DocPrintJob}.
  37  * "Doc" is a short, easy-to-pronounce term that means "a piece of print data."
  38  * The print data format, or "doc flavor", consists of two things:
  39  * <UL>
  40  * <LI>
  41  * <B>MIME type.</B> This is a Multipurpose Internet Mail Extensions (MIME)
  42  * media type (as defined in <A HREF="http://www.ietf.org/rfc/rfc2045.txt">RFC
  43  * 2045</A> and <A HREF="http://www.ietf.org/rfc/rfc2046.txt">RFC 2046</A>)
  44  * that specifies how the print data is to be interpreted.
  45  * The charset of text data should be the IANA MIME-preferred name, or its
  46  * canonical name if no preferred name is specified. Additionally a few
  47  * historical names supported by earlier versions of the Java platform may
  48  * be recognized.
  49  * See <a href="../../java/lang/package-summary.html#charenc">
  50  * character encodings</a> for more information on the character encodings
  51  * supported on the Java platform.
  52  *
  53  * <LI>
  54  * <B>Representation class name.</B> This specifies the fully-qualified name of
  55  * the class of the object from which the actual print data comes, as returned
  56  * by the {@link java.lang.Class#getName() Class.getName()} method.
  57  * (Thus the class name for <CODE>byte[]</CODE> is <CODE>"[B"</CODE>, for
  58  * <CODE>char[]</CODE> it is <CODE>"[C"</CODE>.)
  59  * </UL>
  60  * <P>
  61  * A <code>DocPrintJob</code> obtains its print data by means of interface
  62  * {@link Doc Doc}. A <code>Doc</code> object lets the <code>DocPrintJob</code>
  63  * determine the doc flavor the client can supply.  A <code>Doc</code> object
  64  * also lets the <code>DocPrintJob</code> obtain an instance of the doc flavor's
  65  * representation class, from which the <code>DocPrintJob</code> then obtains
  66  * the actual print data.
  67  *
  68  * <HR>
  69  * <H3>Client Formatted Print Data</H3>
  70  * There are two broad categories of print data, client formatted print data
  71  * and service formatted print data.
  72  * <P>
  73  * For <B>client formatted print data</B>, the client determines or knows the
  74  * print data format.
  75  * For example the client may have a JPEG encoded image, a URL for
  76  * HTML code, or a disk file containing plain text in some encoding,
  77  * possibly obtained from an external source, and
  78  * requires a way to describe the data format to the print service.
  79  * <p>
  80  * The doc flavor's representation class is a conduit for the JPS
  81  * <code>DocPrintJob</code> to obtain a sequence of characters or
  82  * bytes from the client. The
  83  * doc flavor's MIME type is one of the standard media types telling how to
  84  * interpret the sequence of characters or bytes. For a list of standard media
  85  * types, see the Internet Assigned Numbers Authority's (IANA's) <A
  86  * HREF="http://www.iana.org/assignments/media-types/">Media Types
  87  * Directory</A>. Interface {@link Doc Doc} provides two utility operations,
  88  * {@link Doc#getReaderForText() getReaderForText} and
  89  * {@link Doc#getStreamForBytes() getStreamForBytes()}, to help a
  90  * <code>Doc</code> object's client extract client formatted print data.
  91  * <P>
  92  * For client formatted print data, the print data representation class is
  93  * typically one of the following (although other representation classes are
  94  * permitted):
  95  * <UL>
  96  * <LI>
  97  * Character array (<CODE>char[]</CODE>) -- The print data consists of the
  98  * Unicode characters in the array.
  99  *
 100  * <LI>
 101  * <code>String</code>  --
 102  * The print data consists of the Unicode characters in the string.
 103  *
 104  * <LI>
 105  * Character stream ({@link java.io.Reader java.io.Reader})
 106  * -- The print data consists of the Unicode characters read from the stream
 107  * up to the end-of-stream.
 108  *
 109  * <LI>
 110  * Byte array (<CODE>byte[]</CODE>) -- The print data consists of the bytes in
 111  * the array. The bytes are encoded in the character set specified by the doc
 112  * flavor's MIME type. If the MIME type does not specify a character set, the
 113  * default character set is US-ASCII.
 114  *
 115  * <LI>
 116  * Byte stream ({@link java.io.InputStream java.io.InputStream}) --
 117  * The print data consists of the bytes read from the stream up to the
 118  * end-of-stream. The bytes are encoded in the character set specified by the
 119  * doc flavor's MIME type. If the MIME type does not specify a character set,
 120  * the default character set is US-ASCII.
 121 
 122  * <LI>
 123  * Uniform Resource Locator ({@link java.net.URL URL})
 124  * -- The print data consists of the bytes read from the URL location.
 125  * The bytes are encoded in the character set specified by the doc flavor's
 126  * MIME type. If the MIME type does not specify a character set, the default
 127  * character set is US-ASCII.
 128  * <P>
 129  * When the representation class is a URL, the print service itself accesses
 130  * and downloads the document directly from its URL address, without involving
 131  * the client. The service may be some form of network print service which
 132  * is executing in a different environment.
 133  * This means you should not use a URL print data flavor to print a
 134  * document at a restricted URL that the client can see but the printer cannot
 135  * see. This also means you should not use a URL print data flavor to print a
 136  * document stored in a local file that is not available at a URL
 137  * accessible independently of the client.
 138  * For example, a file that is not served up by an HTTP server or FTP server.
 139  * To print such documents, let the client open an input stream on the URL
 140  * or file and use an input stream data flavor.
 141  * </UL>
 142  *
 143  * <HR>
 144  * <h3>Default and Platform Encodings</h3>
 145  * <P>
 146  * For byte print data where the doc flavor's MIME type does not include a
 147  * <CODE>charset</CODE> parameter, the Java Print Service instance assumes the
 148  * US-ASCII character set by default. This is in accordance with
 149  * <A HREF="http://www.ietf.org/rfc/rfc2046.txt">RFC 2046</A>, which says the
 150  * default character set is US-ASCII. Note that US-ASCII is a subset of
 151  * UTF-8, so in the future this may be widened if a future RFC endorses
 152  * UTF-8 as the default in a compatible manner.
 153  * <p>
 154  * Also note that this is different than the behaviour of the Java runtime
 155  * when interpreting a stream of bytes as text data. That assumes the
 156  * default encoding for the user's locale. Thus, when spooling a file in local
 157  * encoding to a Java Print Service it is important to correctly specify
 158  * the encoding. Developers working in the English locales should
 159  * be particularly conscious of this, as their platform encoding corresponds
 160  * to the default mime charset. By this coincidence that particular
 161  * case may work without specifying the encoding of platform data.
 162  * <p>
 163  * Every instance of the Java virtual machine has a default character encoding
 164  * determined during virtual-machine startup and typically depends upon the
 165  * locale and charset being used by the underlying operating system.
 166  * In a distributed environment there is no guarantee that two VM share
 167  * the same default encoding. Thus clients which want to stream platform
 168  * encoded text data from the host platform to a Java Print Service instance
 169  * must explicitly declare the charset and not rely on defaults.
 170  * <p>
 171  * The preferred form is the official IANA primary name for an encoding.
 172  * Applications which stream text data should always specify the charset
 173  * in the mime type, which necessitates obtaining the encoding of the host
 174  * platform for data (eg files) stored in that platform's encoding.
 175  * A CharSet which corresponds to this and is suitable for use in a
 176  * mime-type for a DocFlavor can be obtained
 177  * from {@link DocFlavor#hostEncoding DocFlavor.hostEncoding}
 178  * This may not always be the primary IANA name but is guaranteed to be
 179  * understood by this VM.
 180  * For common flavors, the pre-defined *HOST DocFlavors may be used.
 181  * <p>
 182  * See <a href="../../java/lang/package-summary.html#charenc">
 183  * character encodings</a> for more information on the character encodings
 184  * supported on the Java platform.
 185  * <HR>
 186  * <h3>Recommended DocFlavors</h3>
 187  * <P>
 188  * The Java Print Service API does not define any mandatorily supported
 189  * DocFlavors.
 190  * However, here are some examples of MIME types that a Java Print Service
 191  * instance might support for client formatted print data.
 192  * Nested classes inside class DocFlavor declare predefined static
 193  * constant DocFlavor objects for these example doc flavors; class DocFlavor's
 194  * constructor can be used to create an arbitrary doc flavor.
 195  * <UL>
 196  * <LI>Preformatted text
 197  * <TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 SUMMARY="MIME-Types and their descriptions">
 198  * <TR>
 199  *  <TH>MIME-Type</TH><TH>Description</TH>
 200  * </TR>
 201  * <TR>
 202  * <TD><CODE>"text/plain"</CODE></TD>
 203  * <TD>Plain text in the default character set (US-ASCII)</TD>
 204  * </TR>
 205  * <TR>
 206  * <TD><CODE>"text/plain; charset=<I>xxx</I>"</CODE></TD>
 207  * <TD>Plain text in character set <I>xxx</I></TD>
 208  * </TR>
 209  * <TR>
 210  * <TD><CODE>"text/html"</CODE></TD>
 211  * <TD>HyperText Markup Language in the default character set (US-ASCII)</TD>
 212  * </TR>
 213  * <TR>
 214  * <TD><CODE>"text/html; charset=<I>xxx</I>"</CODE></TD>
 215  * <TD>HyperText Markup Language in character set <I>xxx</I></TD>
 216  * </TR>
 217  * </TABLE>
 218  * <P>
 219  * In general, preformatted text print data is provided either in a character
 220  * oriented representation class (character array, String, Reader) or in a
 221  * byte oriented representation class (byte array, InputStream, URL).
 222  *
 223  *  <LI>Preformatted page description language (PDL) documents
 224  *
 225  * <TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 SUMMARY="MIME-Types and their descriptions">
 226  * <TR>
 227  *  <TH>MIME-Type</TH><TH>Description</TH>
 228  * </TR>
 229  *<TR>
 230  * <TD><CODE>"application/pdf"</CODE></TD>
 231  * <TD>Portable Document Format document</TD>
 232  * </TR>
 233  * <TR>
 234  * <TD><CODE>"application/postscript"</CODE></TD>
 235  * <TD>PostScript document</TD>
 236  * </TR>
 237  * <TR>
 238  * <TD><CODE>"application/vnd.hp-PCL"</CODE></TD>
 239  * <TD>Printer Control Language document</TD>
 240  * </TR>
 241  * </TABLE>
 242  * <P>
 243  * In general, preformatted PDL print data is provided in a byte oriented
 244  * representation class (byte array, InputStream, URL).
 245  *
 246  *  <LI>Preformatted images
 247  *
 248  * <TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 SUMMARY="MIME-Types and their descriptions">
 249  * <TR>
 250  *  <TH>MIME-Type</TH><TH>Description</TH>
 251  * </TR>
 252  *
 253  * <TR>
 254  * <TD><CODE>"image/gif"</CODE></TD>
 255  * <TD>Graphics Interchange Format image</TD>
 256  * </TR>
 257  * <TR>
 258  * <TD><CODE>"image/jpeg"</CODE></TD>
 259  * <TD>Joint Photographic Experts Group image</TD>
 260  * </TR>
 261  * <TR>
 262  * <TD><CODE>"image/png"</CODE></TD>
 263  * <TD>Portable Network Graphics image</TD>
 264  * </TR>
 265  * </TABLE>
 266  * <P>
 267  * In general, preformatted image print data is provided in a byte oriented
 268  * representation class (byte array, InputStream, URL).
 269  *
 270  *  <LI>Preformatted autosense print data
 271  *
 272  * <TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 SUMMARY="MIME-Types and their descriptions">
 273  * <TR>
 274  *  <TH>MIME-Type</TH><TH>Description</TH>
 275  * </TR>
 276  *
 277  * <TR>
 278  * <TD><CODE>"application/octet-stream"</CODE></TD>
 279  * <TD>The print data format is unspecified (just an octet stream)</TD>
 280  * </TABLE>
 281  * <P>
 282  * The printer decides how to interpret the print data; the way this
 283  * "autosensing" works is implementation dependent. In general, preformatted
 284  * autosense print data is provided in a byte oriented representation class
 285  * (byte array, InputStream, URL).
 286  * </UL>
 287  *
 288  * <HR>
 289  * <H3>Service Formatted Print Data</H3>
 290  * <P>
 291  * For <B>service formatted print data</B>, the Java Print Service instance
 292  * determines the print data format. The doc flavor's representation class
 293  * denotes an interface whose methods the <code>DocPrintJob</code> invokes to
 294  * determine the content to be printed -- such as a renderable image
 295  * interface or a Java printable interface.
 296  * The doc flavor's MIME type is the special value
 297  * <CODE>"application/x-java-jvm-local-objectref"</CODE> indicating the client
 298  * will supply a reference to a Java object that implements the interface
 299  * named as the representation class.
 300  * This MIME type is just a placeholder; what's
 301  * important is the print data representation class.
 302  * <P>
 303  * For service formatted print data, the print data representation class is
 304  * typically one of the following (although other representation classes are
 305  * permitted). Nested classes inside class DocFlavor declare predefined static
 306  * constant DocFlavor objects for these example doc flavors; class DocFlavor's
 307  * constructor can be used to create an arbitrary doc flavor.
 308  * <UL>
 309  * <LI>
 310  * Renderable image object -- The client supplies an object that implements
 311  * interface
 312  * {@link java.awt.image.renderable.RenderableImage RenderableImage}. The
 313  * printer calls methods
 314  * in that interface to obtain the image to be printed.
 315  *
 316  * <LI>
 317  * Printable object -- The client supplies an object that implements interface
 318  * {@link java.awt.print.Printable Printable}.
 319  * The printer calls methods in that interface to obtain the pages to be
 320  * printed, one by one.
 321  * For each page, the printer supplies a graphics context, and whatever the
 322  * client draws in that graphics context gets printed.
 323  *
 324  * <LI>
 325  * Pageable object -- The client supplies an object that implements interface
 326  * {@link java.awt.print.Pageable Pageable}. The printer calls
 327  * methods in that interface to obtain the pages to be printed, one by one.
 328  * For each page, the printer supplies a graphics context, and whatever
 329  * the client draws in that graphics context gets printed.
 330  * </UL>
 331  *
 332  * <HR>
 333  *
 334  * <HR>
 335  * <H3>Pre-defined Doc Flavors</H3>
 336  * A Java Print Service instance is not <B><I>required</I></B> to support the
 337  * following print data formats and print data representation classes.  In
 338  * fact, a developer using this class should <b>never</b> assume that a
 339  * particular print service supports the document types corresponding to
 340  * these pre-defined doc flavors.  Always query the print service
 341  * to determine what doc flavors it supports.  However,
 342  * developers who have print services that support these doc flavors are
 343  * encouraged to refer to the predefined singleton instances created here.
 344  * <UL>
 345  * <LI>
 346  * Plain text print data provided through a byte stream. Specifically, the
 347  * following doc flavors are recommended to be supported:
 348  * <BR>&#183;&nbsp;&nbsp;
 349  * <CODE>("text/plain", "java.io.InputStream")</CODE>
 350  * <BR>&#183;&nbsp;&nbsp;
 351  * <CODE>("text/plain; charset=us-ascii", "java.io.InputStream")</CODE>
 352  * <BR>&#183;&nbsp;&nbsp;
 353  * <CODE>("text/plain; charset=utf-8", "java.io.InputStream")</CODE>
 354  *
 355  * <LI>
 356  * Renderable image objects. Specifically, the following doc flavor is
 357  * recommended to be supported:
 358  * <BR>&#183;&nbsp;&nbsp;
 359  * <CODE>("application/x-java-jvm-local-objectref", "java.awt.image.renderable.RenderableImage")</CODE>
 360  * </UL>
 361  * <P>
 362  * A Java Print Service instance is allowed to support any other doc flavors
 363  * (or none) in addition to the above mandatory ones, at the implementation's
 364  * choice.
 365  * <P>
 366  * Support for the above doc flavors is desirable so a printing client can rely
 367  * on being able to print on any JPS printer, regardless of which doc flavors
 368  * the printer supports. If the printer doesn't support the client's preferred
 369  * doc flavor, the client can at least print plain text, or the client can
 370  * convert its data to a renderable image and print the image.
 371  * <P>
 372  * Furthermore, every Java Print Service instance must fulfill these
 373  * requirements for processing plain text print data:
 374  * <UL>
 375  * <LI>
 376  * The character pair carriage return-line feed (CR-LF) means
 377  * "go to column 1 of the next line."
 378  * <LI>
 379  * A carriage return (CR) character standing by itself means
 380  * "go to column 1 of the next line."
 381  * <LI>
 382  * A line feed (LF) character standing by itself means
 383  * "go to column 1 of the next line."
 384  * </UL>
 385  * <P>
 386  * The client must itself perform all plain text print data formatting not
 387  * addressed by the above requirements.
 388  *
 389  * <H3>Design Rationale</H3>
 390  * <P>
 391  * Class DocFlavor in package javax.print.data is similar to class
 392  * {@link java.awt.datatransfer.DataFlavor DataFlavor}. Class
 393  * <code>DataFlavor</code>
 394  * is not used in the Java Print Service (JPS) API
 395  * for three reasons which are all rooted in allowing the JPS API to be
 396  * shared by other print services APIs which may need to run on Java profiles
 397  * which do not include all of the Java Platform, Standard Edition.
 398  * <OL TYPE=1>
 399  * <LI>
 400  * The JPS API is designed to be used in Java profiles which do not support
 401  * AWT.
 402  *
 403  * <LI>
 404  * The implementation of class <code>java.awt.datatransfer.DataFlavor</code>
 405  * does not guarantee that equivalent data flavors will have the same
 406  * serialized representation. DocFlavor does, and can be used in services
 407  * which need this.
 408  *
 409  * <LI>
 410  * The implementation of class <code>java.awt.datatransfer.DataFlavor</code>
 411  * includes a human presentable name as part of the serialized representation.
 412  * This is not appropriate as part of a service matching constraint.
 413  * </OL>
 414  * <P>
 415  * Class DocFlavor's serialized representation uses the following
 416  * canonical form of a MIME type string. Thus, two doc flavors with MIME types
 417  * that are not identical but that are equivalent (that have the same
 418  * canonical form) may be considered equal.
 419  * <UL>
 420  * <LI> The media type, media subtype, and parameters are retained, but all
 421  *      comments and whitespace characters are discarded.
 422  * <LI> The media type, media subtype, and parameter names are converted to
 423  *      lowercase.
 424  * <LI> The parameter values retain their original case, except a charset
 425  *      parameter value for a text media type is converted to lowercase.
 426  * <LI> Quote characters surrounding parameter values are removed.
 427  * <LI> Quoting backslash characters inside parameter values are removed.
 428  * <LI> The parameters are arranged in ascending order of parameter name.
 429  * </UL>
 430  * <P>
 431  * Class DocFlavor's serialized representation also contains the
 432  * fully-qualified class <I>name</I> of the representation class
 433  * (a String object), rather than the representation class itself
 434  * (a Class object). This allows a client to examine the doc flavors a
 435  * Java Print Service instance supports without having
 436  * to load the representation classes, which may be problematic for
 437  * limited-resource clients.
 438  *
 439  * @author  Alan Kaminsky
 440  */
 441 public class DocFlavor implements Serializable, Cloneable {
 442 
 443     private static final long serialVersionUID = -4512080796965449721L;
 444 
 445     /**
 446      * A String representing the host operating system encoding.
 447      * This will follow the conventions documented in
 448      * <a href="http://www.ietf.org/rfc/rfc2278.txt">
 449      * <i>RFC&nbsp;2278:&nbsp;IANA Charset Registration Procedures</i></a>
 450      * except where historical names are returned for compatibility with
 451      * previous versions of the Java platform.
 452      * The value returned from method is valid only for the VM which
 453      * returns it, for use in a DocFlavor.
 454      * This is the charset for all the "HOST" pre-defined DocFlavors in
 455      * the executing VM.
 456      */
 457     public static final String hostEncoding;
 458 
 459     static {
 460         hostEncoding =
 461             java.security.AccessController.doPrivileged(
 462                   new sun.security.action.GetPropertyAction("file.encoding"));
 463     }
 464 
 465     /**
 466      * MIME type.
 467      */
 468     private transient MimeType myMimeType;
 469 
 470     /**
 471      * Representation class name.
 472      * @serial
 473      */
 474     private String myClassName;
 475 
 476     /**
 477      * String value for this doc flavor. Computed when needed and cached.
 478      */
 479     private transient String myStringValue = null;
 480 
 481 
 482     /**
 483      * Constructs a new doc flavor object from the given MIME type and
 484      * representation class name. The given MIME type is converted into
 485      * canonical form and stored internally.
 486      *
 487      * @param  mimeType   MIME media type string.
 488      * @param  className  Fully-qualified representation class name.
 489      *
 490      * @exception  NullPointerException
 491      *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null or
 492      *     <CODE>className</CODE> is null.
 493      * @exception  IllegalArgumentException
 494      *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
 495      *     obey the syntax for a MIME media type string.
 496      */
 497     public DocFlavor(String mimeType, String className) {
 498         if (className == null) {
 499             throw new NullPointerException();
 500         }
 501         myMimeType = new MimeType (mimeType);
 502         myClassName = className;
 503     }
 504 
 505     /**
 506      * Returns this doc flavor object's MIME type string based on the
 507      * canonical form. Each parameter value is enclosed in quotes.
 508      * @return the mime type
 509      */
 510     public String getMimeType() {
 511         return myMimeType.getMimeType();
 512     }
 513 
 514     /**
 515      * Returns this doc flavor object's media type (from the MIME type).
 516      * @return the media type
 517      */
 518     public String getMediaType() {
 519         return myMimeType.getMediaType();
 520     }
 521 
 522     /**
 523      * Returns this doc flavor object's media subtype (from the MIME type).
 524      * @return the media sub-type
 525      */
 526     public String getMediaSubtype() {
 527         return myMimeType.getMediaSubtype();
 528     }
 529 
 530     /**
 531      * Returns a <code>String</code> representing a MIME
 532      * parameter.
 533      * Mime types may include parameters which are usually optional.
 534      * The charset for text types is a commonly useful example.
 535      * This convenience method will return the value of the specified
 536      * parameter if one was specified in the mime type for this flavor.
 537      *
 538      * @param paramName the name of the paramater. This name is internally
 539      * converted to the canonical lower case format before performing
 540      * the match.
 541      * @return String representing a mime parameter, or
 542      * null if that parameter is not in the mime type string.
 543      * @exception NullPointerException if paramName is null.
 544      */
 545     public String getParameter(String paramName) {
 546         return myMimeType.getParameterMap().get(paramName.toLowerCase());
 547     }
 548 
 549     /**
 550      * Returns the name of this doc flavor object's representation class.
 551      * @return the name of the representation class.
 552      */
 553     public String getRepresentationClassName() {
 554         return myClassName;
 555     }
 556 
 557     /**
 558      * Converts this <code>DocFlavor</code> to a string.
 559      *
 560      * @return  MIME type string based on the canonical form. Each parameter
 561      *          value is enclosed in quotes.
 562      *          A "class=" parameter is appended to the
 563      *          MIME type string to indicate the representation class name.
 564      */
 565     public String toString() {
 566         return getStringValue();
 567     }
 568 
 569     /**
 570      * Returns a hash code for this doc flavor object.
 571      */
 572     public int hashCode() {
 573         return getStringValue().hashCode();
 574     }
 575 
 576     /**
 577      * Determines if this doc flavor object is equal to the given object.
 578      * The two are equal if the given object is not null, is an instance
 579      * of <code>DocFlavor</code>, has a MIME type equivalent to this doc
 580      * flavor object's MIME type (that is, the MIME types have the same media
 581      * type, media subtype, and parameters), and has the same representation
 582      * class name as this doc flavor object. Thus, if two doc flavor objects'
 583      * MIME types are the same except for comments, they are considered equal.
 584      * However, two doc flavor objects with MIME types of "text/plain" and
 585      * "text/plain; charset=US-ASCII" are not considered equal, even though
 586      * they represent the same media type (because the default character
 587      * set for plain text is US-ASCII).
 588      *
 589      * @param  obj  Object to test.
 590      *
 591      * @return  True if this doc flavor object equals <CODE>obj</CODE>, false
 592      *          otherwise.
 593      */
 594     public boolean equals(Object obj) {
 595         return
 596             obj != null &&
 597             obj instanceof DocFlavor &&
 598             getStringValue().equals (((DocFlavor) obj).getStringValue());
 599     }
 600 
 601     /**
 602      * Returns this doc flavor object's string value.
 603      */
 604     private String getStringValue() {
 605         if (myStringValue == null) {
 606             myStringValue = myMimeType + "; class=\"" + myClassName + "\"";
 607         }
 608         return myStringValue;
 609     }
 610 
 611     /**
 612      * Write the instance to a stream (ie serialize the object).
 613      * 
 614      * @throws IOException if I/O errors occur while writing to the underlying
 615      * stream
 616      */
 617     private void writeObject(ObjectOutputStream s) throws IOException {
 618 
 619         s.defaultWriteObject();
 620         s.writeObject(myMimeType.getMimeType());
 621     }
 622 
 623     /**
 624      * Reconstitute an instance from a stream (that is, deserialize it).
 625      *
 626      * @throws ClassNotFoundException if the class of a serialized object could
 627      * not be found.
 628      * @throws IOException if I/O errors occur while reading from the underlying
 629      * stream
 630      * @serialData
 631      * The serialised form of a DocFlavor is the String naming the
 632      * representation class followed by the String representing the canonical
 633      * form of the mime type.
 634      */
 635     private void readObject(ObjectInputStream s)
 636         throws ClassNotFoundException, IOException {
 637 
 638         s.defaultReadObject();
 639         myMimeType = new MimeType((String)s.readObject());
 640     }
 641 
 642     /**
 643      * Class DocFlavor.BYTE_ARRAY provides predefined static constant
 644      * DocFlavor objects for example doc flavors using a byte array
 645      * (<CODE>byte[]</CODE>) as the print data representation class.
 646      *
 647      * @author  Alan Kaminsky
 648      */
 649     public static class BYTE_ARRAY extends DocFlavor {
 650 
 651         private static final long serialVersionUID = -9065578006593857475L;
 652 
 653         /**
 654          * Constructs a new doc flavor with the given MIME type and a print
 655          * data representation class name of <CODE>"[B"</CODE> (byte array).
 656          *
 657          * @param  mimeType   MIME media type string.
 658          *
 659          * @exception  NullPointerException
 660          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
 661          * @exception  IllegalArgumentException
 662          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
 663          *     obey the syntax for a MIME media type string.
 664          */
 665         public BYTE_ARRAY (String mimeType) {
 666             super (mimeType, "[B");
 667         }
 668 
 669         /**
 670          * Doc flavor with MIME type = <CODE>"text/plain"</CODE>,
 671          * encoded in the host platform encoding.
 672          * See {@link DocFlavor#hostEncoding hostEncoding}
 673          * Print data representation class name =
 674          * <CODE>"[B"</CODE> (byte array).
 675          */
 676         public static final BYTE_ARRAY TEXT_PLAIN_HOST =
 677             new BYTE_ARRAY ("text/plain; charset="+hostEncoding);
 678 
 679         /**
 680          * Doc flavor with MIME type =
 681          * <CODE>"text/plain; charset=utf-8"</CODE>,
 682          * print data representation class name = <CODE>"[B"</CODE> (byte
 683          * array).
 684          */
 685         public static final BYTE_ARRAY TEXT_PLAIN_UTF_8 =
 686             new BYTE_ARRAY ("text/plain; charset=utf-8");
 687 
 688         /**
 689          * Doc flavor with MIME type =
 690          * <CODE>"text/plain; charset=utf-16"</CODE>,
 691          * print data representation class name = <CODE>"[B"</CODE> (byte
 692          * array).
 693          */
 694         public static final BYTE_ARRAY TEXT_PLAIN_UTF_16 =
 695             new BYTE_ARRAY ("text/plain; charset=utf-16");
 696 
 697 
 698         /**
 699          * Doc flavor with MIME type =
 700          * <CODE>"text/plain; charset=utf-16be"</CODE>
 701          * (big-endian byte ordering),
 702          * print data representation class name = <CODE>"[B"</CODE> (byte
 703          * array).
 704          */
 705         public static final BYTE_ARRAY TEXT_PLAIN_UTF_16BE =
 706             new BYTE_ARRAY ("text/plain; charset=utf-16be");
 707 
 708         /**
 709          * Doc flavor with MIME type =
 710          * <CODE>"text/plain; charset=utf-16le"</CODE>
 711          * (little-endian byte ordering),
 712          * print data representation class name = <CODE>"[B"</CODE> (byte
 713          * array).
 714          */
 715         public static final BYTE_ARRAY TEXT_PLAIN_UTF_16LE =
 716             new BYTE_ARRAY ("text/plain; charset=utf-16le");
 717 
 718         /**
 719          * Doc flavor with MIME type =
 720          * <CODE>"text/plain; charset=us-ascii"</CODE>,
 721          * print data representation class name =
 722          * <CODE>"[B"</CODE> (byte array).
 723          */
 724         public static final BYTE_ARRAY TEXT_PLAIN_US_ASCII =
 725             new BYTE_ARRAY ("text/plain; charset=us-ascii");
 726 
 727 
 728         /**
 729          * Doc flavor with MIME type = <CODE>"text/html"</CODE>,
 730          * encoded in the host platform encoding.
 731          * See {@link DocFlavor#hostEncoding hostEncoding}
 732          * Print data representation class name =
 733          * <CODE>"[B"</CODE> (byte array).
 734          */
 735         public static final BYTE_ARRAY TEXT_HTML_HOST =
 736             new BYTE_ARRAY ("text/html; charset="+hostEncoding);
 737 
 738         /**
 739          * Doc flavor with MIME type =
 740          * <CODE>"text/html; charset=utf-8"</CODE>,
 741          * print data representation class name = <CODE>"[B"</CODE> (byte
 742          * array).
 743          */
 744         public static final BYTE_ARRAY TEXT_HTML_UTF_8 =
 745             new BYTE_ARRAY ("text/html; charset=utf-8");
 746 
 747         /**
 748          * Doc flavor with MIME type =
 749          * <CODE>"text/html; charset=utf-16"</CODE>,
 750          * print data representation class name = <CODE>"[B"</CODE> (byte
 751          * array).
 752          */
 753         public static final BYTE_ARRAY TEXT_HTML_UTF_16 =
 754             new BYTE_ARRAY ("text/html; charset=utf-16");
 755 
 756         /**
 757          * Doc flavor with MIME type =
 758          * <CODE>"text/html; charset=utf-16be"</CODE>
 759          * (big-endian byte ordering),
 760          * print data representation class name = <CODE>"[B"</CODE> (byte
 761          * array).
 762          */
 763         public static final BYTE_ARRAY TEXT_HTML_UTF_16BE =
 764             new BYTE_ARRAY ("text/html; charset=utf-16be");
 765 
 766         /**
 767          * Doc flavor with MIME type =
 768          * <CODE>"text/html; charset=utf-16le"</CODE>
 769          * (little-endian byte ordering),
 770          * print data representation class name = <CODE>"[B"</CODE> (byte
 771          * array).
 772          */
 773         public static final BYTE_ARRAY TEXT_HTML_UTF_16LE =
 774             new BYTE_ARRAY ("text/html; charset=utf-16le");
 775 
 776         /**
 777          * Doc flavor with MIME type =
 778          * <CODE>"text/html; charset=us-ascii"</CODE>,
 779          * print data representation class name =
 780          * <CODE>"[B"</CODE> (byte array).
 781          */
 782         public static final BYTE_ARRAY TEXT_HTML_US_ASCII =
 783             new BYTE_ARRAY ("text/html; charset=us-ascii");
 784 
 785 
 786         /**
 787          * Doc flavor with MIME type = <CODE>"application/pdf"</CODE>, print
 788          * data representation class name = <CODE>"[B"</CODE> (byte array).
 789          */
 790         public static final BYTE_ARRAY PDF = new BYTE_ARRAY ("application/pdf");
 791 
 792         /**
 793          * Doc flavor with MIME type = <CODE>"application/postscript"</CODE>,
 794          * print data representation class name = <CODE>"[B"</CODE> (byte
 795          * array).
 796          */
 797         public static final BYTE_ARRAY POSTSCRIPT =
 798             new BYTE_ARRAY ("application/postscript");
 799 
 800         /**
 801          * Doc flavor with MIME type = <CODE>"application/vnd.hp-PCL"</CODE>,
 802          * print data representation class name = <CODE>"[B"</CODE> (byte
 803          * array).
 804          */
 805         public static final BYTE_ARRAY PCL =
 806             new BYTE_ARRAY ("application/vnd.hp-PCL");
 807 
 808         /**
 809          * Doc flavor with MIME type = <CODE>"image/gif"</CODE>, print data
 810          * representation class name = <CODE>"[B"</CODE> (byte array).
 811          */
 812         public static final BYTE_ARRAY GIF = new BYTE_ARRAY ("image/gif");
 813 
 814         /**
 815          * Doc flavor with MIME type = <CODE>"image/jpeg"</CODE>, print data
 816          * representation class name = <CODE>"[B"</CODE> (byte array).
 817          */
 818         public static final BYTE_ARRAY JPEG = new BYTE_ARRAY ("image/jpeg");
 819 
 820         /**
 821          * Doc flavor with MIME type = <CODE>"image/png"</CODE>, print data
 822          * representation class name = <CODE>"[B"</CODE> (byte array).
 823          */
 824         public static final BYTE_ARRAY PNG = new BYTE_ARRAY ("image/png");
 825 
 826         /**
 827          * Doc flavor with MIME type =
 828          * <CODE>"application/octet-stream"</CODE>,
 829          * print data representation class name = <CODE>"[B"</CODE> (byte
 830          * array). The client must determine that data described
 831          * using this DocFlavor is valid for the printer.
 832          */
 833         public static final BYTE_ARRAY AUTOSENSE =
 834             new BYTE_ARRAY ("application/octet-stream");
 835 
 836     }
 837 
 838     /**
 839      * Class DocFlavor.INPUT_STREAM provides predefined static constant
 840      * DocFlavor objects for example doc flavors using a byte stream ({@link
 841      * java.io.InputStream java.io.InputStream}) as the print
 842      * data representation class.
 843      *
 844      * @author  Alan Kaminsky
 845      */
 846     public static class INPUT_STREAM extends DocFlavor {
 847 
 848         private static final long serialVersionUID = -7045842700749194127L;
 849 
 850         /**
 851          * Constructs a new doc flavor with the given MIME type and a print
 852          * data representation class name of
 853          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 854          *
 855          * @param  mimeType   MIME media type string.
 856          *
 857          * @exception  NullPointerException
 858          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
 859          * @exception  IllegalArgumentException
 860          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
 861          *     obey the syntax for a MIME media type string.
 862          */
 863         public INPUT_STREAM (String mimeType) {
 864             super (mimeType, "java.io.InputStream");
 865         }
 866 
 867         /**
 868          * Doc flavor with MIME type = <CODE>"text/plain"</CODE>,
 869          * encoded in the host platform encoding.
 870          * See {@link DocFlavor#hostEncoding hostEncoding}
 871          * Print data representation class name =
 872          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 873          */
 874         public static final INPUT_STREAM TEXT_PLAIN_HOST =
 875             new INPUT_STREAM ("text/plain; charset="+hostEncoding);
 876 
 877         /**
 878          * Doc flavor with MIME type =
 879          * <CODE>"text/plain; charset=utf-8"</CODE>,
 880          * print data representation class name =
 881          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 882          */
 883         public static final INPUT_STREAM TEXT_PLAIN_UTF_8 =
 884             new INPUT_STREAM ("text/plain; charset=utf-8");
 885 
 886         /**
 887          * Doc flavor with MIME type =
 888          * <CODE>"text/plain; charset=utf-16"</CODE>,
 889          * print data representation class name =
 890          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 891          */
 892         public static final INPUT_STREAM TEXT_PLAIN_UTF_16 =
 893             new INPUT_STREAM ("text/plain; charset=utf-16");
 894 
 895         /**
 896          * Doc flavor with MIME type =
 897          * <CODE>"text/plain; charset=utf-16be"</CODE>
 898          * (big-endian byte ordering),
 899          * print data representation class name =
 900          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 901          */
 902         public static final INPUT_STREAM TEXT_PLAIN_UTF_16BE =
 903             new INPUT_STREAM ("text/plain; charset=utf-16be");
 904 
 905         /**
 906          * Doc flavor with MIME type =
 907          * <CODE>"text/plain; charset=utf-16le"</CODE>
 908          * (little-endian byte ordering),
 909          * print data representation class name =
 910          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 911          */
 912         public static final INPUT_STREAM TEXT_PLAIN_UTF_16LE =
 913             new INPUT_STREAM ("text/plain; charset=utf-16le");
 914 
 915         /**
 916          * Doc flavor with MIME type =
 917          * <CODE>"text/plain; charset=us-ascii"</CODE>,
 918          * print data representation class name =
 919          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 920          */
 921         public static final INPUT_STREAM TEXT_PLAIN_US_ASCII =
 922                 new INPUT_STREAM ("text/plain; charset=us-ascii");
 923 
 924         /**
 925          * Doc flavor with MIME type = <CODE>"text/html"</CODE>,
 926          * encoded in the host platform encoding.
 927          * See {@link DocFlavor#hostEncoding hostEncoding}
 928          * Print data representation class name =
 929          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 930          */
 931         public static final INPUT_STREAM TEXT_HTML_HOST =
 932             new INPUT_STREAM ("text/html; charset="+hostEncoding);
 933 
 934         /**
 935          * Doc flavor with MIME type =
 936          * <CODE>"text/html; charset=utf-8"</CODE>,
 937          * print data representation class name =
 938          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 939          */
 940         public static final INPUT_STREAM TEXT_HTML_UTF_8 =
 941             new INPUT_STREAM ("text/html; charset=utf-8");
 942 
 943         /**
 944          * Doc flavor with MIME type =
 945          * <CODE>"text/html; charset=utf-16"</CODE>,
 946          * print data representation class name =
 947          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 948          */
 949         public static final INPUT_STREAM TEXT_HTML_UTF_16 =
 950             new INPUT_STREAM ("text/html; charset=utf-16");
 951 
 952         /**
 953          * Doc flavor with MIME type =
 954          * <CODE>"text/html; charset=utf-16be"</CODE>
 955          * (big-endian byte ordering),
 956          * print data representation class name =
 957          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 958          */
 959         public static final INPUT_STREAM TEXT_HTML_UTF_16BE =
 960             new INPUT_STREAM ("text/html; charset=utf-16be");
 961 
 962         /**
 963          * Doc flavor with MIME type =
 964          * <CODE>"text/html; charset=utf-16le"</CODE>
 965          * (little-endian byte ordering),
 966          * print data representation class name =
 967          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 968          */
 969         public static final INPUT_STREAM TEXT_HTML_UTF_16LE =
 970             new INPUT_STREAM ("text/html; charset=utf-16le");
 971 
 972         /**
 973          * Doc flavor with MIME type =
 974          * <CODE>"text/html; charset=us-ascii"</CODE>,
 975          * print data representation class name =
 976          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 977          */
 978         public static final INPUT_STREAM TEXT_HTML_US_ASCII =
 979             new INPUT_STREAM ("text/html; charset=us-ascii");
 980 
 981 
 982         /**
 983          * Doc flavor with MIME type = <CODE>"application/pdf"</CODE>, print
 984          * data representation class name = <CODE>"java.io.InputStream"</CODE>
 985          * (byte stream).
 986          */
 987         public static final INPUT_STREAM PDF = new INPUT_STREAM ("application/pdf");
 988 
 989         /**
 990          * Doc flavor with MIME type = <CODE>"application/postscript"</CODE>,
 991          * print data representation class name =
 992          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 993          */
 994         public static final INPUT_STREAM POSTSCRIPT =
 995             new INPUT_STREAM ("application/postscript");
 996 
 997         /**
 998          * Doc flavor with MIME type = <CODE>"application/vnd.hp-PCL"</CODE>,
 999          * print data representation class name =
1000          * <CODE>"java.io.InputStream"</CODE> (byte stream).
1001          */
1002         public static final INPUT_STREAM PCL =
1003             new INPUT_STREAM ("application/vnd.hp-PCL");
1004 
1005         /**
1006          * Doc flavor with MIME type = <CODE>"image/gif"</CODE>, print data
1007          * representation class name =
1008          * <CODE>"java.io.InputStream"</CODE> (byte stream).
1009          */
1010         public static final INPUT_STREAM GIF = new INPUT_STREAM ("image/gif");
1011 
1012         /**
1013          * Doc flavor with MIME type = <CODE>"image/jpeg"</CODE>, print data
1014          * representation class name =
1015          * <CODE>"java.io.InputStream"</CODE> (byte stream).
1016          */
1017         public static final INPUT_STREAM JPEG = new INPUT_STREAM ("image/jpeg");
1018 
1019         /**
1020          * Doc flavor with MIME type = <CODE>"image/png"</CODE>, print data
1021          * representation class name =
1022          * <CODE>"java.io.InputStream"</CODE> (byte stream).
1023          */
1024         public static final INPUT_STREAM PNG = new INPUT_STREAM ("image/png");
1025 
1026         /**
1027          * Doc flavor with MIME type =
1028          * <CODE>"application/octet-stream"</CODE>,
1029          * print data representation class name =
1030          * <CODE>"java.io.InputStream"</CODE> (byte stream).
1031          * The client must determine that data described
1032          * using this DocFlavor is valid for the printer.
1033          */
1034         public static final INPUT_STREAM AUTOSENSE =
1035             new INPUT_STREAM ("application/octet-stream");
1036 
1037     }
1038 
1039     /**
1040      * Class DocFlavor.URL provides predefined static constant DocFlavor
1041      * objects.
1042      * For example doc flavors using a Uniform Resource Locator ({@link
1043      * java.net.URL java.net.URL}) as the print data
1044      * representation class.
1045      *
1046      * @author  Alan Kaminsky
1047      */
1048     public static class URL extends DocFlavor {
1049         private static final long serialVersionUID = 2936725788144902062L;
1050 
1051         /**
1052          * Constructs a new doc flavor with the given MIME type and a print
1053          * data representation class name of <CODE>"java.net.URL"</CODE>.
1054          *
1055          * @param  mimeType   MIME media type string.
1056          *
1057          * @exception  NullPointerException
1058          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
1059          * @exception  IllegalArgumentException
1060          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
1061          *     obey the syntax for a MIME media type string.
1062          */
1063         public URL (String mimeType) {
1064             super (mimeType, "java.net.URL");
1065         }
1066 
1067         /**
1068          * Doc flavor with MIME type = <CODE>"text/plain"</CODE>,
1069          * encoded in the host platform encoding.
1070          * See {@link DocFlavor#hostEncoding hostEncoding}
1071          * Print data representation class name =
1072          * <CODE>"java.net.URL"</CODE> (byte stream).
1073          */
1074         public static final URL TEXT_PLAIN_HOST =
1075             new URL ("text/plain; charset="+hostEncoding);
1076 
1077         /**
1078          * Doc flavor with MIME type =
1079          * <CODE>"text/plain; charset=utf-8"</CODE>,
1080          * print data representation class name =
1081          * <CODE>"java.net.URL"</CODE> (byte stream).
1082          */
1083         public static final URL TEXT_PLAIN_UTF_8 =
1084             new URL ("text/plain; charset=utf-8");
1085 
1086         /**
1087          * Doc flavor with MIME type =
1088          * <CODE>"text/plain; charset=utf-16"</CODE>,
1089          * print data representation class name =
1090          * <CODE>java.net.URL""</CODE> (byte stream).
1091          */
1092         public static final URL TEXT_PLAIN_UTF_16 =
1093             new URL ("text/plain; charset=utf-16");
1094 
1095         /**
1096          * Doc flavor with MIME type =
1097          * <CODE>"text/plain; charset=utf-16be"</CODE>
1098          * (big-endian byte ordering),
1099          * print data representation class name =
1100          * <CODE>"java.net.URL"</CODE> (byte stream).
1101          */
1102         public static final URL TEXT_PLAIN_UTF_16BE =
1103             new URL ("text/plain; charset=utf-16be");
1104 
1105         /**
1106          * Doc flavor with MIME type =
1107          * <CODE>"text/plain; charset=utf-16le"</CODE>
1108          * (little-endian byte ordering),
1109          * print data representation class name =
1110          * <CODE>"java.net.URL"</CODE> (byte stream).
1111          */
1112         public static final URL TEXT_PLAIN_UTF_16LE =
1113             new URL ("text/plain; charset=utf-16le");
1114 
1115         /**
1116          * Doc flavor with MIME type =
1117          * <CODE>"text/plain; charset=us-ascii"</CODE>,
1118          * print data representation class name =
1119          * <CODE>"java.net.URL"</CODE> (byte stream).
1120          */
1121         public static final URL TEXT_PLAIN_US_ASCII =
1122             new URL ("text/plain; charset=us-ascii");
1123 
1124         /**
1125          * Doc flavor with MIME type = <CODE>"text/html"</CODE>,
1126          * encoded in the host platform encoding.
1127          * See {@link DocFlavor#hostEncoding hostEncoding}
1128          * Print data representation class name =
1129          * <CODE>"java.net.URL"</CODE> (byte stream).
1130          */
1131         public static final URL TEXT_HTML_HOST =
1132             new URL ("text/html; charset="+hostEncoding);
1133 
1134         /**
1135          * Doc flavor with MIME type =
1136          * <CODE>"text/html; charset=utf-8"</CODE>,
1137          * print data representation class name =
1138          * <CODE>"java.net.URL"</CODE> (byte stream).
1139          */
1140         public static final URL TEXT_HTML_UTF_8 =
1141             new URL ("text/html; charset=utf-8");
1142 
1143         /**
1144          * Doc flavor with MIME type =
1145          * <CODE>"text/html; charset=utf-16"</CODE>,
1146          * print data representation class name =
1147          * <CODE>"java.net.URL"</CODE> (byte stream).
1148          */
1149         public static final URL TEXT_HTML_UTF_16 =
1150             new URL ("text/html; charset=utf-16");
1151 
1152         /**
1153          * Doc flavor with MIME type =
1154          * <CODE>"text/html; charset=utf-16be"</CODE>
1155          * (big-endian byte ordering),
1156          * print data representation class name =
1157          * <CODE>"java.net.URL"</CODE> (byte stream).
1158          */
1159         public static final URL TEXT_HTML_UTF_16BE =
1160             new URL ("text/html; charset=utf-16be");
1161 
1162         /**
1163          * Doc flavor with MIME type =
1164          * <CODE>"text/html; charset=utf-16le"</CODE>
1165          * (little-endian byte ordering),
1166          * print data representation class name =
1167          * <CODE>"java.net.URL"</CODE> (byte stream).
1168          */
1169         public static final URL TEXT_HTML_UTF_16LE =
1170             new URL ("text/html; charset=utf-16le");
1171 
1172         /**
1173          * Doc flavor with MIME type =
1174          * <CODE>"text/html; charset=us-ascii"</CODE>,
1175          * print data representation class name =
1176          * <CODE>"java.net.URL"</CODE> (byte stream).
1177          */
1178         public static final URL TEXT_HTML_US_ASCII =
1179             new URL ("text/html; charset=us-ascii");
1180 
1181 
1182         /**
1183          * Doc flavor with MIME type = <CODE>"application/pdf"</CODE>, print
1184          * data representation class name = <CODE>"java.net.URL"</CODE>.
1185          */
1186         public static final URL PDF = new URL ("application/pdf");
1187 
1188         /**
1189          * Doc flavor with MIME type = <CODE>"application/postscript"</CODE>,
1190          * print data representation class name = <CODE>"java.net.URL"</CODE>.
1191          */
1192         public static final URL POSTSCRIPT = new URL ("application/postscript");
1193 
1194         /**
1195          * Doc flavor with MIME type = <CODE>"application/vnd.hp-PCL"</CODE>,
1196          * print data representation class name = <CODE>"java.net.URL"</CODE>.
1197          */
1198         public static final URL PCL = new URL ("application/vnd.hp-PCL");
1199 
1200         /**
1201          * Doc flavor with MIME type = <CODE>"image/gif"</CODE>, print data
1202          * representation class name = <CODE>"java.net.URL"</CODE>.
1203          */
1204         public static final URL GIF = new URL ("image/gif");
1205 
1206         /**
1207          * Doc flavor with MIME type = <CODE>"image/jpeg"</CODE>, print data
1208          * representation class name = <CODE>"java.net.URL"</CODE>.
1209          */
1210         public static final URL JPEG = new URL ("image/jpeg");
1211 
1212         /**
1213          * Doc flavor with MIME type = <CODE>"image/png"</CODE>, print data
1214          * representation class name = <CODE>"java.net.URL"</CODE>.
1215          */
1216         public static final URL PNG = new URL ("image/png");
1217 
1218         /**
1219          * Doc flavor with MIME type =
1220          * <CODE>"application/octet-stream"</CODE>,
1221          * print data representation class name = <CODE>"java.net.URL"</CODE>.
1222          *  The client must determine that data described
1223          * using this DocFlavor is valid for the printer.
1224          */
1225         public static final URL AUTOSENSE = new URL ("application/octet-stream");
1226 
1227     }
1228 
1229     /**
1230      * Class DocFlavor.CHAR_ARRAY provides predefined static constant
1231      * DocFlavor objects for example doc flavors using a character array
1232      * (<CODE>char[]</CODE>) as the print data representation class. As such,
1233      * the character set is Unicode.
1234      *
1235      * @author  Alan Kaminsky
1236      */
1237     public static class CHAR_ARRAY extends DocFlavor {
1238 
1239         private static final long serialVersionUID = -8720590903724405128L;
1240 
1241         /**
1242          * Constructs a new doc flavor with the given MIME type and a print
1243          * data representation class name of
1244          * <CODE>"[C"</CODE> (character array).
1245          *
1246          * @param  mimeType  MIME media type string. If it is a text media
1247          *                      type, it is assumed to contain a
1248          *                      <CODE>"charset=utf-16"</CODE> parameter.
1249          *
1250          * @exception  NullPointerException
1251          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
1252          * @exception  IllegalArgumentException
1253          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
1254          *     obey the syntax for a MIME media type string.
1255          */
1256         public CHAR_ARRAY (String mimeType) {
1257             super (mimeType, "[C");
1258         }
1259 
1260         /**
1261          * Doc flavor with MIME type = <CODE>"text/plain;
1262          * charset=utf-16"</CODE>, print data representation class name =
1263          * <CODE>"[C"</CODE> (character array).
1264          */
1265         public static final CHAR_ARRAY TEXT_PLAIN =
1266             new CHAR_ARRAY ("text/plain; charset=utf-16");
1267 
1268         /**
1269          * Doc flavor with MIME type = <CODE>"text/html;
1270          * charset=utf-16"</CODE>, print data representation class name =
1271          * <CODE>"[C"</CODE> (character array).
1272          */
1273         public static final CHAR_ARRAY TEXT_HTML =
1274             new CHAR_ARRAY ("text/html; charset=utf-16");
1275 
1276     }
1277 
1278     /**
1279      * Class DocFlavor.STRING provides predefined static constant DocFlavor
1280      * objects for example doc flavors using a string ({@link java.lang.String
1281      * java.lang.String}) as the print data representation class.
1282      * As such, the character set is Unicode.
1283      *
1284      * @author  Alan Kaminsky
1285      */
1286     public static class STRING extends DocFlavor {
1287 
1288         private static final long serialVersionUID = 4414407504887034035L;
1289 
1290         /**
1291          * Constructs a new doc flavor with the given MIME type and a print
1292          * data representation class name of <CODE>"java.lang.String"</CODE>.
1293          *
1294          * @param  mimeType  MIME media type string. If it is a text media
1295          *                      type, it is assumed to contain a
1296          *                      <CODE>"charset=utf-16"</CODE> parameter.
1297          *
1298          * @exception  NullPointerException
1299          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
1300          * @exception  IllegalArgumentException
1301          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
1302          *     obey the syntax for a MIME media type string.
1303          */
1304         public STRING (String mimeType) {
1305             super (mimeType, "java.lang.String");
1306         }
1307 
1308         /**
1309          * Doc flavor with MIME type = <CODE>"text/plain;
1310          * charset=utf-16"</CODE>, print data representation class name =
1311          * <CODE>"java.lang.String"</CODE>.
1312          */
1313         public static final STRING TEXT_PLAIN =
1314             new STRING ("text/plain; charset=utf-16");
1315 
1316         /**
1317          * Doc flavor with MIME type = <CODE>"text/html;
1318          * charset=utf-16"</CODE>, print data representation class name =
1319          * <CODE>"java.lang.String"</CODE>.
1320          */
1321         public static final STRING TEXT_HTML =
1322             new STRING ("text/html; charset=utf-16");
1323     }
1324 
1325     /**
1326      * Class DocFlavor.READER provides predefined static constant DocFlavor
1327      * objects for example doc flavors using a character stream ({@link
1328      * java.io.Reader java.io.Reader}) as the print data
1329      * representation class. As such, the character set is Unicode.
1330      *
1331      * @author  Alan Kaminsky
1332      */
1333     public static class READER extends DocFlavor {
1334 
1335         private static final long serialVersionUID = 7100295812579351567L;
1336 
1337         /**
1338          * Constructs a new doc flavor with the given MIME type and a print
1339          * data representation class name of\
1340          * <CODE>"java.io.Reader"</CODE> (character stream).
1341          *
1342          * @param  mimeType  MIME media type string. If it is a text media
1343          *                      type, it is assumed to contain a
1344          *                      <CODE>"charset=utf-16"</CODE> parameter.
1345          *
1346          * @exception  NullPointerException
1347          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
1348          * @exception  IllegalArgumentException
1349          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
1350          *     obey the syntax for a MIME media type string.
1351          */
1352         public READER (String mimeType) {
1353             super (mimeType, "java.io.Reader");
1354         }
1355 
1356         /**
1357          * Doc flavor with MIME type = <CODE>"text/plain;
1358          * charset=utf-16"</CODE>, print data representation class name =
1359          * <CODE>"java.io.Reader"</CODE> (character stream).
1360          */
1361         public static final READER TEXT_PLAIN =
1362             new READER ("text/plain; charset=utf-16");
1363 
1364         /**
1365          * Doc flavor with MIME type = <CODE>"text/html;
1366          * charset=utf-16"</CODE>, print data representation class name =
1367          * <CODE>"java.io.Reader"</CODE> (character stream).
1368          */
1369         public static final READER TEXT_HTML =
1370             new READER ("text/html; charset=utf-16");
1371 
1372     }
1373 
1374     /**
1375      * Class DocFlavor.SERVICE_FORMATTED provides predefined static constant
1376      * DocFlavor objects for example doc flavors for service formatted print
1377      * data.
1378      *
1379      * @author  Alan Kaminsky
1380      */
1381     public static class SERVICE_FORMATTED extends DocFlavor {
1382 
1383         private static final long serialVersionUID = 6181337766266637256L;
1384 
1385         /**
1386          * Constructs a new doc flavor with a MIME type of
1387          * <CODE>"application/x-java-jvm-local-objectref"</CODE> indicating
1388          * service formatted print data and the given print data
1389          * representation class name.
1390          *
1391          * @param  className  Fully-qualified representation class name.
1392          *
1393          * @exception  NullPointerException
1394          *     (unchecked exception) Thrown if <CODE>className</CODE> is
1395          *     null.
1396          */
1397         public SERVICE_FORMATTED (String className) {
1398             super ("application/x-java-jvm-local-objectref", className);
1399         }
1400 
1401         /**
1402          * Service formatted print data doc flavor with print data
1403          * representation class name =
1404          * <CODE>"java.awt.image.renderable.RenderableImage"</CODE>
1405          * (renderable image object).
1406          */
1407         public static final SERVICE_FORMATTED RENDERABLE_IMAGE =
1408             new SERVICE_FORMATTED("java.awt.image.renderable.RenderableImage");
1409 
1410         /**
1411          * Service formatted print data doc flavor with print data
1412          * representation class name = <CODE>"java.awt.print.Printable"</CODE>
1413          * (printable object).
1414          */
1415         public static final SERVICE_FORMATTED PRINTABLE =
1416             new SERVICE_FORMATTED ("java.awt.print.Printable");
1417 
1418         /**
1419          * Service formatted print data doc flavor with print data
1420          * representation class name = <CODE>"java.awt.print.Pageable"</CODE>
1421          * (pageable object).
1422          */
1423         public static final SERVICE_FORMATTED PAGEABLE =
1424             new SERVICE_FORMATTED ("java.awt.print.Pageable");
1425 
1426         }
1427 
1428 }
--- EOF ---