Home » openjdk-7 » javax » print » [javadoc | source]

    1   /*
    2    * Copyright (c) 2000, 2010, 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    * <P>
   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() <CODE>Class.getName()</CODE>} 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    * <P>
   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    * Unicde characters in the array.
   99    * <P>
  100    * <LI>
  101    * <code>String</code>  --
  102    * The print data consists of the Unicode characters in the string.
  103    * <P>
  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    * <P>
  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    * <P>
  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    * <p>
  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 gurantee that two VM's 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 <CODE>DocFlavor.hostEncoding</CODE>}
  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    * <p>
  183    * See <a href="../../java/lang/package-summary.html#charenc">
  184    * character encodings</a> for more information on the character encodings
  185    * supported on the Java platform.
  186    * <p>
  187    * <HR>
  188    * <h3>Recommended DocFlavors</h3>
  189    * <P>
  190    * The Java Print Service API does not define any mandatorily supported
  191    * DocFlavors.
  192    * However, here are some examples of MIME types that a Java Print Service
  193    * instance might support for client formatted print data.
  194    * Nested classes inside class DocFlavor declare predefined static
  195    * constant DocFlavor objects for these example doc flavors; class DocFlavor's
  196    * constructor can be used to create an arbitrary doc flavor.
  197    * <UL>
  198    * <LI>Preformatted text
  199    * <P>
  200    * <TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 SUMMARY="MIME-Types and their descriptions">
  201    * <TR>
  202    *  <TH>MIME-Type</TH><TH>Description</TH>
  203    * </TR>
  204    * <TR>
  205    * <TD><CODE>"text/plain"</CODE></TD>
  206    * <TD>Plain text in the default character set (US-ASCII)</TD>
  207    * </TR>
  208    * <TR>
  209    * <TD><CODE>"text/plain; charset=<I>xxx</I>"</CODE></TD>
  210    * <TD>Plain text in character set <I>xxx</I></TD>
  211    * </TR>
  212    * <TR>
  213    * <TD><CODE>"text/html"</CODE></TD>
  214    * <TD>HyperText Markup Language in the default character set (US-ASCII)</TD>
  215    * </TR>
  216    * <TR>
  217    * <TD><CODE>"text/html; charset=<I>xxx</I>"</CODE></TD>
  218    * <TD>HyperText Markup Language in character set <I>xxx</I></TD>
  219    * </TR>
  220    * </TABLE>
  221    * <P>
  222    * In general, preformatted text print data is provided either in a character
  223    * oriented representation class (character array, String, Reader) or in a
  224    * byte oriented representation class (byte array, InputStream, URL).
  225    * <P>
  226    *  <LI>Preformatted page description language (PDL) documents
  227    *<P>
  228    * <TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 SUMMARY="MIME-Types and their descriptions">
  229    * <TR>
  230    *  <TH>MIME-Type</TH><TH>Description</TH>
  231    * </TR>
  232    *<TR>
  233    * <TD><CODE>"application/pdf"</CODE></TD>
  234    * <TD>Portable Document Format document</TD>
  235    * </TR>
  236    * <TR>
  237    * <TD><CODE>"application/postscript"</CODE></TD>
  238    * <TD>PostScript document</TD>
  239    * </TR>
  240    * <TR>
  241    * <TD><CODE>"application/vnd.hp-PCL"</CODE></TD>
  242    * <TD>Printer Control Language document</TD>
  243    * </TR>
  244    * </TABLE>
  245    * <P>
  246    * In general, preformatted PDL print data is provided in a byte oriented
  247    * representation class (byte array, InputStream, URL).
  248    * <P>
  249    *  <LI>Preformatted images
  250    *<P>
  251    * <TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 SUMMARY="MIME-Types and their descriptions">
  252    * <TR>
  253    *  <TH>MIME-Type</TH><TH>Description</TH>
  254    * </TR>
  255    *
  256    * <TR>
  257    * <TD><CODE>"image/gif"</CODE></TD>
  258    * <TD>Graphics Interchange Format image</TD>
  259    * </TR>
  260    * <TR>
  261    * <TD><CODE>"image/jpeg"</CODE></TD>
  262    * <TD>Joint Photographic Experts Group image</TD>
  263    * </TR>
  264    * <TR>
  265    * <TD><CODE>"image/png"</CODE></TD>
  266    * <TD>Portable Network Graphics image</TD>
  267    * </TR>
  268    * </TABLE>
  269    * <P>
  270    * In general, preformatted image print data is provided in a byte oriented
  271    * representation class (byte array, InputStream, URL).
  272    * <P>
  273    *  <LI>Preformatted autosense print data
  274    *   <P>
  275    * <TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 SUMMARY="MIME-Types and their descriptions">
  276    * <TR>
  277    *  <TH>MIME-Type</TH><TH>Description</TH>
  278    * </TR>
  279    *
  280    * <TR>
  281    * <TD><CODE>"application/octet-stream"</CODE></TD>
  282    * <TD>The print data format is unspecified (just an octet stream)</TD>
  283    * </TABLE>
  284    * <P>
  285    * The printer decides how to interpret the print data; the way this
  286    * "autosensing" works is implementation dependent. In general, preformatted
  287    * autosense print data is provided in a byte oriented representation class
  288    * (byte array, InputStream, URL).
  289    *
  290    * <P>
  291    * <HR>
  292    * <H3>Service Formatted Print Data</H3>
  293    * <P>
  294    * For <B>service formatted print data</B>, the Java Print Service instance
  295    * determines the print data format. The doc flavor's representation class
  296    * denotes an interface whose methods the <code>DocPrintJob</code> invokes to
  297    * determine the content to be printed -- such as a renderable image
  298    * interface or a Java printable interface.
  299    * The doc flavor's MIME type is the special value
  300    * <CODE>"application/x-java-jvm-local-objectref"</CODE> indicating the client
  301    * will supply a reference to a Java object that implements the interface
  302    * named as the representation class.
  303    * This MIME type is just a placeholder; what's
  304    * important is the print data representation class.
  305    * <P>
  306    * For service formatted print data, the print data representation class is
  307    * typically one of the following (although other representation classes are
  308    * permitted). Nested classes inside class DocFlavor declare predefined static
  309    * constant DocFlavor objects for these example doc flavors; class DocFlavor's
  310    * constructor can be used to create an arbitrary doc flavor.
  311    * <UL>
  312    * <LI>
  313    * Renderable image object -- The client supplies an object that implements
  314    * interface
  315    * {@link java.awt.image.renderable.RenderableImage RenderableImage}. The
  316    * printer calls methods
  317    * in that interface to obtain the image to be printed.
  318    * <P>
  319    * <LI>
  320    * Printable object -- The client supplies an object that implements interface
  321    * {@link java.awt.print.Printable Printable}.
  322    * The printer calls methods in that interface to obtain the pages to be
  323    * printed, one by one.
  324    * For each page, the printer supplies a graphics context, and whatever the
  325    * client draws in that graphics context gets printed.
  326    * <P>
  327    * <LI>
  328    * Pageable object -- The client supplies an object that implements interface
  329    * {@link java.awt.print.Pageable Pageable}. The printer calls
  330    * methods in that interface to obtain the pages to be printed, one by one.
  331    * For each page, the printer supplies a graphics context, and whatever
  332    * the client draws in that graphics context gets printed.
  333    * </UL>
  334    * <P>
  335    * <HR>
  336    * <P>
  337    * <HR>
  338    * <H3>Pre-defined Doc Flavors</H3>
  339    * A Java Print Service instance is not <B><I>required</I></B> to support the
  340    * following print data formats and print data representation classes.  In
  341    * fact, a developer using this class should <b>never</b> assume that a
  342    * particular print service supports the document types corresponding to
  343    * these pre-defined doc flavors.  Always query the print service
  344    * to determine what doc flavors it supports.  However,
  345    * developers who have print services that support these doc flavors are
  346    * encouraged to refer to the predefined singleton instances created here.
  347    * <UL>
  348    * <LI>
  349    * Plain text print data provided through a byte stream. Specifically, the
  350    * following doc flavors are recommended to be supported:
  351    * <BR>&#183;&nbsp;&nbsp;
  352    * <CODE>("text/plain", "java.io.InputStream")</CODE>
  353    * <BR>&#183;&nbsp;&nbsp;
  354    * <CODE>("text/plain; charset=us-ascii", "java.io.InputStream")</CODE>
  355    * <BR>&#183;&nbsp;&nbsp;
  356    * <CODE>("text/plain; charset=utf-8", "java.io.InputStream")</CODE>
  357    * <P>
  358    * <LI>
  359    * Renderable image objects. Specifically, the following doc flavor is
  360    * recommended to be supported:
  361    * <BR>&#183;&nbsp;&nbsp;
  362    * <CODE>("application/x-java-jvm-local-objectref", "java.awt.image.renderable.RenderableImage")</CODE>
  363    * </UL>
  364    * <P>
  365    * A Java Print Service instance is allowed to support any other doc flavors
  366    * (or none) in addition to the above mandatory ones, at the implementation's
  367    * choice.
  368    * <P>
  369    * Support for the above doc flavors is desirable so a printing client can rely
  370    * on being able to print on any JPS printer, regardless of which doc flavors
  371    * the printer supports. If the printer doesn't support the client's preferred
  372    * doc flavor, the client can at least print plain text, or the client can
  373    * convert its data to a renderable image and print the image.
  374    * <P>
  375    * Furthermore, every Java Print Service instance must fulfill these
  376    * requirements for processing plain text print data:
  377    * <UL>
  378    * <LI>
  379    * The character pair carriage return-line feed (CR-LF) means
  380    * "go to column 1 of the next line."
  381    * <LI>
  382    * A carriage return (CR) character standing by itself means
  383    * "go to column 1 of the next line."
  384    * <LI>
  385    * A line feed (LF) character standing by itself means
  386    * "go to column 1 of the next line."
  387    * <LI>
  388    * </UL>
  389    * <P>
  390    * The client must itself perform all plain text print data formatting not
  391    * addressed by the above requirements.
  392    * <P>
  393    * <H3>Design Rationale</H3>
  394    * <P>
  395    * Class DocFlavor in package javax.print.data is similar to class
  396    * {@link java.awt.datatransfer.DataFlavor DataFlavor}. Class
  397    * <code>DataFlavor</code>
  398    * is not used in the Java Print Service (JPS) API
  399    * for three reasons which are all rooted in allowing the JPS API to be
  400    * shared by other print services APIs which may need to run on Java profiles
  401    * which do not include all of the Java Platform, Standard Edition.
  402    * <OL TYPE=1>
  403    * <LI>
  404    * The JPS API is designed to be used in Java profiles which do not support
  405    * AWT.
  406    * <P>
  407    * <LI>
  408    * The implementation of class <code>java.awt.datatransfer.DataFlavor</code>
  409    * does not guarantee that equivalent data flavors will have the same
  410    * serialized representation. DocFlavor does, and can be used in services
  411    * which need this.
  412    * <P>
  413    * <LI>
  414    * The implementation of class <code>java.awt.datatransfer.DataFlavor</code>
  415    * includes a human presentable name as part of the serialized representation.
  416    * This is not appropriate as part of a service matching constraint.
  417    * </OL>
  418    * <P>
  419    * Class DocFlavor's serialized representation uses the following
  420    * canonical form of a MIME type string. Thus, two doc flavors with MIME types
  421    * that are not identical but that are equivalent (that have the same
  422    * canonical form) may be considered equal.
  423    * <UL>
  424    * <LI> The media type, media subtype, and parameters are retained, but all
  425    *      comments and whitespace characters are discarded.
  426    * <LI> The media type, media subtype, and parameter names are converted to
  427    *      lowercase.
  428    * <LI> The parameter values retain their original case, except a charset
  429    *      parameter value for a text media type is converted to lowercase.
  430    * <LI> Quote characters surrounding parameter values are removed.
  431    * <LI> Quoting backslash characters inside parameter values are removed.
  432    * <LI> The parameters are arranged in ascending order of parameter name.
  433    * </UL>
  434    * <P>
  435    * Class DocFlavor's serialized representation also contains the
  436    * fully-qualified class <I>name</I> of the representation class
  437    * (a String object), rather than the representation class itself
  438    * (a Class object). This allows a client to examine the doc flavors a
  439    * Java Print Service instance supports without having
  440    * to load the representation classes, which may be problematic for
  441    * limited-resource clients.
  442    * <P>
  443    *
  444    * @author  Alan Kaminsky
  445    */
  446   public class DocFlavor implements Serializable, Cloneable {
  447   
  448       private static final long serialVersionUID = -4512080796965449721L;
  449   
  450       /**
  451        * A String representing the host operating system encoding.
  452        * This will follow the conventions documented in
  453        * <a href="http://www.ietf.org/rfc/rfc2278.txt">
  454        * <i>RFC&nbsp;2278:&nbsp;IANA Charset Registration Procedures</i></a>
  455        * except where historical names are returned for compatibility with
  456        * previous versions of the Java platform.
  457        * The value returned from method is valid only for the VM which
  458        * returns it, for use in a DocFlavor.
  459        * This is the charset for all the "HOST" pre-defined DocFlavors in
  460        * the executing VM.
  461        */
  462       public static final String hostEncoding;
  463   
  464       static {
  465           hostEncoding =
  466               (String)java.security.AccessController.doPrivileged(
  467                     new sun.security.action.GetPropertyAction("file.encoding"));
  468       }
  469   
  470       /**
  471        * MIME type.
  472        */
  473       private transient MimeType myMimeType;
  474   
  475       /**
  476        * Representation class name.
  477        * @serial
  478        */
  479       private String myClassName;
  480   
  481       /**
  482        * String value for this doc flavor. Computed when needed and cached.
  483        */
  484       private transient String myStringValue = null;
  485   
  486   
  487       /**
  488        * Constructs a new doc flavor object from the given MIME type and
  489        * representation class name. The given MIME type is converted into
  490        * canonical form and stored internally.
  491        *
  492        * @param  mimeType   MIME media type string.
  493        * @param  className  Fully-qualified representation class name.
  494        *
  495        * @exception  NullPointerException
  496        *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null or
  497        *     <CODE>className</CODE> is null.
  498        * @exception  IllegalArgumentException
  499        *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
  500        *     obey the syntax for a MIME media type string.
  501        */
  502       public DocFlavor(String mimeType, String className) {
  503           if (className == null) {
  504               throw new NullPointerException();
  505           }
  506           myMimeType = new MimeType (mimeType);
  507           myClassName = className;
  508       }
  509   
  510       /**
  511        * Returns this doc flavor object's MIME type string based on the
  512        * canonical form. Each parameter value is enclosed in quotes.
  513        * @return the mime type
  514        */
  515       public String getMimeType() {
  516           return myMimeType.getMimeType();
  517       }
  518   
  519       /**
  520        * Returns this doc flavor object's media type (from the MIME type).
  521        * @return the media type
  522        */
  523       public String getMediaType() {
  524           return myMimeType.getMediaType();
  525       }
  526   
  527       /**
  528        * Returns this doc flavor object's media subtype (from the MIME type).
  529        * @return the media sub-type
  530        */
  531       public String getMediaSubtype() {
  532           return myMimeType.getMediaSubtype();
  533       }
  534   
  535       /**
  536        * Returns a <code>String</code> representing a MIME
  537        * parameter.
  538        * Mime types may include parameters which are usually optional.
  539        * The charset for text types is a commonly useful example.
  540        * This convenience method will return the value of the specified
  541        * parameter if one was specified in the mime type for this flavor.
  542        * <p>
  543        * @param paramName the name of the paramater. This name is internally
  544        * converted to the canonical lower case format before performing
  545        * the match.
  546        * @return String representing a mime parameter, or
  547        * null if that parameter is not in the mime type string.
  548        * @exception throws NullPointerException if paramName is null.
  549        */
  550       public String getParameter(String paramName) {
  551           return
  552               (String)myMimeType.getParameterMap().get(paramName.toLowerCase());
  553       }
  554   
  555       /**
  556        * Returns the name of this doc flavor object's representation class.
  557        * @return the name of the representation class.
  558        */
  559       public String getRepresentationClassName() {
  560           return myClassName;
  561       }
  562   
  563       /**
  564        * Converts this <code>DocFlavor</code> to a string.
  565        *
  566        * @return  MIME type string based on the canonical form. Each parameter
  567        *          value is enclosed in quotes.
  568        *          A "class=" parameter is appended to the
  569        *          MIME type string to indicate the representation class name.
  570        */
  571       public String toString() {
  572           return getStringValue();
  573       }
  574   
  575       /**
  576        * Returns a hash code for this doc flavor object.
  577        */
  578       public int hashCode() {
  579           return getStringValue().hashCode();
  580       }
  581   
  582       /**
  583        * Determines if this doc flavor object is equal to the given object.
  584        * The two are equal if the given object is not null, is an instance
  585        * of <code>DocFlavor</code>, has a MIME type equivalent to this doc
  586        * flavor object's MIME type (that is, the MIME types have the same media
  587        * type, media subtype, and parameters), and has the same representation
  588        * class name as this doc flavor object. Thus, if two doc flavor objects'
  589        * MIME types are the same except for comments, they are considered equal.
  590        * However, two doc flavor objects with MIME types of "text/plain" and
  591        * "text/plain; charset=US-ASCII" are not considered equal, even though
  592        * they represent the same media type (because the default character
  593        * set for plain text is US-ASCII).
  594        *
  595        * @param  obj  Object to test.
  596        *
  597        * @return  True if this doc flavor object equals <CODE>obj</CODE>, false
  598        *          otherwise.
  599        */
  600       public boolean equals(Object obj) {
  601           return
  602               obj != null &&
  603               obj instanceof DocFlavor &&
  604               getStringValue().equals (((DocFlavor) obj).getStringValue());
  605       }
  606   
  607       /**
  608        * Returns this doc flavor object's string value.
  609        */
  610       private String getStringValue() {
  611           if (myStringValue == null) {
  612               myStringValue = myMimeType + "; class=\"" + myClassName + "\"";
  613           }
  614           return myStringValue;
  615       }
  616   
  617       /**
  618        * Write the instance to a stream (ie serialize the object).
  619        */
  620       private void writeObject(ObjectOutputStream s) throws IOException {
  621   
  622           s.defaultWriteObject();
  623           s.writeObject(myMimeType.getMimeType());
  624       }
  625   
  626       /**
  627        * Reconstitute an instance from a stream (that is, deserialize it).
  628        *
  629        * @serialData
  630        * The serialised form of a DocFlavor is the String naming the
  631        * representation class followed by the String representing the canonical
  632        * form of the mime type.
  633        */
  634       private void readObject(ObjectInputStream s)
  635           throws ClassNotFoundException, IOException {
  636   
  637           s.defaultReadObject();
  638           myMimeType = new MimeType((String)s.readObject());
  639       }
  640   
  641       /**
  642        * Class DocFlavor.BYTE_ARRAY provides predefined static constant
  643        * DocFlavor objects for example doc flavors using a byte array
  644        * (<CODE>byte[]</CODE>) as the print data representation class.
  645        * <P>
  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 <CODE>hostEncoding</CODE>}
  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 <CODE>hostEncoding</CODE>}
  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 <CODE>java.io.InputStream</CODE>}) as the print
  842        * data representation class.
  843        * <P>
  844        *
  845        * @author  Alan Kaminsky
  846        */
  847       public static class INPUT_STREAM extends DocFlavor {
  848   
  849           private static final long serialVersionUID = -7045842700749194127L;
  850   
  851           /**
  852            * Constructs a new doc flavor with the given MIME type and a print
  853            * data representation class name of
  854            * <CODE>"java.io.InputStream"</CODE> (byte stream).
  855            *
  856            * @param  mimeType   MIME media type string.
  857            *
  858            * @exception  NullPointerException
  859            *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
  860            * @exception  IllegalArgumentException
  861            *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
  862            *     obey the syntax for a MIME media type string.
  863            */
  864           public INPUT_STREAM (String mimeType) {
  865               super (mimeType, "java.io.InputStream");
  866           }
  867   
  868           /**
  869            * Doc flavor with MIME type = <CODE>"text/plain"</CODE>,
  870            * encoded in the host platform encoding.
  871            * See {@link DocFlavor#hostEncoding <CODE>hostEncoding</CODE>}
  872            * Print data representation class name =
  873            * <CODE>"java.io.InputStream"</CODE> (byte stream).
  874            */
  875           public static final INPUT_STREAM TEXT_PLAIN_HOST =
  876               new INPUT_STREAM ("text/plain; charset="+hostEncoding);
  877   
  878           /**
  879            * Doc flavor with MIME type =
  880            * <CODE>"text/plain; charset=utf-8"</CODE>,
  881            * print data representation class name =
  882            * <CODE>"java.io.InputStream"</CODE> (byte stream).
  883            */
  884           public static final INPUT_STREAM TEXT_PLAIN_UTF_8 =
  885               new INPUT_STREAM ("text/plain; charset=utf-8");
  886   
  887           /**
  888            * Doc flavor with MIME type =
  889            * <CODE>"text/plain; charset=utf-16"</CODE>,
  890            * print data representation class name =
  891            * <CODE>"java.io.InputStream"</CODE> (byte stream).
  892            */
  893           public static final INPUT_STREAM TEXT_PLAIN_UTF_16 =
  894               new INPUT_STREAM ("text/plain; charset=utf-16");
  895   
  896           /**
  897            * Doc flavor with MIME type =
  898            * <CODE>"text/plain; charset=utf-16be"</CODE>
  899            * (big-endian byte ordering),
  900            * print data representation class name =
  901            * <CODE>"java.io.InputStream"</CODE> (byte stream).
  902            */
  903           public static final INPUT_STREAM TEXT_PLAIN_UTF_16BE =
  904               new INPUT_STREAM ("text/plain; charset=utf-16be");
  905   
  906           /**
  907            * Doc flavor with MIME type =
  908            * <CODE>"text/plain; charset=utf-16le"</CODE>
  909            * (little-endian byte ordering),
  910            * print data representation class name =
  911            * <CODE>"java.io.InputStream"</CODE> (byte stream).
  912            */
  913           public static final INPUT_STREAM TEXT_PLAIN_UTF_16LE =
  914               new INPUT_STREAM ("text/plain; charset=utf-16le");
  915   
  916           /**
  917            * Doc flavor with MIME type =
  918            * <CODE>"text/plain; charset=us-ascii"</CODE>,
  919            * print data representation class name =
  920            * <CODE>"java.io.InputStream"</CODE> (byte stream).
  921            */
  922           public static final INPUT_STREAM TEXT_PLAIN_US_ASCII =
  923                   new INPUT_STREAM ("text/plain; charset=us-ascii");
  924   
  925           /**
  926            * Doc flavor with MIME type = <CODE>"text/html"</CODE>,
  927            * encoded in the host platform encoding.
  928            * See {@link DocFlavor#hostEncoding <CODE>hostEncoding</CODE>}
  929            * Print data representation class name =
  930            * <CODE>"java.io.InputStream"</CODE> (byte stream).
  931            */
  932           public static final INPUT_STREAM TEXT_HTML_HOST =
  933               new INPUT_STREAM ("text/html; charset="+hostEncoding);
  934   
  935           /**
  936            * Doc flavor with MIME type =
  937            * <CODE>"text/html; charset=utf-8"</CODE>,
  938            * print data representation class name =
  939            * <CODE>"java.io.InputStream"</CODE> (byte stream).
  940            */
  941           public static final INPUT_STREAM TEXT_HTML_UTF_8 =
  942               new INPUT_STREAM ("text/html; charset=utf-8");
  943   
  944           /**
  945            * Doc flavor with MIME type =
  946            * <CODE>"text/html; charset=utf-16"</CODE>,
  947            * print data representation class name =
  948            * <CODE>"java.io.InputStream"</CODE> (byte stream).
  949            */
  950           public static final INPUT_STREAM TEXT_HTML_UTF_16 =
  951               new INPUT_STREAM ("text/html; charset=utf-16");
  952   
  953           /**
  954            * Doc flavor with MIME type =
  955            * <CODE>"text/html; charset=utf-16be"</CODE>
  956            * (big-endian byte ordering),
  957            * print data representation class name =
  958            * <CODE>"java.io.InputStream"</CODE> (byte stream).
  959            */
  960           public static final INPUT_STREAM TEXT_HTML_UTF_16BE =
  961               new INPUT_STREAM ("text/html; charset=utf-16be");
  962   
  963           /**
  964            * Doc flavor with MIME type =
  965            * <CODE>"text/html; charset=utf-16le"</CODE>
  966            * (little-endian byte ordering),
  967            * print data representation class name =
  968            * <CODE>"java.io.InputStream"</CODE> (byte stream).
  969            */
  970           public static final INPUT_STREAM TEXT_HTML_UTF_16LE =
  971               new INPUT_STREAM ("text/html; charset=utf-16le");
  972   
  973           /**
  974            * Doc flavor with MIME type =
  975            * <CODE>"text/html; charset=us-ascii"</CODE>,
  976            * print data representation class name =
  977            * <CODE>"java.io.InputStream"</CODE> (byte stream).
  978            */
  979           public static final INPUT_STREAM TEXT_HTML_US_ASCII =
  980               new INPUT_STREAM ("text/html; charset=us-ascii");
  981   
  982   
  983           /**
  984            * Doc flavor with MIME type = <CODE>"application/pdf"</CODE>, print
  985            * data representation class name = <CODE>"java.io.InputStream"</CODE>
  986            * (byte stream).
  987            */
  988           public static final INPUT_STREAM PDF = new INPUT_STREAM ("application/pdf");
  989   
  990           /**
  991            * Doc flavor with MIME type = <CODE>"application/postscript"</CODE>,
  992            * print data representation class name =
  993            * <CODE>"java.io.InputStream"</CODE> (byte stream).
  994            */
  995           public static final INPUT_STREAM POSTSCRIPT =
  996               new INPUT_STREAM ("application/postscript");
  997   
  998           /**
  999            * Doc flavor with MIME type = <CODE>"application/vnd.hp-PCL"</CODE>,
 1000            * print data representation class name =
 1001            * <CODE>"java.io.InputStream"</CODE> (byte stream).
 1002            */
 1003           public static final INPUT_STREAM PCL =
 1004               new INPUT_STREAM ("application/vnd.hp-PCL");
 1005   
 1006           /**
 1007            * Doc flavor with MIME type = <CODE>"image/gif"</CODE>, print data
 1008            * representation class name =
 1009            * <CODE>"java.io.InputStream"</CODE> (byte stream).
 1010            */
 1011           public static final INPUT_STREAM GIF = new INPUT_STREAM ("image/gif");
 1012   
 1013           /**
 1014            * Doc flavor with MIME type = <CODE>"image/jpeg"</CODE>, print data
 1015            * representation class name =
 1016            * <CODE>"java.io.InputStream"</CODE> (byte stream).
 1017            */
 1018           public static final INPUT_STREAM JPEG = new INPUT_STREAM ("image/jpeg");
 1019   
 1020           /**
 1021            * Doc flavor with MIME type = <CODE>"image/png"</CODE>, print data
 1022            * representation class name =
 1023            * <CODE>"java.io.InputStream"</CODE> (byte stream).
 1024            */
 1025           public static final INPUT_STREAM PNG = new INPUT_STREAM ("image/png");
 1026   
 1027           /**
 1028            * Doc flavor with MIME type =
 1029            * <CODE>"application/octet-stream"</CODE>,
 1030            * print data representation class name =
 1031            * <CODE>"java.io.InputStream"</CODE> (byte stream).
 1032            * The client must determine that data described
 1033            * using this DocFlavor is valid for the printer.
 1034            */
 1035           public static final INPUT_STREAM AUTOSENSE =
 1036               new INPUT_STREAM ("application/octet-stream");
 1037   
 1038       }
 1039   
 1040       /**
 1041        * Class DocFlavor.URL provides predefined static constant DocFlavor
 1042        * objects.
 1043        * For example doc flavors using a Uniform Resource Locator ({@link
 1044        * java.net.URL <CODE>java.net.URL</CODE>}) as the print data
 1045        * representation  class.
 1046        * <P>
 1047        *
 1048        * @author  Alan Kaminsky
 1049        */
 1050       public static class URL extends DocFlavor {
 1051   
 1052           /**
 1053            * Constructs a new doc flavor with the given MIME type and a print
 1054            * data representation class name of <CODE>"java.net.URL"</CODE>.
 1055            *
 1056            * @param  mimeType   MIME media type string.
 1057            *
 1058            * @exception  NullPointerException
 1059            *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
 1060            * @exception  IllegalArgumentException
 1061            *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
 1062            *     obey the syntax for a MIME media type string.
 1063            */
 1064           public URL (String mimeType) {
 1065               super (mimeType, "java.net.URL");
 1066           }
 1067   
 1068           /**
 1069            * Doc flavor with MIME type = <CODE>"text/plain"</CODE>,
 1070            * encoded in the host platform encoding.
 1071            * See {@link DocFlavor#hostEncoding <CODE>hostEncoding</CODE>}
 1072            * Print data representation class name =
 1073            * <CODE>"java.net.URL"</CODE> (byte stream).
 1074            */
 1075           public static final URL TEXT_PLAIN_HOST =
 1076               new URL ("text/plain; charset="+hostEncoding);
 1077   
 1078           /**
 1079            * Doc flavor with MIME type =
 1080            * <CODE>"text/plain; charset=utf-8"</CODE>,
 1081            * print data representation class name =
 1082            * <CODE>"java.net.URL"</CODE> (byte stream).
 1083            */
 1084           public static final URL TEXT_PLAIN_UTF_8 =
 1085               new URL ("text/plain; charset=utf-8");
 1086   
 1087           /**
 1088            * Doc flavor with MIME type =
 1089            * <CODE>"text/plain; charset=utf-16"</CODE>,
 1090            * print data representation class name =
 1091            * <CODE>java.net.URL""</CODE> (byte stream).
 1092            */
 1093           public static final URL TEXT_PLAIN_UTF_16 =
 1094               new URL ("text/plain; charset=utf-16");
 1095   
 1096           /**
 1097            * Doc flavor with MIME type =
 1098            * <CODE>"text/plain; charset=utf-16be"</CODE>
 1099            * (big-endian byte ordering),
 1100            * print data representation class name =
 1101            * <CODE>"java.net.URL"</CODE> (byte stream).
 1102            */
 1103           public static final URL TEXT_PLAIN_UTF_16BE =
 1104               new URL ("text/plain; charset=utf-16be");
 1105   
 1106           /**
 1107            * Doc flavor with MIME type =
 1108            * <CODE>"text/plain; charset=utf-16le"</CODE>
 1109            * (little-endian byte ordering),
 1110            * print data representation class name =
 1111            * <CODE>"java.net.URL"</CODE> (byte stream).
 1112            */
 1113           public static final URL TEXT_PLAIN_UTF_16LE =
 1114               new URL ("text/plain; charset=utf-16le");
 1115   
 1116           /**
 1117            * Doc flavor with MIME type =
 1118            * <CODE>"text/plain; charset=us-ascii"</CODE>,
 1119            * print data representation class name =
 1120            * <CODE>"java.net.URL"</CODE> (byte stream).
 1121            */
 1122           public static final URL TEXT_PLAIN_US_ASCII =
 1123               new URL ("text/plain; charset=us-ascii");
 1124   
 1125           /**
 1126            * Doc flavor with MIME type = <CODE>"text/html"</CODE>,
 1127            * encoded in the host platform encoding.
 1128            * See {@link DocFlavor#hostEncoding <CODE>hostEncoding</CODE>}
 1129            * Print data representation class name =
 1130            * <CODE>"java.net.URL"</CODE> (byte stream).
 1131            */
 1132           public static final URL TEXT_HTML_HOST =
 1133               new URL ("text/html; charset="+hostEncoding);
 1134   
 1135           /**
 1136            * Doc flavor with MIME type =
 1137            * <CODE>"text/html; charset=utf-8"</CODE>,
 1138            * print data representation class name =
 1139            * <CODE>"java.net.URL"</CODE> (byte stream).
 1140            */
 1141           public static final URL TEXT_HTML_UTF_8 =
 1142               new URL ("text/html; charset=utf-8");
 1143   
 1144           /**
 1145            * Doc flavor with MIME type =
 1146            * <CODE>"text/html; charset=utf-16"</CODE>,
 1147            * print data representation class name =
 1148            * <CODE>"java.net.URL"</CODE> (byte stream).
 1149            */
 1150           public static final URL TEXT_HTML_UTF_16 =
 1151               new URL ("text/html; charset=utf-16");
 1152   
 1153           /**
 1154            * Doc flavor with MIME type =
 1155            * <CODE>"text/html; charset=utf-16be"</CODE>
 1156            * (big-endian byte ordering),
 1157            * print data representation class name =
 1158            * <CODE>"java.net.URL"</CODE> (byte stream).
 1159            */
 1160           public static final URL TEXT_HTML_UTF_16BE =
 1161               new URL ("text/html; charset=utf-16be");
 1162   
 1163           /**
 1164            * Doc flavor with MIME type =
 1165            * <CODE>"text/html; charset=utf-16le"</CODE>
 1166            * (little-endian byte ordering),
 1167            * print data representation class name =
 1168            * <CODE>"java.net.URL"</CODE> (byte stream).
 1169            */
 1170           public static final URL TEXT_HTML_UTF_16LE =
 1171               new URL ("text/html; charset=utf-16le");
 1172   
 1173           /**
 1174            * Doc flavor with MIME type =
 1175            * <CODE>"text/html; charset=us-ascii"</CODE>,
 1176            * print data representation class name =
 1177            * <CODE>"java.net.URL"</CODE> (byte stream).
 1178            */
 1179           public static final URL TEXT_HTML_US_ASCII =
 1180               new URL ("text/html; charset=us-ascii");
 1181   
 1182   
 1183           /**
 1184            * Doc flavor with MIME type = <CODE>"application/pdf"</CODE>, print
 1185            * data representation class name = <CODE>"java.net.URL"</CODE>.
 1186            */
 1187           public static final URL PDF = new URL ("application/pdf");
 1188   
 1189           /**
 1190            * Doc flavor with MIME type = <CODE>"application/postscript"</CODE>,
 1191            * print data representation class name = <CODE>"java.net.URL"</CODE>.
 1192            */
 1193           public static final URL POSTSCRIPT = new URL ("application/postscript");
 1194   
 1195           /**
 1196            * Doc flavor with MIME type = <CODE>"application/vnd.hp-PCL"</CODE>,
 1197            * print data representation class name = <CODE>"java.net.URL"</CODE>.
 1198            */
 1199           public static final URL PCL = new URL ("application/vnd.hp-PCL");
 1200   
 1201           /**
 1202            * Doc flavor with MIME type = <CODE>"image/gif"</CODE>, print data
 1203            * representation class name = <CODE>"java.net.URL"</CODE>.
 1204            */
 1205           public static final URL GIF = new URL ("image/gif");
 1206   
 1207           /**
 1208            * Doc flavor with MIME type = <CODE>"image/jpeg"</CODE>, print data
 1209            * representation class name = <CODE>"java.net.URL"</CODE>.
 1210            */
 1211           public static final URL JPEG = new URL ("image/jpeg");
 1212   
 1213           /**
 1214            * Doc flavor with MIME type = <CODE>"image/png"</CODE>, print data
 1215            * representation class name = <CODE>"java.net.URL"</CODE>.
 1216            */
 1217           public static final URL PNG = new URL ("image/png");
 1218   
 1219           /**
 1220            * Doc flavor with MIME type =
 1221            * <CODE>"application/octet-stream"</CODE>,
 1222            * print data representation class name = <CODE>"java.net.URL"</CODE>.
 1223            *  The client must determine that data described
 1224            * using this DocFlavor is valid for the printer.
 1225            */
 1226           public static final URL AUTOSENSE = new URL ("application/octet-stream");
 1227   
 1228       }
 1229   
 1230       /**
 1231        * Class DocFlavor.CHAR_ARRAY provides predefined static constant
 1232        * DocFlavor objects for example doc flavors using a character array
 1233        * (<CODE>char[]</CODE>) as the print data representation class. As such,
 1234        * the character set is Unicode.
 1235        * <P>
 1236        *
 1237        * @author  Alan Kaminsky
 1238        */
 1239       public static class CHAR_ARRAY extends DocFlavor {
 1240   
 1241           private static final long serialVersionUID = -8720590903724405128L;
 1242   
 1243           /**
 1244            * Constructs a new doc flavor with the given MIME type and a print
 1245            * data representation class name of
 1246            * <CODE>"[C"</CODE> (character array).
 1247            *
 1248            * @param  mimeType  MIME media type string. If it is a text media
 1249            *                      type, it is assumed to contain a
 1250            *                      <CODE>"charset=utf-16"</CODE> parameter.
 1251            *
 1252            * @exception  NullPointerException
 1253            *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
 1254            * @exception  IllegalArgumentException
 1255            *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
 1256            *     obey the syntax for a MIME media type string.
 1257            */
 1258           public CHAR_ARRAY (String mimeType) {
 1259               super (mimeType, "[C");
 1260           }
 1261   
 1262           /**
 1263            * Doc flavor with MIME type = <CODE>"text/plain;
 1264            * charset=utf-16"</CODE>, print data representation class name =
 1265            * <CODE>"[C"</CODE> (character array).
 1266            */
 1267           public static final CHAR_ARRAY TEXT_PLAIN =
 1268               new CHAR_ARRAY ("text/plain; charset=utf-16");
 1269   
 1270           /**
 1271            * Doc flavor with MIME type = <CODE>"text/html;
 1272            * charset=utf-16"</CODE>, print data representation class name =
 1273            * <CODE>"[C"</CODE> (character array).
 1274            */
 1275           public static final CHAR_ARRAY TEXT_HTML =
 1276               new CHAR_ARRAY ("text/html; charset=utf-16");
 1277   
 1278       }
 1279   
 1280       /**
 1281        * Class DocFlavor.STRING provides predefined static constant DocFlavor
 1282        * objects for example doc flavors using a string ({@link java.lang.String
 1283        * <CODE>java.lang.String</CODE>}) as the print data representation class.
 1284        * As such, the character set is Unicode.
 1285        * <P>
 1286        *
 1287        * @author  Alan Kaminsky
 1288        */
 1289       public static class STRING extends DocFlavor {
 1290   
 1291           private static final long serialVersionUID = 4414407504887034035L;
 1292   
 1293           /**
 1294            * Constructs a new doc flavor with the given MIME type and a print
 1295            * data representation class name of <CODE>"java.lang.String"</CODE>.
 1296            *
 1297            * @param  mimeType  MIME media type string. If it is a text media
 1298            *                      type, it is assumed to contain a
 1299            *                      <CODE>"charset=utf-16"</CODE> parameter.
 1300            *
 1301            * @exception  NullPointerException
 1302            *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
 1303            * @exception  IllegalArgumentException
 1304            *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
 1305            *     obey the syntax for a MIME media type string.
 1306            */
 1307           public STRING (String mimeType) {
 1308               super (mimeType, "java.lang.String");
 1309           }
 1310   
 1311           /**
 1312            * Doc flavor with MIME type = <CODE>"text/plain;
 1313            * charset=utf-16"</CODE>, print data representation class name =
 1314            * <CODE>"java.lang.String"</CODE>.
 1315            */
 1316           public static final STRING TEXT_PLAIN =
 1317               new STRING ("text/plain; charset=utf-16");
 1318   
 1319           /**
 1320            * Doc flavor with MIME type = <CODE>"text/html;
 1321            * charset=utf-16"</CODE>, print data representation class name =
 1322            * <CODE>"java.lang.String"</CODE>.
 1323            */
 1324           public static final STRING TEXT_HTML =
 1325               new STRING ("text/html; charset=utf-16");
 1326       }
 1327   
 1328       /**
 1329        * Class DocFlavor.READER provides predefined static constant DocFlavor
 1330        * objects for example doc flavors using a character stream ({@link
 1331        * java.io.Reader <CODE>java.io.Reader</CODE>}) as the print data
 1332        * representation class. As such, the character set is Unicode.
 1333        * <P>
 1334        *
 1335        * @author  Alan Kaminsky
 1336        */
 1337       public static class READER extends DocFlavor {
 1338   
 1339           private static final long serialVersionUID = 7100295812579351567L;
 1340   
 1341           /**
 1342            * Constructs a new doc flavor with the given MIME type and a print
 1343            * data representation class name of\
 1344            * <CODE>"java.io.Reader"</CODE> (character stream).
 1345            *
 1346            * @param  mimeType  MIME media type string. If it is a text media
 1347            *                      type, it is assumed to contain a
 1348            *                      <CODE>"charset=utf-16"</CODE> parameter.
 1349            *
 1350            * @exception  NullPointerException
 1351            *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
 1352            * @exception  IllegalArgumentException
 1353            *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
 1354            *     obey the syntax for a MIME media type string.
 1355            */
 1356           public READER (String mimeType) {
 1357               super (mimeType, "java.io.Reader");
 1358           }
 1359   
 1360           /**
 1361            * Doc flavor with MIME type = <CODE>"text/plain;
 1362            * charset=utf-16"</CODE>, print data representation class name =
 1363            * <CODE>"java.io.Reader"</CODE> (character stream).
 1364            */
 1365           public static final READER TEXT_PLAIN =
 1366               new READER ("text/plain; charset=utf-16");
 1367   
 1368           /**
 1369            * Doc flavor with MIME type = <CODE>"text/html;
 1370            * charset=utf-16"</CODE>, print data representation class name =
 1371            * <CODE>"java.io.Reader"</CODE> (character stream).
 1372            */
 1373           public static final READER TEXT_HTML =
 1374               new READER ("text/html; charset=utf-16");
 1375   
 1376       }
 1377   
 1378       /**
 1379        * Class DocFlavor.SERVICE_FORMATTED provides predefined static constant
 1380        * DocFlavor objects for example doc flavors for service formatted print
 1381        * data.
 1382        * <P>
 1383        *
 1384        * @author  Alan Kaminsky
 1385        */
 1386       public static class SERVICE_FORMATTED extends DocFlavor {
 1387   
 1388           private static final long serialVersionUID = 6181337766266637256L;
 1389   
 1390           /**
 1391            * Constructs a new doc flavor with a MIME type of
 1392            * <CODE>"application/x-java-jvm-local-objectref"</CODE> indicating
 1393            * service formatted print data and the given print data
 1394            * representation class name.
 1395            *
 1396            * @param  className  Fully-qualified representation class name.
 1397            *
 1398            * @exception  NullPointerException
 1399            *     (unchecked exception) Thrown if <CODE>className</CODE> is
 1400            *     null.
 1401            */
 1402           public SERVICE_FORMATTED (String className) {
 1403               super ("application/x-java-jvm-local-objectref", className);
 1404           }
 1405   
 1406           /**
 1407            * Service formatted print data doc flavor with print data
 1408            * representation class name =
 1409            * <CODE>"java.awt.image.renderable.RenderableImage"</CODE>
 1410            * (renderable image object).
 1411            */
 1412           public static final SERVICE_FORMATTED RENDERABLE_IMAGE =
 1413               new SERVICE_FORMATTED("java.awt.image.renderable.RenderableImage");
 1414   
 1415           /**
 1416            * Service formatted print data doc flavor with print data
 1417            * representation class name = <CODE>"java.awt.print.Printable"</CODE>
 1418            * (printable object).
 1419            */
 1420           public static final SERVICE_FORMATTED PRINTABLE =
 1421               new SERVICE_FORMATTED ("java.awt.print.Printable");
 1422   
 1423           /**
 1424            * Service formatted print data doc flavor with print data
 1425            * representation class name = <CODE>"java.awt.print.Pageable"</CODE>
 1426            * (pageable object).
 1427            */
 1428           public static final SERVICE_FORMATTED PAGEABLE =
 1429               new SERVICE_FORMATTED ("java.awt.print.Pageable");
 1430   
 1431           }
 1432   
 1433   }

Home » openjdk-7 » javax » print » [javadoc | source]