src/share/classes/javax/print/DocFlavor.java

Print this page




 364  * choice.
 365  * <P>
 366  * Support for the above doc flavors is desirable so a printing client can rely
 367  * on being able to print on any JPS printer, regardless of which doc flavors
 368  * the printer supports. If the printer doesn't support the client's preferred
 369  * doc flavor, the client can at least print plain text, or the client can
 370  * convert its data to a renderable image and print the image.
 371  * <P>
 372  * Furthermore, every Java Print Service instance must fulfill these
 373  * requirements for processing plain text print data:
 374  * <UL>
 375  * <LI>
 376  * The character pair carriage return-line feed (CR-LF) means
 377  * "go to column 1 of the next line."
 378  * <LI>
 379  * A carriage return (CR) character standing by itself means
 380  * "go to column 1 of the next line."
 381  * <LI>
 382  * A line feed (LF) character standing by itself means
 383  * "go to column 1 of the next line."
 384  * <LI>
 385  * </UL>
 386  * <P>
 387  * The client must itself perform all plain text print data formatting not
 388  * addressed by the above requirements.
 389  *
 390  * <H3>Design Rationale</H3>
 391  * <P>
 392  * Class DocFlavor in package javax.print.data is similar to class
 393  * {@link java.awt.datatransfer.DataFlavor DataFlavor}. Class
 394  * <code>DataFlavor</code>
 395  * is not used in the Java Print Service (JPS) API
 396  * for three reasons which are all rooted in allowing the JPS API to be
 397  * shared by other print services APIs which may need to run on Java profiles
 398  * which do not include all of the Java Platform, Standard Edition.
 399  * <OL TYPE=1>
 400  * <LI>
 401  * The JPS API is designed to be used in Java profiles which do not support
 402  * AWT.
 403  *
 404  * <LI>


 419  * canonical form) may be considered equal.
 420  * <UL>
 421  * <LI> The media type, media subtype, and parameters are retained, but all
 422  *      comments and whitespace characters are discarded.
 423  * <LI> The media type, media subtype, and parameter names are converted to
 424  *      lowercase.
 425  * <LI> The parameter values retain their original case, except a charset
 426  *      parameter value for a text media type is converted to lowercase.
 427  * <LI> Quote characters surrounding parameter values are removed.
 428  * <LI> Quoting backslash characters inside parameter values are removed.
 429  * <LI> The parameters are arranged in ascending order of parameter name.
 430  * </UL>
 431  * <P>
 432  * Class DocFlavor's serialized representation also contains the
 433  * fully-qualified class <I>name</I> of the representation class
 434  * (a String object), rather than the representation class itself
 435  * (a Class object). This allows a client to examine the doc flavors a
 436  * Java Print Service instance supports without having
 437  * to load the representation classes, which may be problematic for
 438  * limited-resource clients.
 439  * <P>
 440  *
 441  * @author  Alan Kaminsky
 442  */
 443 public class DocFlavor implements Serializable, Cloneable {
 444 
 445     private static final long serialVersionUID = -4512080796965449721L;
 446 
 447     /**
 448      * A String representing the host operating system encoding.
 449      * This will follow the conventions documented in
 450      * <a href="http://www.ietf.org/rfc/rfc2278.txt">
 451      * <i>RFC&nbsp;2278:&nbsp;IANA Charset Registration Procedures</i></a>
 452      * except where historical names are returned for compatibility with
 453      * previous versions of the Java platform.
 454      * The value returned from method is valid only for the VM which
 455      * returns it, for use in a DocFlavor.
 456      * This is the charset for all the "HOST" pre-defined DocFlavors in
 457      * the executing VM.
 458      */
 459     public static final String hostEncoding;


 519      */
 520     public String getMediaType() {
 521         return myMimeType.getMediaType();
 522     }
 523 
 524     /**
 525      * Returns this doc flavor object's media subtype (from the MIME type).
 526      * @return the media sub-type
 527      */
 528     public String getMediaSubtype() {
 529         return myMimeType.getMediaSubtype();
 530     }
 531 
 532     /**
 533      * Returns a <code>String</code> representing a MIME
 534      * parameter.
 535      * Mime types may include parameters which are usually optional.
 536      * The charset for text types is a commonly useful example.
 537      * This convenience method will return the value of the specified
 538      * parameter if one was specified in the mime type for this flavor.
 539      * <p>
 540      * @param paramName the name of the paramater. This name is internally
 541      * converted to the canonical lower case format before performing
 542      * the match.
 543      * @return String representing a mime parameter, or
 544      * null if that parameter is not in the mime type string.
 545      * @exception NullPointerException if paramName is null.
 546      */
 547     public String getParameter(String paramName) {
 548         return
 549             (String)myMimeType.getParameterMap().get(paramName.toLowerCase());
 550     }
 551 
 552     /**
 553      * Returns the name of this doc flavor object's representation class.
 554      * @return the name of the representation class.
 555      */
 556     public String getRepresentationClassName() {
 557         return myClassName;
 558     }
 559 


 622 
 623     /**
 624      * Reconstitute an instance from a stream (that is, deserialize it).
 625      *
 626      * @serialData
 627      * The serialised form of a DocFlavor is the String naming the
 628      * representation class followed by the String representing the canonical
 629      * form of the mime type.
 630      */
 631     private void readObject(ObjectInputStream s)
 632         throws ClassNotFoundException, IOException {
 633 
 634         s.defaultReadObject();
 635         myMimeType = new MimeType((String)s.readObject());
 636     }
 637 
 638     /**
 639      * Class DocFlavor.BYTE_ARRAY provides predefined static constant
 640      * DocFlavor objects for example doc flavors using a byte array
 641      * (<CODE>byte[]</CODE>) as the print data representation class.
 642      * <P>
 643      *
 644      * @author  Alan Kaminsky
 645      */
 646     public static class BYTE_ARRAY extends DocFlavor {
 647 
 648         private static final long serialVersionUID = -9065578006593857475L;
 649 
 650         /**
 651          * Constructs a new doc flavor with the given MIME type and a print
 652          * data representation class name of <CODE>"[B"</CODE> (byte array).
 653          *
 654          * @param  mimeType   MIME media type string.
 655          *
 656          * @exception  NullPointerException
 657          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
 658          * @exception  IllegalArgumentException
 659          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
 660          *     obey the syntax for a MIME media type string.
 661          */
 662         public BYTE_ARRAY (String mimeType) {


 820          */
 821         public static final BYTE_ARRAY PNG = new BYTE_ARRAY ("image/png");
 822 
 823         /**
 824          * Doc flavor with MIME type =
 825          * <CODE>"application/octet-stream"</CODE>,
 826          * print data representation class name = <CODE>"[B"</CODE> (byte
 827          * array). The client must determine that data described
 828          * using this DocFlavor is valid for the printer.
 829          */
 830         public static final BYTE_ARRAY AUTOSENSE =
 831             new BYTE_ARRAY ("application/octet-stream");
 832 
 833     }
 834 
 835     /**
 836      * Class DocFlavor.INPUT_STREAM provides predefined static constant
 837      * DocFlavor objects for example doc flavors using a byte stream ({@link
 838      * java.io.InputStream java.io.InputStream}) as the print
 839      * data representation class.
 840      * <P>
 841      *
 842      * @author  Alan Kaminsky
 843      */
 844     public static class INPUT_STREAM extends DocFlavor {
 845 
 846         private static final long serialVersionUID = -7045842700749194127L;
 847 
 848         /**
 849          * Constructs a new doc flavor with the given MIME type and a print
 850          * data representation class name of
 851          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 852          *
 853          * @param  mimeType   MIME media type string.
 854          *
 855          * @exception  NullPointerException
 856          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
 857          * @exception  IllegalArgumentException
 858          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
 859          *     obey the syntax for a MIME media type string.
 860          */


1023 
1024         /**
1025          * Doc flavor with MIME type =
1026          * <CODE>"application/octet-stream"</CODE>,
1027          * print data representation class name =
1028          * <CODE>"java.io.InputStream"</CODE> (byte stream).
1029          * The client must determine that data described
1030          * using this DocFlavor is valid for the printer.
1031          */
1032         public static final INPUT_STREAM AUTOSENSE =
1033             new INPUT_STREAM ("application/octet-stream");
1034 
1035     }
1036 
1037     /**
1038      * Class DocFlavor.URL provides predefined static constant DocFlavor
1039      * objects.
1040      * For example doc flavors using a Uniform Resource Locator ({@link
1041      * java.net.URL java.net.URL}) as the print data
1042      * representation  class.
1043      * <P>
1044      *
1045      * @author  Alan Kaminsky
1046      */
1047     public static class URL extends DocFlavor {
1048         private static final long serialVersionUID = 2936725788144902062L;
1049 
1050         /**
1051          * Constructs a new doc flavor with the given MIME type and a print
1052          * data representation class name of <CODE>"java.net.URL"</CODE>.
1053          *
1054          * @param  mimeType   MIME media type string.
1055          *
1056          * @exception  NullPointerException
1057          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
1058          * @exception  IllegalArgumentException
1059          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
1060          *     obey the syntax for a MIME media type string.
1061          */
1062         public URL (String mimeType) {
1063             super (mimeType, "java.net.URL");


1213          * representation class name = <CODE>"java.net.URL"</CODE>.
1214          */
1215         public static final URL PNG = new URL ("image/png");
1216 
1217         /**
1218          * Doc flavor with MIME type =
1219          * <CODE>"application/octet-stream"</CODE>,
1220          * print data representation class name = <CODE>"java.net.URL"</CODE>.
1221          *  The client must determine that data described
1222          * using this DocFlavor is valid for the printer.
1223          */
1224         public static final URL AUTOSENSE = new URL ("application/octet-stream");
1225 
1226     }
1227 
1228     /**
1229      * Class DocFlavor.CHAR_ARRAY provides predefined static constant
1230      * DocFlavor objects for example doc flavors using a character array
1231      * (<CODE>char[]</CODE>) as the print data representation class. As such,
1232      * the character set is Unicode.
1233      * <P>
1234      *
1235      * @author  Alan Kaminsky
1236      */
1237     public static class CHAR_ARRAY extends DocFlavor {
1238 
1239         private static final long serialVersionUID = -8720590903724405128L;
1240 
1241         /**
1242          * Constructs a new doc flavor with the given MIME type and a print
1243          * data representation class name of
1244          * <CODE>"[C"</CODE> (character array).
1245          *
1246          * @param  mimeType  MIME media type string. If it is a text media
1247          *                      type, it is assumed to contain a
1248          *                      <CODE>"charset=utf-16"</CODE> parameter.
1249          *
1250          * @exception  NullPointerException
1251          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
1252          * @exception  IllegalArgumentException
1253          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not


1263          * <CODE>"[C"</CODE> (character array).
1264          */
1265         public static final CHAR_ARRAY TEXT_PLAIN =
1266             new CHAR_ARRAY ("text/plain; charset=utf-16");
1267 
1268         /**
1269          * Doc flavor with MIME type = <CODE>"text/html;
1270          * charset=utf-16"</CODE>, print data representation class name =
1271          * <CODE>"[C"</CODE> (character array).
1272          */
1273         public static final CHAR_ARRAY TEXT_HTML =
1274             new CHAR_ARRAY ("text/html; charset=utf-16");
1275 
1276     }
1277 
1278     /**
1279      * Class DocFlavor.STRING provides predefined static constant DocFlavor
1280      * objects for example doc flavors using a string ({@link java.lang.String
1281      * java.lang.String}) as the print data representation class.
1282      * As such, the character set is Unicode.
1283      * <P>
1284      *
1285      * @author  Alan Kaminsky
1286      */
1287     public static class STRING extends DocFlavor {
1288 
1289         private static final long serialVersionUID = 4414407504887034035L;
1290 
1291         /**
1292          * Constructs a new doc flavor with the given MIME type and a print
1293          * data representation class name of <CODE>"java.lang.String"</CODE>.
1294          *
1295          * @param  mimeType  MIME media type string. If it is a text media
1296          *                      type, it is assumed to contain a
1297          *                      <CODE>"charset=utf-16"</CODE> parameter.
1298          *
1299          * @exception  NullPointerException
1300          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
1301          * @exception  IllegalArgumentException
1302          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
1303          *     obey the syntax for a MIME media type string.


1311          * charset=utf-16"</CODE>, print data representation class name =
1312          * <CODE>"java.lang.String"</CODE>.
1313          */
1314         public static final STRING TEXT_PLAIN =
1315             new STRING ("text/plain; charset=utf-16");
1316 
1317         /**
1318          * Doc flavor with MIME type = <CODE>"text/html;
1319          * charset=utf-16"</CODE>, print data representation class name =
1320          * <CODE>"java.lang.String"</CODE>.
1321          */
1322         public static final STRING TEXT_HTML =
1323             new STRING ("text/html; charset=utf-16");
1324     }
1325 
1326     /**
1327      * Class DocFlavor.READER provides predefined static constant DocFlavor
1328      * objects for example doc flavors using a character stream ({@link
1329      * java.io.Reader java.io.Reader}) as the print data
1330      * representation class. As such, the character set is Unicode.
1331      * <P>
1332      *
1333      * @author  Alan Kaminsky
1334      */
1335     public static class READER extends DocFlavor {
1336 
1337         private static final long serialVersionUID = 7100295812579351567L;
1338 
1339         /**
1340          * Constructs a new doc flavor with the given MIME type and a print
1341          * data representation class name of\
1342          * <CODE>"java.io.Reader"</CODE> (character stream).
1343          *
1344          * @param  mimeType  MIME media type string. If it is a text media
1345          *                      type, it is assumed to contain a
1346          *                      <CODE>"charset=utf-16"</CODE> parameter.
1347          *
1348          * @exception  NullPointerException
1349          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
1350          * @exception  IllegalArgumentException
1351          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not


1360          * charset=utf-16"</CODE>, print data representation class name =
1361          * <CODE>"java.io.Reader"</CODE> (character stream).
1362          */
1363         public static final READER TEXT_PLAIN =
1364             new READER ("text/plain; charset=utf-16");
1365 
1366         /**
1367          * Doc flavor with MIME type = <CODE>"text/html;
1368          * charset=utf-16"</CODE>, print data representation class name =
1369          * <CODE>"java.io.Reader"</CODE> (character stream).
1370          */
1371         public static final READER TEXT_HTML =
1372             new READER ("text/html; charset=utf-16");
1373 
1374     }
1375 
1376     /**
1377      * Class DocFlavor.SERVICE_FORMATTED provides predefined static constant
1378      * DocFlavor objects for example doc flavors for service formatted print
1379      * data.
1380      * <P>
1381      *
1382      * @author  Alan Kaminsky
1383      */
1384     public static class SERVICE_FORMATTED extends DocFlavor {
1385 
1386         private static final long serialVersionUID = 6181337766266637256L;
1387 
1388         /**
1389          * Constructs a new doc flavor with a MIME type of
1390          * <CODE>"application/x-java-jvm-local-objectref"</CODE> indicating
1391          * service formatted print data and the given print data
1392          * representation class name.
1393          *
1394          * @param  className  Fully-qualified representation class name.
1395          *
1396          * @exception  NullPointerException
1397          *     (unchecked exception) Thrown if <CODE>className</CODE> is
1398          *     null.
1399          */
1400         public SERVICE_FORMATTED (String className) {




 364  * choice.
 365  * <P>
 366  * Support for the above doc flavors is desirable so a printing client can rely
 367  * on being able to print on any JPS printer, regardless of which doc flavors
 368  * the printer supports. If the printer doesn't support the client's preferred
 369  * doc flavor, the client can at least print plain text, or the client can
 370  * convert its data to a renderable image and print the image.
 371  * <P>
 372  * Furthermore, every Java Print Service instance must fulfill these
 373  * requirements for processing plain text print data:
 374  * <UL>
 375  * <LI>
 376  * The character pair carriage return-line feed (CR-LF) means
 377  * "go to column 1 of the next line."
 378  * <LI>
 379  * A carriage return (CR) character standing by itself means
 380  * "go to column 1 of the next line."
 381  * <LI>
 382  * A line feed (LF) character standing by itself means
 383  * "go to column 1 of the next line."

 384  * </UL>
 385  * <P>
 386  * The client must itself perform all plain text print data formatting not
 387  * addressed by the above requirements.
 388  *
 389  * <H3>Design Rationale</H3>
 390  * <P>
 391  * Class DocFlavor in package javax.print.data is similar to class
 392  * {@link java.awt.datatransfer.DataFlavor DataFlavor}. Class
 393  * <code>DataFlavor</code>
 394  * is not used in the Java Print Service (JPS) API
 395  * for three reasons which are all rooted in allowing the JPS API to be
 396  * shared by other print services APIs which may need to run on Java profiles
 397  * which do not include all of the Java Platform, Standard Edition.
 398  * <OL TYPE=1>
 399  * <LI>
 400  * The JPS API is designed to be used in Java profiles which do not support
 401  * AWT.
 402  *
 403  * <LI>


 418  * canonical form) may be considered equal.
 419  * <UL>
 420  * <LI> The media type, media subtype, and parameters are retained, but all
 421  *      comments and whitespace characters are discarded.
 422  * <LI> The media type, media subtype, and parameter names are converted to
 423  *      lowercase.
 424  * <LI> The parameter values retain their original case, except a charset
 425  *      parameter value for a text media type is converted to lowercase.
 426  * <LI> Quote characters surrounding parameter values are removed.
 427  * <LI> Quoting backslash characters inside parameter values are removed.
 428  * <LI> The parameters are arranged in ascending order of parameter name.
 429  * </UL>
 430  * <P>
 431  * Class DocFlavor's serialized representation also contains the
 432  * fully-qualified class <I>name</I> of the representation class
 433  * (a String object), rather than the representation class itself
 434  * (a Class object). This allows a client to examine the doc flavors a
 435  * Java Print Service instance supports without having
 436  * to load the representation classes, which may be problematic for
 437  * limited-resource clients.

 438  *
 439  * @author  Alan Kaminsky
 440  */
 441 public class DocFlavor implements Serializable, Cloneable {
 442 
 443     private static final long serialVersionUID = -4512080796965449721L;
 444 
 445     /**
 446      * A String representing the host operating system encoding.
 447      * This will follow the conventions documented in
 448      * <a href="http://www.ietf.org/rfc/rfc2278.txt">
 449      * <i>RFC&nbsp;2278:&nbsp;IANA Charset Registration Procedures</i></a>
 450      * except where historical names are returned for compatibility with
 451      * previous versions of the Java platform.
 452      * The value returned from method is valid only for the VM which
 453      * returns it, for use in a DocFlavor.
 454      * This is the charset for all the "HOST" pre-defined DocFlavors in
 455      * the executing VM.
 456      */
 457     public static final String hostEncoding;


 517      */
 518     public String getMediaType() {
 519         return myMimeType.getMediaType();
 520     }
 521 
 522     /**
 523      * Returns this doc flavor object's media subtype (from the MIME type).
 524      * @return the media sub-type
 525      */
 526     public String getMediaSubtype() {
 527         return myMimeType.getMediaSubtype();
 528     }
 529 
 530     /**
 531      * Returns a <code>String</code> representing a MIME
 532      * parameter.
 533      * Mime types may include parameters which are usually optional.
 534      * The charset for text types is a commonly useful example.
 535      * This convenience method will return the value of the specified
 536      * parameter if one was specified in the mime type for this flavor.
 537      *
 538      * @param paramName the name of the paramater. This name is internally
 539      * converted to the canonical lower case format before performing
 540      * the match.
 541      * @return String representing a mime parameter, or
 542      * null if that parameter is not in the mime type string.
 543      * @exception NullPointerException if paramName is null.
 544      */
 545     public String getParameter(String paramName) {
 546         return
 547             (String)myMimeType.getParameterMap().get(paramName.toLowerCase());
 548     }
 549 
 550     /**
 551      * Returns the name of this doc flavor object's representation class.
 552      * @return the name of the representation class.
 553      */
 554     public String getRepresentationClassName() {
 555         return myClassName;
 556     }
 557 


 620 
 621     /**
 622      * Reconstitute an instance from a stream (that is, deserialize it).
 623      *
 624      * @serialData
 625      * The serialised form of a DocFlavor is the String naming the
 626      * representation class followed by the String representing the canonical
 627      * form of the mime type.
 628      */
 629     private void readObject(ObjectInputStream s)
 630         throws ClassNotFoundException, IOException {
 631 
 632         s.defaultReadObject();
 633         myMimeType = new MimeType((String)s.readObject());
 634     }
 635 
 636     /**
 637      * Class DocFlavor.BYTE_ARRAY provides predefined static constant
 638      * DocFlavor objects for example doc flavors using a byte array
 639      * (<CODE>byte[]</CODE>) as the print data representation class.

 640      *
 641      * @author  Alan Kaminsky
 642      */
 643     public static class BYTE_ARRAY extends DocFlavor {
 644 
 645         private static final long serialVersionUID = -9065578006593857475L;
 646 
 647         /**
 648          * Constructs a new doc flavor with the given MIME type and a print
 649          * data representation class name of <CODE>"[B"</CODE> (byte array).
 650          *
 651          * @param  mimeType   MIME media type string.
 652          *
 653          * @exception  NullPointerException
 654          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
 655          * @exception  IllegalArgumentException
 656          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
 657          *     obey the syntax for a MIME media type string.
 658          */
 659         public BYTE_ARRAY (String mimeType) {


 817          */
 818         public static final BYTE_ARRAY PNG = new BYTE_ARRAY ("image/png");
 819 
 820         /**
 821          * Doc flavor with MIME type =
 822          * <CODE>"application/octet-stream"</CODE>,
 823          * print data representation class name = <CODE>"[B"</CODE> (byte
 824          * array). The client must determine that data described
 825          * using this DocFlavor is valid for the printer.
 826          */
 827         public static final BYTE_ARRAY AUTOSENSE =
 828             new BYTE_ARRAY ("application/octet-stream");
 829 
 830     }
 831 
 832     /**
 833      * Class DocFlavor.INPUT_STREAM provides predefined static constant
 834      * DocFlavor objects for example doc flavors using a byte stream ({@link
 835      * java.io.InputStream java.io.InputStream}) as the print
 836      * data representation class.

 837      *
 838      * @author  Alan Kaminsky
 839      */
 840     public static class INPUT_STREAM extends DocFlavor {
 841 
 842         private static final long serialVersionUID = -7045842700749194127L;
 843 
 844         /**
 845          * Constructs a new doc flavor with the given MIME type and a print
 846          * data representation class name of
 847          * <CODE>"java.io.InputStream"</CODE> (byte stream).
 848          *
 849          * @param  mimeType   MIME media type string.
 850          *
 851          * @exception  NullPointerException
 852          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
 853          * @exception  IllegalArgumentException
 854          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
 855          *     obey the syntax for a MIME media type string.
 856          */


1019 
1020         /**
1021          * Doc flavor with MIME type =
1022          * <CODE>"application/octet-stream"</CODE>,
1023          * print data representation class name =
1024          * <CODE>"java.io.InputStream"</CODE> (byte stream).
1025          * The client must determine that data described
1026          * using this DocFlavor is valid for the printer.
1027          */
1028         public static final INPUT_STREAM AUTOSENSE =
1029             new INPUT_STREAM ("application/octet-stream");
1030 
1031     }
1032 
1033     /**
1034      * Class DocFlavor.URL provides predefined static constant DocFlavor
1035      * objects.
1036      * For example doc flavors using a Uniform Resource Locator ({@link
1037      * java.net.URL java.net.URL}) as the print data
1038      * representation  class.

1039      *
1040      * @author  Alan Kaminsky
1041      */
1042     public static class URL extends DocFlavor {
1043         private static final long serialVersionUID = 2936725788144902062L;
1044 
1045         /**
1046          * Constructs a new doc flavor with the given MIME type and a print
1047          * data representation class name of <CODE>"java.net.URL"</CODE>.
1048          *
1049          * @param  mimeType   MIME media type string.
1050          *
1051          * @exception  NullPointerException
1052          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
1053          * @exception  IllegalArgumentException
1054          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
1055          *     obey the syntax for a MIME media type string.
1056          */
1057         public URL (String mimeType) {
1058             super (mimeType, "java.net.URL");


1208          * representation class name = <CODE>"java.net.URL"</CODE>.
1209          */
1210         public static final URL PNG = new URL ("image/png");
1211 
1212         /**
1213          * Doc flavor with MIME type =
1214          * <CODE>"application/octet-stream"</CODE>,
1215          * print data representation class name = <CODE>"java.net.URL"</CODE>.
1216          *  The client must determine that data described
1217          * using this DocFlavor is valid for the printer.
1218          */
1219         public static final URL AUTOSENSE = new URL ("application/octet-stream");
1220 
1221     }
1222 
1223     /**
1224      * Class DocFlavor.CHAR_ARRAY provides predefined static constant
1225      * DocFlavor objects for example doc flavors using a character array
1226      * (<CODE>char[]</CODE>) as the print data representation class. As such,
1227      * the character set is Unicode.

1228      *
1229      * @author  Alan Kaminsky
1230      */
1231     public static class CHAR_ARRAY extends DocFlavor {
1232 
1233         private static final long serialVersionUID = -8720590903724405128L;
1234 
1235         /**
1236          * Constructs a new doc flavor with the given MIME type and a print
1237          * data representation class name of
1238          * <CODE>"[C"</CODE> (character array).
1239          *
1240          * @param  mimeType  MIME media type string. If it is a text media
1241          *                      type, it is assumed to contain a
1242          *                      <CODE>"charset=utf-16"</CODE> parameter.
1243          *
1244          * @exception  NullPointerException
1245          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
1246          * @exception  IllegalArgumentException
1247          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not


1257          * <CODE>"[C"</CODE> (character array).
1258          */
1259         public static final CHAR_ARRAY TEXT_PLAIN =
1260             new CHAR_ARRAY ("text/plain; charset=utf-16");
1261 
1262         /**
1263          * Doc flavor with MIME type = <CODE>"text/html;
1264          * charset=utf-16"</CODE>, print data representation class name =
1265          * <CODE>"[C"</CODE> (character array).
1266          */
1267         public static final CHAR_ARRAY TEXT_HTML =
1268             new CHAR_ARRAY ("text/html; charset=utf-16");
1269 
1270     }
1271 
1272     /**
1273      * Class DocFlavor.STRING provides predefined static constant DocFlavor
1274      * objects for example doc flavors using a string ({@link java.lang.String
1275      * java.lang.String}) as the print data representation class.
1276      * As such, the character set is Unicode.

1277      *
1278      * @author  Alan Kaminsky
1279      */
1280     public static class STRING extends DocFlavor {
1281 
1282         private static final long serialVersionUID = 4414407504887034035L;
1283 
1284         /**
1285          * Constructs a new doc flavor with the given MIME type and a print
1286          * data representation class name of <CODE>"java.lang.String"</CODE>.
1287          *
1288          * @param  mimeType  MIME media type string. If it is a text media
1289          *                      type, it is assumed to contain a
1290          *                      <CODE>"charset=utf-16"</CODE> parameter.
1291          *
1292          * @exception  NullPointerException
1293          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
1294          * @exception  IllegalArgumentException
1295          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
1296          *     obey the syntax for a MIME media type string.


1304          * charset=utf-16"</CODE>, print data representation class name =
1305          * <CODE>"java.lang.String"</CODE>.
1306          */
1307         public static final STRING TEXT_PLAIN =
1308             new STRING ("text/plain; charset=utf-16");
1309 
1310         /**
1311          * Doc flavor with MIME type = <CODE>"text/html;
1312          * charset=utf-16"</CODE>, print data representation class name =
1313          * <CODE>"java.lang.String"</CODE>.
1314          */
1315         public static final STRING TEXT_HTML =
1316             new STRING ("text/html; charset=utf-16");
1317     }
1318 
1319     /**
1320      * Class DocFlavor.READER provides predefined static constant DocFlavor
1321      * objects for example doc flavors using a character stream ({@link
1322      * java.io.Reader java.io.Reader}) as the print data
1323      * representation class. As such, the character set is Unicode.

1324      *
1325      * @author  Alan Kaminsky
1326      */
1327     public static class READER extends DocFlavor {
1328 
1329         private static final long serialVersionUID = 7100295812579351567L;
1330 
1331         /**
1332          * Constructs a new doc flavor with the given MIME type and a print
1333          * data representation class name of\
1334          * <CODE>"java.io.Reader"</CODE> (character stream).
1335          *
1336          * @param  mimeType  MIME media type string. If it is a text media
1337          *                      type, it is assumed to contain a
1338          *                      <CODE>"charset=utf-16"</CODE> parameter.
1339          *
1340          * @exception  NullPointerException
1341          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> is null.
1342          * @exception  IllegalArgumentException
1343          *     (unchecked exception) Thrown if <CODE>mimeType</CODE> does not


1352          * charset=utf-16"</CODE>, print data representation class name =
1353          * <CODE>"java.io.Reader"</CODE> (character stream).
1354          */
1355         public static final READER TEXT_PLAIN =
1356             new READER ("text/plain; charset=utf-16");
1357 
1358         /**
1359          * Doc flavor with MIME type = <CODE>"text/html;
1360          * charset=utf-16"</CODE>, print data representation class name =
1361          * <CODE>"java.io.Reader"</CODE> (character stream).
1362          */
1363         public static final READER TEXT_HTML =
1364             new READER ("text/html; charset=utf-16");
1365 
1366     }
1367 
1368     /**
1369      * Class DocFlavor.SERVICE_FORMATTED provides predefined static constant
1370      * DocFlavor objects for example doc flavors for service formatted print
1371      * data.

1372      *
1373      * @author  Alan Kaminsky
1374      */
1375     public static class SERVICE_FORMATTED extends DocFlavor {
1376 
1377         private static final long serialVersionUID = 6181337766266637256L;
1378 
1379         /**
1380          * Constructs a new doc flavor with a MIME type of
1381          * <CODE>"application/x-java-jvm-local-objectref"</CODE> indicating
1382          * service formatted print data and the given print data
1383          * representation class name.
1384          *
1385          * @param  className  Fully-qualified representation class name.
1386          *
1387          * @exception  NullPointerException
1388          *     (unchecked exception) Thrown if <CODE>className</CODE> is
1389          *     null.
1390          */
1391         public SERVICE_FORMATTED (String className) {