|
Préférences
Moteurs de recherche
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
JavaTM 2 Platform Std. Ed. v1.5.0
javax.print
|
MIME-Type | Description |
---|---|
"text/plain" |
Plain text in the default character set (US-ASCII) |
"text/plain; charset=xxx" |
Plain text in character set xxx |
"text/html" |
HyperText Markup Language in the default character set (US-ASCII) |
"text/html; charset=xxx" |
HyperText Markup Language in character set xxx |
In general, preformatted text print data is provided either in a character oriented representation class (character array, String, Reader) or in a byte oriented representation class (byte array, InputStream, URL).
MIME-Type | Description |
---|---|
"application/pdf" |
Portable Document Format document |
"application/postscript" |
PostScript document |
"application/vnd.hp-PCL" |
Printer Control Language document |
In general, preformatted PDL print data is provided in a byte oriented representation class (byte array, InputStream, URL).
MIME-Type | Description |
---|---|
"image/gif" |
Graphics Interchange Format image |
"image/jpeg" |
Joint Photographic Experts Group image |
"image/png" |
Portable Network Graphics image |
In general, preformatted image print data is provided in a byte oriented representation class (byte array, InputStream, URL).
MIME-Type | Description |
---|---|
"application/octet-stream" |
The print data format is unspecified (just an octet stream) |
The printer decides how to interpret the print data; the way this "autosensing" works is implementation dependent. In general, preformatted autosense print data is provided in a byte oriented representation class (byte array, InputStream, URL).
For service formatted print data, the Java Print Service instance
determines the print data format. The doc flavor's representation class
denotes an interface whose methods the DocPrintJob
invokes to
determine the content to be printed -- such as a renderable image
interface or a Java 2 printable interface.
The doc flavor's MIME type is the special value
"application/x-java-jvm-local-objectref"
indicating the client
will supply a reference to a Java object that implements the interface
named as the representation class.
This MIME type is just a placeholder; what's
important is the print data representation class.
For service formatted print data, the print data representation class is typically one of the following (although other representation classes are permitted). Nested classes inside class DocFlavor declare predefined static constant DocFlavor objects for these example doc flavors; class DocFlavor's constructor can be used to create an arbitrary doc flavor.
RenderableImage
. The
printer calls methods
in that interface to obtain the image to be printed.
Printable
.
The printer calls methods in that interface to obtain the pages to be
printed, one by one.
For each page, the printer supplies a graphics context, and whatever the
client draws in that graphics context gets printed.
Pageable
. The printer calls
methods in that interface to obtain the pages to be printed, one by one.
For each page, the printer supplies a graphics context, and whatever
the client draws in that graphics context gets printed.
("text/plain", "java.io.InputStream")
("text/plain; charset=us-ascii", "java.io.InputStream")
("text/plain; charset=utf-8", "java.io.InputStream")
("application/x-java-jvm-local-objectref", "java.awt.image.renderable.RenderableImage")
A Java Print Service instance is allowed to support any other doc flavors (or none) in addition to the above mandatory ones, at the implementation's choice.
Support for the above doc flavors is desirable so a printing client can rely on being able to print on any JPS printer, regardless of which doc flavors the printer supports. If the printer doesn't support the client's preferred doc flavor, the client can at least print plain text, or the client can convert its data to a renderable image and print the image.
Furthermore, every Java Print Service instance must fulfill these requirements for processing plain text print data:
The client must itself perform all plain text print data formatting not addressed by the above requirements.
Class DocFlavor in package javax.print.data is similar to class
DataFlavor
. Class
DataFlavor
is not used in the Java Print Service (JPS) API
for three reasons which are all rooted in allowing the JPS API to be
shared by other print services APIs which may need to run on Java profiles
which do not include all of the Java 2 Standard Edition.
java.awt.datatransfer.DataFlavor
does not guarantee that equivalent data flavors will have the same
serialized representation. DocFlavor does, and can be used in services
which need this.
java.awt.datatransfer.DataFlavor
includes a human presentable name as part of the serialized representation.
This is not appropriate as part of a service matching constraint.
Class DocFlavor's serialized representation uses the following canonical form of a MIME type string. Thus, two doc flavors with MIME types that are not identical but that are equivalent (that have the same canonical form) may be considered equal.
Class DocFlavor's serialized representation also contains the fully-qualified class name of the representation class (a String object), rather than the representation class itself (a Class object). This allows a client to examine the doc flavors a Java Print Service instance supports without having to load the representation classes, which may be problematic for limited-resource clients.
Nested Class Summary | |
---|---|
static class |
DocFlavor.BYTE_ARRAY
Class DocFlavor.BYTE_ARRAY provides predefined static constant DocFlavor objects for example doc flavors using a byte array ( byte[] ) as the print data representation class. |
static class |
DocFlavor.CHAR_ARRAY
Class DocFlavor.CHAR_ARRAY provides predefined static constant DocFlavor objects for example doc flavors using a character array ( char[] ) as the print data representation class. |
static class |
DocFlavor.INPUT_STREAM
Class DocFlavor.INPUT_STREAM provides predefined static constant DocFlavor objects for example doc flavors using a byte stream ( ) as the print
data representation class. |
static class |
DocFlavor.READER
Class DocFlavor.READER provides predefined static constant DocFlavor objects for example doc flavors using a character stream ( ) as the print data
representation class. |
static class |
DocFlavor.SERVICE_FORMATTED
Class DocFlavor.SERVICE_FORMATTED provides predefined static constant DocFlavor objects for example doc flavors for service formatted print data. |
static class |
DocFlavor.STRING
Class DocFlavor.STRING provides predefined static constant DocFlavor objects for example doc flavors using a string ( ) as the print data representation class. |
static class |
DocFlavor.URL
Class DocFlavor.URL provides predefined static constant DocFlavor objects. |
Field Summary | |
---|---|
static String |
hostEncoding
A String representing the host operating system encoding. |
Constructor Summary | |
---|---|
DocFlavor(String mimeType,
String className)
Constructs a new doc flavor object from the given MIME type and representation class name. |
Method Summary | |
---|---|
boolean |
equals(Object obj)
Determines if this doc flavor object is equal to the given object. |
String |
getMediaSubtype()
Returns this doc flavor object's media subtype (from the MIME type). |
String |
getMediaType()
Returns this doc flavor object's media type (from the MIME type). |
String |
getMimeType()
Returns this doc flavor object's MIME type string based on the canonical form. |
String |
getParameter(String paramName)
Returns a String representing a MIME
parameter. |
String |
getRepresentationClassName()
Returns the name of this doc flavor object's representation class. |
int |
hashCode()
Returns a hash code for this doc flavor object. |
String |
toString()
Converts this DocFlavor to a string. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String hostEncoding
Constructor Detail |
---|
public DocFlavor(String mimeType, String className)
mimeType
- MIME media type string.className
- Fully-qualified representation class name.
NullPointerException
- (unchecked exception) Thrown if mimeType
is null or
className
is null.
IllegalArgumentException
- (unchecked exception) Thrown if mimeType
does not
obey the syntax for a MIME media type string.Method Detail |
---|
public String getMimeType()
public String getMediaType()
public String getMediaSubtype()
public String getParameter(String paramName)
String
representing a MIME
parameter.
Mime types may include parameters which are usually optional.
The charset for text types is a commonly useful example.
This convenience method will return the value of the specified
parameter if one was specified in the mime type for this flavor.
paramName
- the name of the paramater. This name is internally
converted to the canonical lower case format before performing
the match.
throws
- NullPointerException if paramName is null.public String getRepresentationClassName()
public String toString()
DocFlavor
to a string.
public int hashCode()
Object.equals(java.lang.Object)
,
Hashtable
public boolean equals(Object obj)
DocFlavor
, has a MIME type equivalent to this doc
flavor object's MIME type (that is, the MIME types have the same media
type, media subtype, and parameters), and has the same representation
class name as this doc flavor object. Thus, if two doc flavor objects'
MIME types are the same except for comments, they are considered equal.
However, two doc flavor objects with MIME types of "text/plain" and
"text/plain; charset=US-ASCII" are not considered equal, even though
they represent the same media type (because the default character
set for plain text is US-ASCII).
obj
- Object to test.
obj
, false
otherwise.Object.hashCode()
,
Hashtable