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

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