jdk/src/share/classes/javax/print/DocFlavor.java
changeset 22260 c9185e010e03
parent 21278 ef8a3a2a72f2
child 22584 eed64ee05369
equal deleted inserted replaced
22259:8e5afc67dca8 22260:c9185e010e03
     1 /*
     1 /*
     2  * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    47  * historical names supported by earlier versions of the Java platform may
    47  * historical names supported by earlier versions of the Java platform may
    48  * be recognized.
    48  * be recognized.
    49  * See <a href="../../java/lang/package-summary.html#charenc">
    49  * See <a href="../../java/lang/package-summary.html#charenc">
    50  * character encodings</a> for more information on the character encodings
    50  * character encodings</a> for more information on the character encodings
    51  * supported on the Java platform.
    51  * supported on the Java platform.
    52  * <P>
    52  *
    53  * <LI>
    53  * <LI>
    54  * <B>Representation class name.</B> This specifies the fully-qualified name of
    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
    55  * the class of the object from which the actual print data comes, as returned
    56  * by the {@link java.lang.Class#getName() Class.getName()} method.
    56  * by the {@link java.lang.Class#getName() Class.getName()} method.
    57  * (Thus the class name for <CODE>byte[]</CODE> is <CODE>"[B"</CODE>, for
    57  * (Thus the class name for <CODE>byte[]</CODE> is <CODE>"[B"</CODE>, for
    62  * {@link Doc Doc}. A <code>Doc</code> object lets the <code>DocPrintJob</code>
    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
    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
    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
    65  * representation class, from which the <code>DocPrintJob</code> then obtains
    66  * the actual print data.
    66  * the actual print data.
    67  * <P>
    67  *
    68  * <HR>
    68  * <HR>
    69  * <H3>Client Formatted Print Data</H3>
    69  * <H3>Client Formatted Print Data</H3>
    70  * There are two broad categories of print data, client formatted print data
    70  * There are two broad categories of print data, client formatted print data
    71  * and service formatted print data.
    71  * and service formatted print data.
    72  * <P>
    72  * <P>
    94  * permitted):
    94  * permitted):
    95  * <UL>
    95  * <UL>
    96  * <LI>
    96  * <LI>
    97  * Character array (<CODE>char[]</CODE>) -- The print data consists of the
    97  * Character array (<CODE>char[]</CODE>) -- The print data consists of the
    98  * Unicode characters in the array.
    98  * Unicode characters in the array.
    99  * <P>
    99  *
   100  * <LI>
   100  * <LI>
   101  * <code>String</code>  --
   101  * <code>String</code>  --
   102  * The print data consists of the Unicode characters in the string.
   102  * The print data consists of the Unicode characters in the string.
   103  * <P>
   103  *
   104  * <LI>
   104  * <LI>
   105  * Character stream ({@link java.io.Reader java.io.Reader})
   105  * Character stream ({@link java.io.Reader java.io.Reader})
   106  * -- The print data consists of the Unicode characters read from the stream
   106  * -- The print data consists of the Unicode characters read from the stream
   107  * up to the end-of-stream.
   107  * up to the end-of-stream.
   108  * <P>
   108  *
   109  * <LI>
   109  * <LI>
   110  * Byte array (<CODE>byte[]</CODE>) -- The print data consists of the bytes in
   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
   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
   112  * flavor's MIME type. If the MIME type does not specify a character set, the
   113  * default character set is US-ASCII.
   113  * default character set is US-ASCII.
   114  * <P>
   114  *
   115  * <LI>
   115  * <LI>
   116  * Byte stream ({@link java.io.InputStream java.io.InputStream}) --
   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
   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
   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,
   119  * doc flavor's MIME type. If the MIME type does not specify a character set,
   137  * accessible independently of the client.
   137  * accessible independently of the client.
   138  * For example, a file that is not served up by an HTTP server or FTP server.
   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
   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.
   140  * or file and use an input stream data flavor.
   141  * </UL>
   141  * </UL>
   142  * <p>
   142  *
   143  * <HR>
   143  * <HR>
   144  * <h3>Default and Platform Encodings</h3>
   144  * <h3>Default and Platform Encodings</h3>
   145  * <P>
   145  * <P>
   146  * For byte print data where the doc flavor's MIME type does not include a
   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
   147  * <CODE>charset</CODE> parameter, the Java Print Service instance assumes the
   177  * from {@link DocFlavor#hostEncoding DocFlavor.hostEncoding}
   177  * from {@link DocFlavor#hostEncoding DocFlavor.hostEncoding}
   178  * This may not always be the primary IANA name but is guaranteed to be
   178  * This may not always be the primary IANA name but is guaranteed to be
   179  * understood by this VM.
   179  * understood by this VM.
   180  * For common flavors, the pre-defined *HOST DocFlavors may be used.
   180  * For common flavors, the pre-defined *HOST DocFlavors may be used.
   181  * <p>
   181  * <p>
   182  * <p>
       
   183  * See <a href="../../java/lang/package-summary.html#charenc">
   182  * See <a href="../../java/lang/package-summary.html#charenc">
   184  * character encodings</a> for more information on the character encodings
   183  * character encodings</a> for more information on the character encodings
   185  * supported on the Java platform.
   184  * supported on the Java platform.
   186  * <p>
       
   187  * <HR>
   185  * <HR>
   188  * <h3>Recommended DocFlavors</h3>
   186  * <h3>Recommended DocFlavors</h3>
   189  * <P>
   187  * <P>
   190  * The Java Print Service API does not define any mandatorily supported
   188  * The Java Print Service API does not define any mandatorily supported
   191  * DocFlavors.
   189  * DocFlavors.
   194  * Nested classes inside class DocFlavor declare predefined static
   192  * Nested classes inside class DocFlavor declare predefined static
   195  * constant DocFlavor objects for these example doc flavors; class DocFlavor's
   193  * constant DocFlavor objects for these example doc flavors; class DocFlavor's
   196  * constructor can be used to create an arbitrary doc flavor.
   194  * constructor can be used to create an arbitrary doc flavor.
   197  * <UL>
   195  * <UL>
   198  * <LI>Preformatted text
   196  * <LI>Preformatted text
   199  * <P>
       
   200  * <TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 SUMMARY="MIME-Types and their descriptions">
   197  * <TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 SUMMARY="MIME-Types and their descriptions">
   201  * <TR>
   198  * <TR>
   202  *  <TH>MIME-Type</TH><TH>Description</TH>
   199  *  <TH>MIME-Type</TH><TH>Description</TH>
   203  * </TR>
   200  * </TR>
   204  * <TR>
   201  * <TR>
   220  * </TABLE>
   217  * </TABLE>
   221  * <P>
   218  * <P>
   222  * In general, preformatted text print data is provided either in a character
   219  * In general, preformatted text print data is provided either in a character
   223  * oriented representation class (character array, String, Reader) or in a
   220  * oriented representation class (character array, String, Reader) or in a
   224  * byte oriented representation class (byte array, InputStream, URL).
   221  * byte oriented representation class (byte array, InputStream, URL).
   225  * <P>
   222  *
   226  *  <LI>Preformatted page description language (PDL) documents
   223  *  <LI>Preformatted page description language (PDL) documents
   227  *<P>
   224  *
   228  * <TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 SUMMARY="MIME-Types and their descriptions">
   225  * <TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 SUMMARY="MIME-Types and their descriptions">
   229  * <TR>
   226  * <TR>
   230  *  <TH>MIME-Type</TH><TH>Description</TH>
   227  *  <TH>MIME-Type</TH><TH>Description</TH>
   231  * </TR>
   228  * </TR>
   232  *<TR>
   229  *<TR>
   243  * </TR>
   240  * </TR>
   244  * </TABLE>
   241  * </TABLE>
   245  * <P>
   242  * <P>
   246  * In general, preformatted PDL print data is provided in a byte oriented
   243  * In general, preformatted PDL print data is provided in a byte oriented
   247  * representation class (byte array, InputStream, URL).
   244  * representation class (byte array, InputStream, URL).
   248  * <P>
   245  *
   249  *  <LI>Preformatted images
   246  *  <LI>Preformatted images
   250  *<P>
   247  *
   251  * <TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 SUMMARY="MIME-Types and their descriptions">
   248  * <TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 SUMMARY="MIME-Types and their descriptions">
   252  * <TR>
   249  * <TR>
   253  *  <TH>MIME-Type</TH><TH>Description</TH>
   250  *  <TH>MIME-Type</TH><TH>Description</TH>
   254  * </TR>
   251  * </TR>
   255  *
   252  *
   267  * </TR>
   264  * </TR>
   268  * </TABLE>
   265  * </TABLE>
   269  * <P>
   266  * <P>
   270  * In general, preformatted image print data is provided in a byte oriented
   267  * In general, preformatted image print data is provided in a byte oriented
   271  * representation class (byte array, InputStream, URL).
   268  * representation class (byte array, InputStream, URL).
   272  * <P>
   269  *
   273  *  <LI>Preformatted autosense print data
   270  *  <LI>Preformatted autosense print data
   274  *   <P>
   271  *
   275  * <TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 SUMMARY="MIME-Types and their descriptions">
   272  * <TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 SUMMARY="MIME-Types and their descriptions">
   276  * <TR>
   273  * <TR>
   277  *  <TH>MIME-Type</TH><TH>Description</TH>
   274  *  <TH>MIME-Type</TH><TH>Description</TH>
   278  * </TR>
   275  * </TR>
   279  *
   276  *
   285  * The printer decides how to interpret the print data; the way this
   282  * The printer decides how to interpret the print data; the way this
   286  * "autosensing" works is implementation dependent. In general, preformatted
   283  * "autosensing" works is implementation dependent. In general, preformatted
   287  * autosense print data is provided in a byte oriented representation class
   284  * autosense print data is provided in a byte oriented representation class
   288  * (byte array, InputStream, URL).
   285  * (byte array, InputStream, URL).
   289  * </UL>
   286  * </UL>
   290  * <P>
   287  *
   291  * <HR>
   288  * <HR>
   292  * <H3>Service Formatted Print Data</H3>
   289  * <H3>Service Formatted Print Data</H3>
   293  * <P>
   290  * <P>
   294  * For <B>service formatted print data</B>, the Java Print Service instance
   291  * For <B>service formatted print data</B>, the Java Print Service instance
   295  * determines the print data format. The doc flavor's representation class
   292  * determines the print data format. The doc flavor's representation class
   313  * Renderable image object -- The client supplies an object that implements
   310  * Renderable image object -- The client supplies an object that implements
   314  * interface
   311  * interface
   315  * {@link java.awt.image.renderable.RenderableImage RenderableImage}. The
   312  * {@link java.awt.image.renderable.RenderableImage RenderableImage}. The
   316  * printer calls methods
   313  * printer calls methods
   317  * in that interface to obtain the image to be printed.
   314  * in that interface to obtain the image to be printed.
   318  * <P>
   315  *
   319  * <LI>
   316  * <LI>
   320  * Printable object -- The client supplies an object that implements interface
   317  * Printable object -- The client supplies an object that implements interface
   321  * {@link java.awt.print.Printable Printable}.
   318  * {@link java.awt.print.Printable Printable}.
   322  * The printer calls methods in that interface to obtain the pages to be
   319  * The printer calls methods in that interface to obtain the pages to be
   323  * printed, one by one.
   320  * printed, one by one.
   324  * For each page, the printer supplies a graphics context, and whatever the
   321  * For each page, the printer supplies a graphics context, and whatever the
   325  * client draws in that graphics context gets printed.
   322  * client draws in that graphics context gets printed.
   326  * <P>
   323  *
   327  * <LI>
   324  * <LI>
   328  * Pageable object -- The client supplies an object that implements interface
   325  * Pageable object -- The client supplies an object that implements interface
   329  * {@link java.awt.print.Pageable Pageable}. The printer calls
   326  * {@link java.awt.print.Pageable Pageable}. The printer calls
   330  * methods in that interface to obtain the pages to be printed, one by one.
   327  * 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
   328  * For each page, the printer supplies a graphics context, and whatever
   332  * the client draws in that graphics context gets printed.
   329  * the client draws in that graphics context gets printed.
   333  * </UL>
   330  * </UL>
   334  * <P>
   331  *
   335  * <HR>
   332  * <HR>
   336  * <P>
   333  *
   337  * <HR>
   334  * <HR>
   338  * <H3>Pre-defined Doc Flavors</H3>
   335  * <H3>Pre-defined Doc Flavors</H3>
   339  * A Java Print Service instance is not <B><I>required</I></B> to support the
   336  * 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
   337  * following print data formats and print data representation classes.  In
   341  * fact, a developer using this class should <b>never</b> assume that a
   338  * fact, a developer using this class should <b>never</b> assume that a
   352  * <CODE>("text/plain", "java.io.InputStream")</CODE>
   349  * <CODE>("text/plain", "java.io.InputStream")</CODE>
   353  * <BR>&#183;&nbsp;&nbsp;
   350  * <BR>&#183;&nbsp;&nbsp;
   354  * <CODE>("text/plain; charset=us-ascii", "java.io.InputStream")</CODE>
   351  * <CODE>("text/plain; charset=us-ascii", "java.io.InputStream")</CODE>
   355  * <BR>&#183;&nbsp;&nbsp;
   352  * <BR>&#183;&nbsp;&nbsp;
   356  * <CODE>("text/plain; charset=utf-8", "java.io.InputStream")</CODE>
   353  * <CODE>("text/plain; charset=utf-8", "java.io.InputStream")</CODE>
   357  * <P>
   354  *
   358  * <LI>
   355  * <LI>
   359  * Renderable image objects. Specifically, the following doc flavor is
   356  * Renderable image objects. Specifically, the following doc flavor is
   360  * recommended to be supported:
   357  * recommended to be supported:
   361  * <BR>&#183;&nbsp;&nbsp;
   358  * <BR>&#183;&nbsp;&nbsp;
   362  * <CODE>("application/x-java-jvm-local-objectref", "java.awt.image.renderable.RenderableImage")</CODE>
   359  * <CODE>("application/x-java-jvm-local-objectref", "java.awt.image.renderable.RenderableImage")</CODE>
   387  * <LI>
   384  * <LI>
   388  * </UL>
   385  * </UL>
   389  * <P>
   386  * <P>
   390  * The client must itself perform all plain text print data formatting not
   387  * The client must itself perform all plain text print data formatting not
   391  * addressed by the above requirements.
   388  * addressed by the above requirements.
   392  * <P>
   389  *
   393  * <H3>Design Rationale</H3>
   390  * <H3>Design Rationale</H3>
   394  * <P>
   391  * <P>
   395  * Class DocFlavor in package javax.print.data is similar to class
   392  * Class DocFlavor in package javax.print.data is similar to class
   396  * {@link java.awt.datatransfer.DataFlavor DataFlavor}. Class
   393  * {@link java.awt.datatransfer.DataFlavor DataFlavor}. Class
   397  * <code>DataFlavor</code>
   394  * <code>DataFlavor</code>
   401  * which do not include all of the Java Platform, Standard Edition.
   398  * which do not include all of the Java Platform, Standard Edition.
   402  * <OL TYPE=1>
   399  * <OL TYPE=1>
   403  * <LI>
   400  * <LI>
   404  * The JPS API is designed to be used in Java profiles which do not support
   401  * The JPS API is designed to be used in Java profiles which do not support
   405  * AWT.
   402  * AWT.
   406  * <P>
   403  *
   407  * <LI>
   404  * <LI>
   408  * The implementation of class <code>java.awt.datatransfer.DataFlavor</code>
   405  * The implementation of class <code>java.awt.datatransfer.DataFlavor</code>
   409  * does not guarantee that equivalent data flavors will have the same
   406  * does not guarantee that equivalent data flavors will have the same
   410  * serialized representation. DocFlavor does, and can be used in services
   407  * serialized representation. DocFlavor does, and can be used in services
   411  * which need this.
   408  * which need this.
   412  * <P>
   409  *
   413  * <LI>
   410  * <LI>
   414  * The implementation of class <code>java.awt.datatransfer.DataFlavor</code>
   411  * The implementation of class <code>java.awt.datatransfer.DataFlavor</code>
   415  * includes a human presentable name as part of the serialized representation.
   412  * includes a human presentable name as part of the serialized representation.
   416  * This is not appropriate as part of a service matching constraint.
   413  * This is not appropriate as part of a service matching constraint.
   417  * </OL>
   414  * </OL>