* <P>
* 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.
* <UL>
* <LI> The media type, media subtype, and parameters are retained, but all
* comments and whitespace characters are discarded.
* <LI> The media type, media subtype, and parameter names are converted to
* lowercase.
* <LI> The parameter values retain their original case, except a charset
* parameter value for a text media type is converted to lowercase.
* <LI> Quote characters surrounding parameter values are removed.
* <LI> Quoting backslash characters inside parameter values are removed.
* <LI> The parameters are arranged in ascending order of parameter name.
* </UL>
* <P>
* Class DocFlavor's serialized representation also contains the
* fully-qualified class <I>name</I> 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.
* <P>
*
* @author Alan Kaminsky
*/
public class DocFlavor implements Serializable, Cloneable {
private static final long serialVersionUID = -4512080796965449721L;
/**
* A String representing the host operating system encoding.
* This will follow the conventions documented in
* <a href="http://ietf.org/rfc/rfc2278.txt">
* <i>RFC 2278: IANA Charset Registration Procedures</i></a>
* except where historical names are returned for compatibility with
* previous versions of the Java platform.
* The value returned from method is valid only for the VM which
* returns it, for use in a DocFlavor.
* This is the charset for all the "HOST" pre-defined DocFlavors in
* the executing VM.
*/
public static final String hostEncoding;
static {
hostEncoding =
(String)java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("file.encoding"));
}
/**
* MIME type.
*/
private transient MimeType myMimeType;
/**
* Representation class name.
* @serial
*/
private String myClassName;
/**
* String value for this doc flavor. Computed when needed and cached.
*/
private transient String myStringValue = null;
/**
* Constructs a new doc flavor object from the given MIME type and
* representation class name. The given MIME type is converted into
* canonical form and stored internally.
*
* @param mimeType MIME media type string.
* @param className Fully-qualified representation class name.
*
* @exception NullPointerException
* (unchecked exception) Thrown if <CODE>mimeType</CODE> is null or
* <CODE>className</CODE> is null.
* @exception IllegalArgumentException
* (unchecked exception) Thrown if <CODE>mimeType</CODE> does not
* obey the syntax for a MIME media type string.
*/
public DocFlavor(String mimeType, String className) {
if (className == null) {
throw new NullPointerException();
}
myMimeType = new MimeType (mimeType);
myClassName = className;
}
/**
* Returns this doc flavor object's MIME type string based on the
* canonical form. Each parameter value is enclosed in quotes.
* @return the mime type
*/
public String getMimeType() {
return myMimeType.getMimeType();
}
=5= |