javax.print
class: MimeType [javadoc |
source]
java.lang.Object
javax.print.MimeType
All Implemented Interfaces:
Cloneable, java$io$Serializable
Class MimeType encapsulates a Multipurpose Internet Mail Extensions (MIME)
media type as defined in
RFC
2045 and
RFC 2046. A
MIME type object is part of a
DocFlavor object and
specifies the format of the print data.
Class MimeType is similar to the like-named
class in package java.awt.datatransfer . Class
java.awt.datatransfer.MimeType is not used in the Jini Print Service API
for two reasons:
-
Since not all Java profiles include the AWT, the Jini Print Service should
not depend on an AWT class.
-
The implementation of class java.awt.datatransfer.MimeType does not
guarantee
that equivalent MIME types will have the same serialized representation.
Thus, since the Jini Lookup Service (JLUS) matches service attributes based
on equality of serialized representations, JLUS searches involving MIME
types encapsulated in class java.awt.datatransfer.MimeType may incorrectly
fail to match.
Class MimeType's serialized representation is based on the following
canonical form of a MIME type string. Thus, two MIME types that are not
identical but that are equivalent (that have the same canonical form) will
be considered equal by the JLUS's matching algorithm.
- The media type, media subtype, and parameters are retained, but all
comments and whitespace characters are discarded.
- The media type, media subtype, and parameter names are converted to
lowercase.
- The parameter values retain their original case, except a charset
parameter value for a text media type is converted to lowercase.
- Quote characters surrounding parameter values are removed.
- Quoting backslash characters inside parameter values are removed.
- The parameters are arranged in ascending order of parameter name.
Constructor: |
public MimeType(String s) {
parse (s);
}
Construct a new MIME type object from the given string. The given
string is converted into canonical form and stored internally. Parameters:
s - MIME media type string.
Throws:
NullPointerException -
(unchecked exception) Thrown if s is null.
IllegalArgumentException -
(unchecked exception) Thrown if s does not obey the
syntax for a MIME media type string.
- exception:
NullPointerException -
(unchecked exception) Thrown if s is null.
- exception:
IllegalArgumentException -
(unchecked exception) Thrown if s does not obey the
syntax for a MIME media type string.
|
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from javax.print.MimeType Detail: |
public boolean equals(Object obj) {
return(obj != null &&
obj instanceof MimeType &&
getStringValue().equals(((MimeType) obj).getStringValue()));
}
Determine if this MIME type object is equal to the given object. The two
are equal if the given object is not null, is an instance of class
net.jini.print.data.MimeType, and has the same canonical form as this
MIME type object (that is, has the same type, subtype, and parameters).
Thus, if two MIME type objects are the same except for comments, they are
considered equal. However, "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). |
public String getMediaSubtype() {
return myPieces[1];
}
Returns this MIME type object's media subtype. |
public String getMediaType() {
return myPieces[0];
}
Returns this MIME type object's media type. |
public String getMimeType() {
return getStringValue();
}
Returns this MIME type object's MIME type string based on the canonical
form. Each parameter value is enclosed in quotes. |
public Map getParameterMap() {
if (myParameterMap == null) {
myParameterMap = new ParameterMap();
}
return myParameterMap;
}
Returns an unmodifiable map view of the parameters in this MIME type
object. Each entry in the parameter map view consists of a parameter
name String (key) mapping to a parameter value String. If this MIME
type object has no parameters, an empty map is returned. |
public int hashCode() {
return getStringValue().hashCode();
}
Returns a hash code for this MIME type object. |
public String toString() {
return getStringValue();
}
Converts this MIME type object to a string. |