javax.print
public class DocFlavor extends Object implements Cloneable, Serializable
DocFlavor
provides a description of the format in which the
print data will be supplied in a print job to the print service.
A doc flavor consists of two parts:
"[B"
or for an input stream "java.io.InputStream"
.
DocFlavor
class is therefore used in several places in the
Java Print Service API. A print service provides its supported document
flavors as an array of DocFlavor objects and a print job gets the flavor of
its data to print from the Doc
object provided as a DocFlavor
instance.
It has to be differentiated between client formatted and service formatted print data. Client formatted print data is already provided formatted by the client e.g. in an image format or as postscript. For service formatted print data, the Java Print Service instance produces the formatted print data. Here the doc flavor's representation class name does specify an interface instead of the actual print data source. The print service will call the methods of the given implementation of this interface with a special Graphics object capable of producing formatted print data from the graphics routines inside the interface methods.
URL
it will open the URL to read the print data from it. If it is
a byte[]
it will directly use the array and send it to the
printer. There are predefined doc flavor as inner class for the most common
representation class types:
char[]
): The characters of the array
represent the print data.java.io.Reader
): The whole characters
read from the stream represent the print data.java.lang.String
): The characters of the String
represent the print data.byte[]
): The bytes of the array represent the
print data. Encoding if text content is given in the mime type.java.io.InputStream
): The whole bytes read
from the stream represent the print data. If text content the encoding is
specified in the mime type.java.net.URL
): The bytes read
from the stream through opening of the URL represent the print data.
If text content the encoding is specified in the mime type.
"application/x-java-jvm-local-objectref"
to signal the local
reference to the print data object implementing the interface. Predefined
doc flavor classes exist as an inner class for the three available interface
to produce print data:
java.awt.print.Pageable
): A pageable object
is supplied to the print service. The print service will call the methods of
the interface with a Grahics object to produce the formatted print data.java.awt.print.Printable
): A printable object
is supplied to the print service. The print service will call the methods of
the interface with a Grahics object to produce the formatted print data.java.awt.image.renderable.RenderableImage
): A renderable image
object is supplied to the print service. The print service calls methods of
this interface to obtain the image to be printed.Nested Class Summary | |
---|---|
static class | DocFlavor.BYTE_ARRAY
Predefined static DocFlavor objects for document
types which use a byte array for the print data representation.
|
static class | DocFlavor.CHAR_ARRAY
Predefined static DocFlavor objects for document
types which use a char array for the print data representation.
|
static class | DocFlavor.INPUT_STREAM
Predefined static DocFlavor objects for document
types which use an InputStream to retrieve the print data.
|
static class | DocFlavor.READER
Predefined static DocFlavor objects for document
types which use an Reader to retrieve the print data.
|
static class | DocFlavor.SERVICE_FORMATTED
Predefined static DocFlavor objects for document
types which use service formatted print data.
|
static class | DocFlavor.STRING
Predefined static DocFlavor objects for document
types which use a String for the print data representation.
|
static class | DocFlavor.URL
Predefined static DocFlavor objects for document
types which have an URL where to retrieve the print data.
|
Field Summary | |
---|---|
static String | hostEncoding
The string representing the host encoding. |
Constructor Summary | |
---|---|
DocFlavor(String mimeType, String className)
Constructs a DocFlavor object with the given MIME type and
representation class name.
|
Method Summary | |
---|---|
boolean | equals(Object obj)
Checks if this doc flavor object is equal to the given object.
|
String | getMediaSubtype()
Returns the media subtype of this flavor object.
|
String | getMediaType()
Returns the media type of this flavor object.
|
String | getMimeType()
Returns the mime type of this flavor object.
|
String | getParameter(String paramName)
Returns the value for an optional parameter of the mime type of this
flavor object.
|
String | getRepresentationClassName()
Returns the name of the representation class of this flavor object.
|
int | hashCode()
Returns a hash code for this doc flavor object.
|
String | toString()
Returns a string representation of this doc flavor object.
|
DocFlavor
object with the given MIME type and
representation class name.
Parameters: mimeType the MIME type string. className the fully-qualified name of the representation class.
Throws: NullPointerException if mimeType or className are null
. IllegalArgumentException if given mimeType has syntax errors.
Two doc flavor objects are considered equal if the provided object is not
null
and an instance of DocFlavor
. The MIME
types has to be equal in their media type, media subtype, their
paramter/value combinations and the representation classname.
Parameters: obj the object to test.
Returns: true
if equal, false
otherwise.
Returns: The media subtype.
Returns: The media type.
Returns: The mime type.
Parameters: paramName the name of the parameter
Returns: The value for the parameter, or null
if none bound.
Throws: NullPointerException if paramName is null
.
Returns: The representation classname.
Returns: The hashcode.
Returns: The constructed string representation.