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>·&nbsp;&nbsp;
 349  * <CODE>("text/plain", "java.io.InputStream")</CODE>
 350  * <BR>·&nbsp;&nbsp;
 351  * <CODE>("text/plain; charset=us-ascii", "java.io.InputStream")</CODE>
 352  * <BR>·&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>·&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  * <LI>
 385  * </UL>
 386  * <P>
 387  * The client must itself perform all plain text print data formatting not
 388  * addressed by the above requirements.
 389  *
 390  * <H3>Design Rationale</H3>
 391  * <P>
 392  * Class DocFlavor in package javax.print.data is similar to class
 393  * {@link java.awt.datatransfer.DataFlavor DataFlavor}. Class
 394  * <code>DataFlavor</code>
 395  * is not used in the Java Print Service (JPS) API
 396  * for three reasons which are all rooted in allowing the JPS API to be
 397  * shared by other print services APIs which may need to run on Java profiles
 398  * which do not include all of the Java Platform, Standard Edition.
 399  * <OL TYPE=1>
 400  * <LI>
 401  * The JPS API is designed to be used in Java profiles which do not support
 402  * AWT.
 403  *
 404  * <LI>
 405  * The implementation of class <code>java.awt.datatransfer.DataFlavor</code>
 406  * does not guarantee that equivalent data flavors will have the same
 407  * serialized representation. DocFlavor does, and can be used in services
 408  * which need this.
 409  *
 410  * <LI>
 411  * The implementation of class <code>java.awt.datatransfer.DataFlavor</code>
 412  * includes a human presentable name as part of the serialized representation.
 413  * This is not appropriate as part of a service matching constraint.
 414  * </OL>
 415  * <P>
 416  * Class DocFlavor's serialized representation uses the following
 417  * canonical form of a MIME type string. Thus, two doc flavors with MIME types
 418  * that are not identical but that are equivalent (that have the same
 419  * canonical form) may be considered equal.
 420  * <UL>
 421  * <LI> The media type, media subtype, and parameters are retained, but all
 422  *      comments and whitespace characters are discarded.
 423  * <LI> The media type, media subtype, and parameter names are converted to
 424  *      lowercase.
 425  * <LI> The parameter values retain their original case, except a charset
 426  *      parameter value for a text media type is converted to lowercase.
 427  * <LI> Quote characters surrounding parameter values are removed.
 428  * <LI> Quoting backslash characters inside parameter values are removed.
 429  * <LI> The parameters are arranged in ascending order of parameter name.
 430  * </UL>
 431  * <P>
 432  * Class DocFlavor's serialized representation also contains the
 433  * fully-qualified class <I>name</I> of the representation class
 434  * (a String object), rather than the representation class itself
 435  * (a Class object). This allows a client to examine the doc flavors a
 436  * Java Print Service instance supports without having
 437  * to load the representation classes, which may be problematic for
 438  * limited-resource clients.
 439  * <P>
 440  *
 441  * @author  Alan Kaminsky
 442  */
 443 public class DocFlavor implements Serializable, Cloneable {
 444 
 445     private static final long serialVersionUID = -4512080796965449721L;
 446 
 447     /**
 448      * A String representing the host operating system encoding.
 449      * This will follow the conventions documented in
 450      * <a href="http://www.ietf.org/rfc/rfc2278.txt">
 451      * <i>RFC&nbsp;2278:&nbsp;IANA Charset Registration Procedures</i></a>
 452      * except where historical names are returned for compatibility with
 453      * previous versions of the Java platform.
 454      * The value returned from method is valid only for the VM which
 455      * returns it, for use in a DocFlavor.
 456      * This is the charset for all the "HOST" pre-defined DocFlavors in
 457      * the executing VM.
 458      */
 459     public static final String hostEncoding;
 460 
 461     static {
 462         hostEncoding =
 463             java.security.AccessController.doPrivileged(
 464                   new sun.security.action.GetPropertyAction("file.encoding"));
 465     }
 466 
 467     /**
 468      * MIME type.
 469      */
 470     private transient MimeType myMimeType;
 471 
 472     /**
 473      * Representation class name.
 474      * @serial
 475      */
 476     private String myClassName;
 477 
 478     /**
 479      * String value for this doc flavor. Computed when needed and cached.
 480      */
 481     private transient String myStringValue = null;
 482 
 483 
 484     /**
 485      * Constructs a new doc flavor object from the given MIME type and
 486      * representation class name. The given MIME type is converted into
 487      * canonical form and stored internally.
 488      *
 489      * @param  mimeType   MIME media type string.
 490      * @param  className  Fully-qualified representation class name.
 491      *
 492      * @exception  NullPointerException
 493      *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null or
 494      *     <CODE>className</CODE> is null.
 495      * @exception  IllegalArgumentException
 496      *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
 497      *     obey the syntax for a MIME media type string.
 498      */
 499     public DocFlavor(String mimeType, String className) {
 500         if (className == null) {
 501             throw new NullPointerException();
 502         }
 503         myMimeType = new MimeType (mimeType);
 504         myClassName = className;
 505     }
 506 
 507     /**
 508      * Returns this doc flavor object's MIME type string based on the
 509      * canonical form. Each parameter value is enclosed in quotes.
 510      * @return the mime type
 511      */
 512     public String getMimeType() {
 513         return myMimeType.getMimeType();
 514     }
 515 
 516     /**
 517      * Returns this doc flavor object's media type (from the MIME type).
 518      * @return the media type
 519      */
 520     public String getMediaType() {
 521         return myMimeType.getMediaType();
 522     }
 523 
 524     /**
 525      * Returns this doc flavor object's media subtype (from the MIME type).
 526      * @return the media sub-type
 527      */
 528     public String getMediaSubtype() {
 529         return myMimeType.getMediaSubtype();
 530     }
 531 
 532     /**
 533      * Returns a <code>String</code> representing a MIME
 534      * parameter.
 535      * Mime types may include parameters which are usually optional.
 536      * The charset for text types is a commonly useful example.
 537      * This convenience method will return the value of the specified
 538      * parameter if one was specified in the mime type for this flavor.
 539      * <p>
 540      * @param paramName the name of the paramater. This name is internally
 541      * converted to the canonical lower case format before performing
 542      * the match.
 543      * @return String representing a mime parameter, or
 544      * null if that parameter is not in the mime type string.
 545      * @exception NullPointerException if paramName is null.
 546      */
 547     public String getParameter(String paramName) {
 548         return
 549             (String)myMimeType.getParameterMap().get(paramName.toLowerCase());
 550     }
 551 
 552     /**
 553      * Returns the name of this doc flavor object's representation class.
 554      * @return the name of the representation class.
 555      */
 556     public String getRepresentationClassName() {
 557         return myClassName;
 558     }
 559 
 560     /**
 561      * Converts this <code>DocFlavor</code> to a string.
 562      *
 563      * @return  MIME type string based on the canonical form. Each parameter
 564      *          value is enclosed in quotes.
 565      *          A "class=" parameter is appended to the
 566      *          MIME type string to indicate the representation class name.
 567      */
 568     public String toString() {
 569         return getStringValue();
 570     }
 571 
 572     /**
 573      * Returns a hash code for this doc flavor object.
 574      */
 575     public int hashCode() {
 576         return getStringValue().hashCode();
 577     }
 578 
 579     /**
 580      * Determines if this doc flavor object is equal to the given object.
 581      * The two are equal if the given object is not null, is an instance
 582      * of <code>DocFlavor</code>, has a MIME type equivalent to this doc
 583      * flavor object's MIME type (that is, the MIME types have the same media
 584      * type, media subtype, and parameters), and has the same representation
 585      * class name as this doc flavor object. Thus, if two doc flavor objects'
 586      * MIME types are the same except for comments, they are considered equal.
 587      * However, two doc flavor objects with MIME types of "text/plain" and
 588      * "text/plain; charset=US-ASCII" are not considered equal, even though
 589      * they represent the same media type (because the default character
 590      * set for plain text is US-ASCII).
 591      *
 592      * @param  obj  Object to test.
 593      *
 594      * @return  True if this doc flavor object equals <CODE>obj</CODE>, false
 595      *          otherwise.
 596      */
 597     public boolean equals(Object obj) {
 598         return
 599             obj != null &&
 600             obj instanceof DocFlavor &&
 601             getStringValue().equals (((DocFlavor) obj).getStringValue());
 602     }
 603 
 604     /**
 605      * Returns this doc flavor object's string value.
 606      */
 607     private String getStringValue() {
 608         if (myStringValue == null) {
 609             myStringValue = myMimeType + "; class=\"" + myClassName + "\"";
 610         }
 611         return myStringValue;
 612     }
 613 
 614     /**
 615      * Write the instance to a stream (ie serialize the object).
 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      * @serialData
 627      * The serialised form of a DocFlavor is the String naming the
 628      * representation class followed by the String representing the canonical
 629      * form of the mime type.
 630      */
 631     private void readObject(ObjectInputStream s)
 632         throws ClassNotFoundException, IOException {
 633 
 634         s.defaultReadObject();
 635         myMimeType = new MimeType((String)s.readObject());
 636     }
 637 
 638     /**
 639      * Class DocFlavor.BYTE_ARRAY provides predefined static constant
 640      * DocFlavor objects for example doc flavors using a byte array
 641      * (<CODE>byte[]</CODE>) as the print data representation class.
 642      * <P>
 643      *
 644      * @author  Alan Kaminsky
 645      */
 646     public static class BYTE_ARRAY extends DocFlavor {
 647 
 648         private static final long serialVersionUID = -9065578006593857475L;
 649 
 650         /**
 651          * Constructs a new doc flavor with the given MIME type and a print
 652          * data representation class name of <CODE>"[B"</CODE> (byte array).
 653          *
 654          * @param  mimeType   MIME media type string.
 655          *
 656          * @exception  NullPointerException
 657          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
 658          * @exception  IllegalArgumentException
 659          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
 660          *     obey the syntax for a MIME media type string.
 661          */
 662         public BYTE_ARRAY (String mimeType) {
 663             super (mimeType, "[B");
 664         }
 665 
 666         /**
 667          * Doc flavor with MIME type = <CODE>"text/plain"</CODE>,
 668          * encoded in the host platform encoding.
 669          * See {@link DocFlavor#hostEncoding hostEncoding}
 670          * Print data representation class name =
 671          * <CODE>"[B"</CODE> (byte array).
 672          */
 673         public static final BYTE_ARRAY TEXT_PLAIN_HOST =
 674             new BYTE_ARRAY ("text/plain; charset="+hostEncoding);
 675 
 676         /**
 677          * Doc flavor with MIME type =
 678          * <CODE>"text/plain; charset=utf-8"</CODE>,
 679          * print data representation class name = <CODE>"[B"</CODE> (byte
 680          * array).
 681          */
 682         public static final BYTE_ARRAY TEXT_PLAIN_UTF_8 =
 683             new BYTE_ARRAY ("text/plain; charset=utf-8");
 684 
 685         /**
 686          * Doc flavor with MIME type =
 687          * <CODE>"text/plain; charset=utf-16"</CODE>,
 688          * print data representation class name = <CODE>"[B"</CODE> (byte
 689          * array).
 690          */
 691         public static final BYTE_ARRAY TEXT_PLAIN_UTF_16 =
 692             new BYTE_ARRAY ("text/plain; charset=utf-16");
 693 
 694 
 695         /**
 696          * Doc flavor with MIME type =
 697          * <CODE>"text/plain; charset=utf-16be"</CODE>
 698          * (big-endian byte ordering),
 699          * print data representation class name = <CODE>"[B"</CODE> (byte
 700          * array).
 701          */
 702         public static final BYTE_ARRAY TEXT_PLAIN_UTF_16BE =
 703             new BYTE_ARRAY ("text/plain; charset=utf-16be");
 704 
 705         /**
 706          * Doc flavor with MIME type =
 707          * <CODE>"text/plain; charset=utf-16le"</CODE>
 708          * (little-endian byte ordering),
 709          * print data representation class name = <CODE>"[B"</CODE> (byte
 710          * array).
 711          */
 712         public static final BYTE_ARRAY TEXT_PLAIN_UTF_16LE =
 713             new BYTE_ARRAY ("text/plain; charset=utf-16le");
 714 
 715         /**
 716          * Doc flavor with MIME type =
 717          * <CODE>"text/plain; charset=us-ascii"</CODE>,
 718          * print data representation class name =
 719          * <CODE>"[B"</CODE> (byte array).
 720          */
 721         public static final BYTE_ARRAY TEXT_PLAIN_US_ASCII =
 722             new BYTE_ARRAY ("text/plain; charset=us-ascii");
 723 
 724 
 725         /**
 726          * Doc flavor with MIME type = <CODE>"text/html"</CODE>,
 727          * encoded in the host platform encoding.
 728          * See {@link DocFlavor#hostEncoding hostEncoding}
 729          * Print data representation class name =
 730          * <CODE>"[B"</CODE> (byte array).
 731          */
 732         public static final BYTE_ARRAY TEXT_HTML_HOST =
 733             new BYTE_ARRAY ("text/html; charset="+hostEncoding);
 734 
 735         /**
 736          * Doc flavor with MIME type =
 737          * <CODE>"text/html; charset=utf-8"</CODE>,
 738          * print data representation class name = <CODE>"[B"</CODE> (byte
 739          * array).
 740          */
 741         public static final BYTE_ARRAY TEXT_HTML_UTF_8 =
 742             new BYTE_ARRAY ("text/html; charset=utf-8");
 743 
 744         /**
 745          * Doc flavor with MIME type =
 746          * <CODE>"text/html; charset=utf-16"</CODE>,
 747          * print data representation class name = <CODE>"[B"</CODE> (byte
 748          * array).
 749          */
 750         public static final BYTE_ARRAY TEXT_HTML_UTF_16 =
 751             new BYTE_ARRAY ("text/html; charset=utf-16");
 752 
 753         /**
 754          * Doc flavor with MIME type =
 755          * <CODE>"text/html; charset=utf-16be"</CODE>
 756          * (big-endian byte ordering),
 757          * print data representation class name = <CODE>"[B"</CODE> (byte
 758          * array).
 759          */
 760         public static final BYTE_ARRAY TEXT_HTML_UTF_16BE =
 761             new BYTE_ARRAY ("text/html; charset=utf-16be");
 762 
 763         /**
 764          * Doc flavor with MIME type =
 765          * <CODE>"text/html; charset=utf-16le"</CODE>
 766          * (little-endian byte ordering),
 767          * print data representation class name = <CODE>"[B"</CODE> (byte
 768          * array).
 769          */
 770         public static final BYTE_ARRAY TEXT_HTML_UTF_16LE =
 771             new BYTE_ARRAY ("text/html; charset=utf-16le");
 772 
 773         /**
 774          * Doc flavor with MIME type =
 775          * <CODE>"text/html; charset=us-ascii"</CODE>,
 776          * print data representation class name =
 777          * <CODE>"[B"</CODE> (byte array).
 778          */
 779         public static final BYTE_ARRAY TEXT_HTML_US_ASCII =
 780             new BYTE_ARRAY ("text/html; charset=us-ascii");
 781 
 782 
 783         /**
 784          * Doc flavor with MIME type = <CODE>"application/pdf"</CODE>, print
 785          * data representation class name = <CODE>"[B"</CODE> (byte array).
 786          */
 787         public static final BYTE_ARRAY PDF = new BYTE_ARRAY ("application/pdf");
 788 
 789         /**
 790          * Doc flavor with MIME type = <CODE>"application/postscript"</CODE>,
 791          * print data representation class name = <CODE>"[B"</CODE> (byte
 792          * array).
 793          */
 794         public static final BYTE_ARRAY POSTSCRIPT =
 795             new BYTE_ARRAY ("application/postscript");
 796 
 797         /**
 798          * Doc flavor with MIME type = <CODE>"application/vnd.hp-PCL"</CODE>,
 799          * print data representation class name = <CODE>"[B"</CODE> (byte
 800          * array).
 801          */
 802         public static final BYTE_ARRAY PCL =
 803             new BYTE_ARRAY ("application/vnd.hp-PCL");
 804 
 805         /**
 806          * Doc flavor with MIME type = <CODE>"image/gif"</CODE>, print data
 807          * representation class name = <CODE>"[B"</CODE> (byte array).
 808          */
 809         public static final BYTE_ARRAY GIF = new BYTE_ARRAY ("image/gif");
 810 
 811         /**
 812          * Doc flavor with MIME type = <CODE>"image/jpeg"</CODE>, print data
 813          * representation class name = <CODE>"[B"</CODE> (byte array).
 814          */
 815         public static final BYTE_ARRAY JPEG = new BYTE_ARRAY ("image/jpeg");
 816 
 817         /**
 818          * Doc flavor with MIME type = <CODE>"image/png"</CODE>, print data
 819          * representation class name = <CODE>"[B"</CODE> (byte array).
 820          */
 821         public static final BYTE_ARRAY PNG = new BYTE_ARRAY ("image/png");
 822 
 823         /**
 824          * Doc flavor with MIME type =
 825          * <CODE>"application/octet-stream"</CODE>,
 826          * print data representation class name = <CODE>"[B"</CODE> (byte
 827          * array). The client must determine that data described
 828          * using this DocFlavor is valid for the printer.
 829          */
 830         public static final BYTE_ARRAY AUTOSENSE =
 831             new BYTE_ARRAY ("application/octet-stream");
 832 
 833     }
 834 
 835     /**
 836      * Class DocFlavor.INPUT_STREAM provides predefined static constant
 837      * DocFlavor objects for example doc flavors using a byte stream ({@link
 838      * java.io.InputStream java.io.InputStream}) as the print
 839      * data representation class.
 840      * <P>
 841      *
 842      * @author  Alan Kaminsky
 843      */
 844     public static class INPUT_STREAM extends DocFlavor {
 845 
 846         private static final long serialVersionUID = -7045842700749194127L;
 847 
 848         /**
 849          * Constructs a new doc flavor with the given MIME type and a print
 850          * data representation class name of
 851          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 852          *
 853          * @param  mimeType   MIME media type string.
 854          *
 855          * @exception  NullPointerException
 856          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
 857          * @exception  IllegalArgumentException
 858          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
 859          *     obey the syntax for a MIME media type string.
 860          */
 861         public INPUT_STREAM (String mimeType) {
 862             super (mimeType, "java.io.InputStream");
 863         }
 864 
 865         /**
 866          * Doc flavor with MIME type = <CODE>"text/plain"</CODE>,
 867          * encoded in the host platform encoding.
 868          * See {@link DocFlavor#hostEncoding hostEncoding}
 869          * Print data representation class name =
 870          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 871          */
 872         public static final INPUT_STREAM TEXT_PLAIN_HOST =
 873             new INPUT_STREAM ("text/plain; charset="+hostEncoding);
 874 
 875         /**
 876          * Doc flavor with MIME type =
 877          * <CODE>"text/plain; charset=utf-8"</CODE>,
 878          * print data representation class name =
 879          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 880          */
 881         public static final INPUT_STREAM TEXT_PLAIN_UTF_8 =
 882             new INPUT_STREAM ("text/plain; charset=utf-8");
 883 
 884         /**
 885          * Doc flavor with MIME type =
 886          * <CODE>"text/plain; charset=utf-16"</CODE>,
 887          * print data representation class name =
 888          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 889          */
 890         public static final INPUT_STREAM TEXT_PLAIN_UTF_16 =
 891             new INPUT_STREAM ("text/plain; charset=utf-16");
 892 
 893         /**
 894          * Doc flavor with MIME type =
 895          * <CODE>"text/plain; charset=utf-16be"</CODE>
 896          * (big-endian byte ordering),
 897          * print data representation class name =
 898          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 899          */
 900         public static final INPUT_STREAM TEXT_PLAIN_UTF_16BE =
 901             new INPUT_STREAM ("text/plain; charset=utf-16be");
 902 
 903         /**
 904          * Doc flavor with MIME type =
 905          * <CODE>"text/plain; charset=utf-16le"</CODE>
 906          * (little-endian byte ordering),
 907          * print data representation class name =
 908          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 909          */
 910         public static final INPUT_STREAM TEXT_PLAIN_UTF_16LE =
 911             new INPUT_STREAM ("text/plain; charset=utf-16le");
 912 
 913         /**
 914          * Doc flavor with MIME type =
 915          * <CODE>"text/plain; charset=us-ascii"</CODE>,
 916          * print data representation class name =
 917          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 918          */
 919         public static final INPUT_STREAM TEXT_PLAIN_US_ASCII =
 920                 new INPUT_STREAM ("text/plain; charset=us-ascii");
 921 
 922         /**
 923          * Doc flavor with MIME type = <CODE>"text/html"</CODE>,
 924          * encoded in the host platform encoding.
 925          * See {@link DocFlavor#hostEncoding hostEncoding}
 926          * Print data representation class name =
 927          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 928          */
 929         public static final INPUT_STREAM TEXT_HTML_HOST =
 930             new INPUT_STREAM ("text/html; charset="+hostEncoding);
 931 
 932         /**
 933          * Doc flavor with MIME type =
 934          * <CODE>"text/html; charset=utf-8"</CODE>,
 935          * print data representation class name =
 936          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 937          */
 938         public static final INPUT_STREAM TEXT_HTML_UTF_8 =
 939             new INPUT_STREAM ("text/html; charset=utf-8");
 940 
 941         /**
 942          * Doc flavor with MIME type =
 943          * <CODE>"text/html; charset=utf-16"</CODE>,
 944          * print data representation class name =
 945          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 946          */
 947         public static final INPUT_STREAM TEXT_HTML_UTF_16 =
 948             new INPUT_STREAM ("text/html; charset=utf-16");
 949 
 950         /**
 951          * Doc flavor with MIME type =
 952          * <CODE>"text/html; charset=utf-16be"</CODE>
 953          * (big-endian byte ordering),
 954          * print data representation class name =
 955          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 956          */
 957         public static final INPUT_STREAM TEXT_HTML_UTF_16BE =
 958             new INPUT_STREAM ("text/html; charset=utf-16be");
 959 
 960         /**
 961          * Doc flavor with MIME type =
 962          * <CODE>"text/html; charset=utf-16le"</CODE>
 963          * (little-endian byte ordering),
 964          * print data representation class name =
 965          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 966          */
 967         public static final INPUT_STREAM TEXT_HTML_UTF_16LE =
 968             new INPUT_STREAM ("text/html; charset=utf-16le");
 969 
 970         /**
 971          * Doc flavor with MIME type =
 972          * <CODE>"text/html; charset=us-ascii"</CODE>,
 973          * print data representation class name =
 974          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 975          */
 976         public static final INPUT_STREAM TEXT_HTML_US_ASCII =
 977             new INPUT_STREAM ("text/html; charset=us-ascii");
 978 
 979 
 980         /**
 981          * Doc flavor with MIME type = <CODE>"application/pdf"</CODE>, print
 982          * data representation class name = <CODE>"java.io.InputStream"</CODE>
 983          * (byte stream).
 984          */
 985         public static final INPUT_STREAM PDF = new INPUT_STREAM ("application/pdf");
 986 
 987         /**
 988          * Doc flavor with MIME type = <CODE>"application/postscript"</CODE>,
 989          * print data representation class name =
 990          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 991          */
 992         public static final INPUT_STREAM POSTSCRIPT =
 993             new INPUT_STREAM ("application/postscript");
 994 
 995         /**
 996          * Doc flavor with MIME type = <CODE>"application/vnd.hp-PCL"</CODE>,
 997          * print data representation class name =
 998          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 999          */
1000         public static final INPUT_STREAM PCL =
1001             new INPUT_STREAM ("application/vnd.hp-PCL");
1002 
1003         /**
1004          * Doc flavor with MIME type = <CODE>"image/gif"</CODE>, print data
1005          * representation class name =
1006          * <CODE>"java.io.InputStream"</CODE> (byte stream).
1007          */
1008         public static final INPUT_STREAM GIF = new INPUT_STREAM ("image/gif");
1009 
1010         /**
1011          * Doc flavor with MIME type = <CODE>"image/jpeg"</CODE>, print data
1012          * representation class name =
1013          * <CODE>"java.io.InputStream"</CODE> (byte stream).
1014          */
1015         public static final INPUT_STREAM JPEG = new INPUT_STREAM ("image/jpeg");
1016 
1017         /**
1018          * Doc flavor with MIME type = <CODE>"image/png"</CODE>, print data
1019          * representation class name =
1020          * <CODE>"java.io.InputStream"</CODE> (byte stream).
1021          */
1022         public static final INPUT_STREAM PNG = new INPUT_STREAM ("image/png");
1023 
1024         /**
1025          * Doc flavor with MIME type =
1026          * <CODE>"application/octet-stream"</CODE>,
1027          * print data representation class name =
1028          * <CODE>"java.io.InputStream"</CODE> (byte stream).
1029          * The client must determine that data described
1030          * using this DocFlavor is valid for the printer.
1031          */
1032         public static final INPUT_STREAM AUTOSENSE =
1033             new INPUT_STREAM ("application/octet-stream");
1034 
1035     }
1036 
1037     /**
1038      * Class DocFlavor.URL provides predefined static constant DocFlavor
1039      * objects.
1040      * For example doc flavors using a Uniform Resource Locator ({@link
1041      * java.net.URL java.net.URL}) as the print data
1042      * representation  class.
1043      * <P>
1044      *
1045      * @author  Alan Kaminsky
1046      */
1047     public static class URL extends DocFlavor {
1048         private static final long serialVersionUID = 2936725788144902062L;
1049 
1050         /**
1051          * Constructs a new doc flavor with the given MIME type and a print
1052          * data representation class name of <CODE>"java.net.URL"</CODE>.
1053          *
1054          * @param  mimeType   MIME media type string.
1055          *
1056          * @exception  NullPointerException
1057          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
1058          * @exception  IllegalArgumentException
1059          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
1060          *     obey the syntax for a MIME media type string.
1061          */
1062         public URL (String mimeType) {
1063             super (mimeType, "java.net.URL");
1064         }
1065 
1066         /**
1067          * Doc flavor with MIME type = <CODE>"text/plain"</CODE>,
1068          * encoded in the host platform encoding.
1069          * See {@link DocFlavor#hostEncoding hostEncoding}
1070          * Print data representation class name =
1071          * <CODE>"java.net.URL"</CODE> (byte stream).
1072          */
1073         public static final URL TEXT_PLAIN_HOST =
1074             new URL ("text/plain; charset="+hostEncoding);
1075 
1076         /**
1077          * Doc flavor with MIME type =
1078          * <CODE>"text/plain; charset=utf-8"</CODE>,
1079          * print data representation class name =
1080          * <CODE>"java.net.URL"</CODE> (byte stream).
1081          */
1082         public static final URL TEXT_PLAIN_UTF_8 =
1083             new URL ("text/plain; charset=utf-8");
1084 
1085         /**
1086          * Doc flavor with MIME type =
1087          * <CODE>"text/plain; charset=utf-16"</CODE>,
1088          * print data representation class name =
1089          * <CODE>java.net.URL""</CODE> (byte stream).
1090          */
1091         public static final URL TEXT_PLAIN_UTF_16 =
1092             new URL ("text/plain; charset=utf-16");
1093 
1094         /**
1095          * Doc flavor with MIME type =
1096          * <CODE>"text/plain; charset=utf-16be"</CODE>
1097          * (big-endian byte ordering),
1098          * print data representation class name =
1099          * <CODE>"java.net.URL"</CODE> (byte stream).
1100          */
1101         public static final URL TEXT_PLAIN_UTF_16BE =
1102             new URL ("text/plain; charset=utf-16be");
1103 
1104         /**
1105          * Doc flavor with MIME type =
1106          * <CODE>"text/plain; charset=utf-16le"</CODE>
1107          * (little-endian byte ordering),
1108          * print data representation class name =
1109          * <CODE>"java.net.URL"</CODE> (byte stream).
1110          */
1111         public static final URL TEXT_PLAIN_UTF_16LE =
1112             new URL ("text/plain; charset=utf-16le");
1113 
1114         /**
1115          * Doc flavor with MIME type =
1116          * <CODE>"text/plain; charset=us-ascii"</CODE>,
1117          * print data representation class name =
1118          * <CODE>"java.net.URL"</CODE> (byte stream).
1119          */
1120         public static final URL TEXT_PLAIN_US_ASCII =
1121             new URL ("text/plain; charset=us-ascii");
1122 
1123         /**
1124          * Doc flavor with MIME type = <CODE>"text/html"</CODE>,
1125          * encoded in the host platform encoding.
1126          * See {@link DocFlavor#hostEncoding hostEncoding}
1127          * Print data representation class name =
1128          * <CODE>"java.net.URL"</CODE> (byte stream).
1129          */
1130         public static final URL TEXT_HTML_HOST =
1131             new URL ("text/html; charset="+hostEncoding);
1132 
1133         /**
1134          * Doc flavor with MIME type =
1135          * <CODE>"text/html; charset=utf-8"</CODE>,
1136          * print data representation class name =
1137          * <CODE>"java.net.URL"</CODE> (byte stream).
1138          */
1139         public static final URL TEXT_HTML_UTF_8 =
1140             new URL ("text/html; charset=utf-8");
1141 
1142         /**
1143          * Doc flavor with MIME type =
1144          * <CODE>"text/html; charset=utf-16"</CODE>,
1145          * print data representation class name =
1146          * <CODE>"java.net.URL"</CODE> (byte stream).
1147          */
1148         public static final URL TEXT_HTML_UTF_16 =
1149             new URL ("text/html; charset=utf-16");
1150 
1151         /**
1152          * Doc flavor with MIME type =
1153          * <CODE>"text/html; charset=utf-16be"</CODE>
1154          * (big-endian byte ordering),
1155          * print data representation class name =
1156          * <CODE>"java.net.URL"</CODE> (byte stream).
1157          */
1158         public static final URL TEXT_HTML_UTF_16BE =
1159             new URL ("text/html; charset=utf-16be");
1160 
1161         /**
1162          * Doc flavor with MIME type =
1163          * <CODE>"text/html; charset=utf-16le"</CODE>
1164          * (little-endian byte ordering),
1165          * print data representation class name =
1166          * <CODE>"java.net.URL"</CODE> (byte stream).
1167          */
1168         public static final URL TEXT_HTML_UTF_16LE =
1169             new URL ("text/html; charset=utf-16le");
1170 
1171         /**
1172          * Doc flavor with MIME type =
1173          * <CODE>"text/html; charset=us-ascii"</CODE>,
1174          * print data representation class name =
1175          * <CODE>"java.net.URL"</CODE> (byte stream).
1176          */
1177         public static final URL TEXT_HTML_US_ASCII =
1178             new URL ("text/html; charset=us-ascii");
1179 
1180 
1181         /**
1182          * Doc flavor with MIME type = <CODE>"application/pdf"</CODE>, print
1183          * data representation class name = <CODE>"java.net.URL"</CODE>.
1184          */
1185         public static final URL PDF = new URL ("application/pdf");
1186 
1187         /**
1188          * Doc flavor with MIME type = <CODE>"application/postscript"</CODE>,
1189          * print data representation class name = <CODE>"java.net.URL"</CODE>.
1190          */
1191         public static final URL POSTSCRIPT = new URL ("application/postscript");
1192 
1193         /**
1194          * Doc flavor with MIME type = <CODE>"application/vnd.hp-PCL"</CODE>,
1195          * print data representation class name = <CODE>"java.net.URL"</CODE>.
1196          */
1197         public static final URL PCL = new URL ("application/vnd.hp-PCL");
1198 
1199         /**
1200          * Doc flavor with MIME type = <CODE>"image/gif"</CODE>, print data
1201          * representation class name = <CODE>"java.net.URL"</CODE>.
1202          */
1203         public static final URL GIF = new URL ("image/gif");
1204 
1205         /**
1206          * Doc flavor with MIME type = <CODE>"image/jpeg"</CODE>, print data
1207          * representation class name = <CODE>"java.net.URL"</CODE>.
1208          */
1209         public static final URL JPEG = new URL ("image/jpeg");
1210 
1211         /**
1212          * Doc flavor with MIME type = <CODE>"image/png"</CODE>, print data
1213          * representation class name = <CODE>"java.net.URL"</CODE>.
1214          */
1215         public static final URL PNG = new URL ("image/png");
1216 
1217         /**
1218          * Doc flavor with MIME type =
1219          * <CODE>"application/octet-stream"</CODE>,
1220          * print data representation class name = <CODE>"java.net.URL"</CODE>.
1221          *  The client must determine that data described
1222          * using this DocFlavor is valid for the printer.
1223          */
1224         public static final URL AUTOSENSE = new URL ("application/octet-stream");
1225 
1226     }
1227 
1228     /**
1229      * Class DocFlavor.CHAR_ARRAY provides predefined static constant
1230      * DocFlavor objects for example doc flavors using a character array
1231      * (<CODE>char[]</CODE>) as the print data representation class. As such,
1232      * the character set is Unicode.
1233      * <P>
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      * <P>
1284      *
1285      * @author  Alan Kaminsky
1286      */
1287     public static class STRING extends DocFlavor {
1288 
1289         private static final long serialVersionUID = 4414407504887034035L;
1290 
1291         /**
1292          * Constructs a new doc flavor with the given MIME type and a print
1293          * data representation class name of <CODE>"java.lang.String"</CODE>.
1294          *
1295          * @param  mimeType  MIME media type string. If it is a text media
1296          *                      type, it is assumed to contain a
1297          *                      <CODE>"charset=utf-16"</CODE> parameter.
1298          *
1299          * @exception  NullPointerException
1300          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
1301          * @exception  IllegalArgumentException
1302          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
1303          *     obey the syntax for a MIME media type string.
1304          */
1305         public STRING (String mimeType) {
1306             super (mimeType, "java.lang.String");
1307         }
1308 
1309         /**
1310          * Doc flavor with MIME type = <CODE>"text/plain;
1311          * charset=utf-16"</CODE>, print data representation class name =
1312          * <CODE>"java.lang.String"</CODE>.
1313          */
1314         public static final STRING TEXT_PLAIN =
1315             new STRING ("text/plain; charset=utf-16");
1316 
1317         /**
1318          * Doc flavor with MIME type = <CODE>"text/html;
1319          * charset=utf-16"</CODE>, print data representation class name =
1320          * <CODE>"java.lang.String"</CODE>.
1321          */
1322         public static final STRING TEXT_HTML =
1323             new STRING ("text/html; charset=utf-16");
1324     }
1325 
1326     /**
1327      * Class DocFlavor.READER provides predefined static constant DocFlavor
1328      * objects for example doc flavors using a character stream ({@link
1329      * java.io.Reader java.io.Reader}) as the print data
1330      * representation class. As such, the character set is Unicode.
1331      * <P>
1332      *
1333      * @author  Alan Kaminsky
1334      */
1335     public static class READER extends DocFlavor {
1336 
1337         private static final long serialVersionUID = 7100295812579351567L;
1338 
1339         /**
1340          * Constructs a new doc flavor with the given MIME type and a print
1341          * data representation class name of\
1342          * <CODE>"java.io.Reader"</CODE> (character stream).
1343          *
1344          * @param  mimeType  MIME media type string. If it is a text media
1345          *                      type, it is assumed to contain a
1346          *                      <CODE>"charset=utf-16"</CODE> parameter.
1347          *
1348          * @exception  NullPointerException
1349          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
1350          * @exception  IllegalArgumentException
1351          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
1352          *     obey the syntax for a MIME media type string.
1353          */
1354         public READER (String mimeType) {
1355             super (mimeType, "java.io.Reader");
1356         }
1357 
1358         /**
1359          * Doc flavor with MIME type = <CODE>"text/plain;
1360          * charset=utf-16"</CODE>, print data representation class name =
1361          * <CODE>"java.io.Reader"</CODE> (character stream).
1362          */
1363         public static final READER TEXT_PLAIN =
1364             new READER ("text/plain; charset=utf-16");
1365 
1366         /**
1367          * Doc flavor with MIME type = <CODE>"text/html;
1368          * charset=utf-16"</CODE>, print data representation class name =
1369          * <CODE>"java.io.Reader"</CODE> (character stream).
1370          */
1371         public static final READER TEXT_HTML =
1372             new READER ("text/html; charset=utf-16");
1373 
1374     }
1375 
1376     /**
1377      * Class DocFlavor.SERVICE_FORMATTED provides predefined static constant
1378      * DocFlavor objects for example doc flavors for service formatted print
1379      * data.
1380      * <P>
1381      *
1382      * @author  Alan Kaminsky
1383      */
1384     public static class SERVICE_FORMATTED extends DocFlavor {
1385 
1386         private static final long serialVersionUID = 6181337766266637256L;
1387 
1388         /**
1389          * Constructs a new doc flavor with a MIME type of
1390          * <CODE>"application/x-java-jvm-local-objectref"</CODE> indicating
1391          * service formatted print data and the given print data
1392          * representation class name.
1393          *
1394          * @param  className  Fully-qualified representation class name.
1395          *
1396          * @exception  NullPointerException
1397          *     (unchecked exception) Thrown if <CODE>className</CODE> is
1398          *     null.
1399          */
1400         public SERVICE_FORMATTED (String className) {
1401             super ("application/x-java-jvm-local-objectref", className);
1402         }
1403 
1404         /**
1405          * Service formatted print data doc flavor with print data
1406          * representation class name =
1407          * <CODE>"java.awt.image.renderable.RenderableImage"</CODE>
1408          * (renderable image object).
1409          */
1410         public static final SERVICE_FORMATTED RENDERABLE_IMAGE =
1411             new SERVICE_FORMATTED("java.awt.image.renderable.RenderableImage");
1412 
1413         /**
1414          * Service formatted print data doc flavor with print data
1415          * representation class name = <CODE>"java.awt.print.Printable"</CODE>
1416          * (printable object).
1417          */
1418         public static final SERVICE_FORMATTED PRINTABLE =
1419             new SERVICE_FORMATTED ("java.awt.print.Printable");
1420 
1421         /**
1422          * Service formatted print data doc flavor with print data
1423          * representation class name = <CODE>"java.awt.print.Pageable"</CODE>
1424          * (pageable object).
1425          */
1426         public static final SERVICE_FORMATTED PAGEABLE =
1427             new SERVICE_FORMATTED ("java.awt.print.Pageable");
1428 
1429         }
1430 
1431 }
--- EOF ---