javax.print
Class DocFlavor
- 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:
-
The MIME type (Multipurpose Internet Mail Extensions types as described
in RFC 2045/2046) specifying the media format of the print data.
-
The representation class name which is the fully qualified name of the
class providing the print data to the print job. For example if the print
data is supplied as a byte array the representation class name will be
"[B"
or for an input stream "java.io.InputStream"
.
The
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.
Client formatted print data document flavors
The print service uses the representation class of the doc flavor to know
how to retrieve the print data. If the representation class is a
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:
- Character arrays (
char[]
): The characters of the array
represent the print data. - Character streams (
java.io.Reader
): The whole characters
read from the stream represent the print data. - String (
java.lang.String
): The characters of the String
represent the print data. - Byte arrays (
byte[]
): The bytes of the array represent the
print data. Encoding if text content is given in the mime type. - Byte streams (
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. - Uniform Resource Locator (
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.
Service formatted print data document flavors
The print service uses the provided object implementing the interface
specified by the representation class to produce the formatted print data.
The mime type of service formatted data is always
"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:
- Pageable object (
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. - Printable object (
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. - Renderable Image object
(
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.
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.
|
DocFlavor(String mimeType, String className) - Constructs a
DocFlavor object with the given MIME type and
representation class name.
|
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
DocFlavor
public DocFlavor(String mimeType,
String className)
Constructs a DocFlavor
object with the given MIME type and
representation class name.
mimeType
- the MIME type string.className
- the fully-qualified name of the representation class.
equals
public boolean equals(Object obj)
Checks if this doc flavor object is equal to the given object.
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.
- equals in interface Object
obj
- the object to test.
true
if equal, false
otherwise.
getMediaSubtype
public String getMediaSubtype()
Returns the media subtype of this flavor object.
A mimetype of "text/html; charset=us-ascii" will
return "html" as the media subtype.
getMediaType
public String getMediaType()
Returns the media type of this flavor object.
A mimetype of "text/html; charset=us-ascii" will
return "text" as the media type.
getMimeType
public String getMimeType()
Returns the mime type of this flavor object.
The mimetype will have every parameter value
enclosed in quotes.
getParameter
public String getParameter(String paramName)
Returns the value for an optional parameter of the mime type of this
flavor object.
paramName
- the name of the parameter
- The value for the parameter, or
null
if none bound.
getRepresentationClassName
public String getRepresentationClassName()
Returns the name of the representation class of this flavor object.
- The representation classname.
toString
public String toString()
Returns a string representation of this doc flavor object.
The returned string is of the form
getMimeType() + "; class=\"" + getRepresentationClassName() + "\"";
- toString in interface Object
- The constructed string representation.
DocFlavor.java --
Copyright (C) 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.