public class MimeType
extends java.lang.Object
implements java.io.Externalizable, java.lang.Cloneable
Implementation taken from java.awt.datatransfer.MimeType 1.20 01/12/03
| Constructor and Description |
|---|
MimeType()
Constructor for externalization; this constructor should not be
called directly by an application, since the result will be an
uninitialized, immutable
MimeType object. |
MimeType(java.lang.String rawdata)
Builds a
MimeType from a String. |
MimeType(java.lang.String primary,
java.lang.String sub)
Builds a
MimeType with the given primary and sub
type but has an empty parameter list. |
MimeType(java.lang.String primary,
java.lang.String sub,
ch.randelshofer.quaqua.datatransfer.MimeTypeParameterList mtpl)
Builds a
MimeType with a pre-defined
and valid (or empty) parameter list. |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
clone()
Returns a clone of this object.
|
boolean |
equals(java.lang.Object thatObject)
MimeTypes are equal if their primary types,
subtypes, and parameters are all equal. |
java.lang.String |
getBaseType()
Return a String representation of this object
without the parameter list.
|
java.lang.String |
getParameter(java.lang.String name)
Retrieve the value associated with the given name, or null if there
is no current association.
|
ch.randelshofer.quaqua.datatransfer.MimeTypeParameterList |
getParameters()
Retrieve a copy of this object's parameter list.
|
java.lang.String |
getPrimaryType()
Retrieve the primary type of this object.
|
java.lang.String |
getSubType()
Retrieve the sub type of this object.
|
int |
hashCode() |
boolean |
match(MimeType type)
Returns
true if the primary type and the
subtype of this object are the same as the specified
type; otherwise returns false. |
boolean |
match(java.lang.String rawdata)
Returns
true if the primary type and the
subtype of this object are the same as the content type
described in rawdata; otherwise returns
false. |
void |
readExternal(java.io.ObjectInput in)
The object implements the readExternal method to restore its
contents by calling the methods of DataInput for primitive
types and readObject for objects, strings and arrays.
|
void |
removeParameter(java.lang.String name)
Remove any value associated with the given name.
|
void |
setParameter(java.lang.String name,
java.lang.String value)
Set the value to be associated with the given name, replacing
any previous association.
|
java.lang.String |
toString()
Return the String representation of this object.
|
void |
writeExternal(java.io.ObjectOutput out)
The object implements the writeExternal method to save its contents
by calling the methods of DataOutput for its primitive values or
calling the writeObject method of ObjectOutput for objects, strings
and arrays.
|
public MimeType()
MimeType object.public MimeType(java.lang.String rawdata)
throws MimeTypeParseException
MimeType from a String.rawdata - text used to initialize the MimeTypeMimeTypeParseExceptionpublic MimeType(java.lang.String primary,
java.lang.String sub)
throws MimeTypeParseException
MimeType with the given primary and sub
type but has an empty parameter list.primary - the primary type of this MimeTypesub - the subtype of this MimeTypeMimeTypeParseExceptionpublic MimeType(java.lang.String primary,
java.lang.String sub,
ch.randelshofer.quaqua.datatransfer.MimeTypeParameterList mtpl)
throws MimeTypeParseException
MimeType with a pre-defined
and valid (or empty) parameter list.primary - the primary type of this MimeTypesub - the subtype of this MimeTypemtpl - the requested parameter listMimeTypeParseExceptionpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object thatObject)
MimeTypes are equal if their primary types,
subtypes, and parameters are all equal. No default values
are taken into account.equals in class java.lang.ObjectthatObject - the object to be evaluated as a
MimeTypetrue if thatObject is
a MimeType; otherwise returns falsepublic java.lang.String getPrimaryType()
public java.lang.String getSubType()
public ch.randelshofer.quaqua.datatransfer.MimeTypeParameterList getParameters()
public java.lang.String getParameter(java.lang.String name)
public void setParameter(java.lang.String name,
java.lang.String value)
java.lang.IllegalArgumentException - if parameter or value is illegalpublic void removeParameter(java.lang.String name)
java.lang.IllegalArgumentException - if parameter may not be deletedpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getBaseType()
public boolean match(MimeType type)
true if the primary type and the
subtype of this object are the same as the specified
type; otherwise returns false.type - the type to compare to this's typetrue if the primary type and the
subtype of this object are the same as the
specified type; otherwise returns
falsepublic boolean match(java.lang.String rawdata)
throws MimeTypeParseException
true if the primary type and the
subtype of this object are the same as the content type
described in rawdata; otherwise returns
false.rawdata - the raw data to be examinedtrue if the primary type and the
subtype of this object are the same as the content type
described in rawdata; otherwise returns
false; if rawdata is
null, returns falseMimeTypeParseExceptionpublic void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
writeExternal in interface java.io.Externalizablejava.io.IOException - Includes any I/O exceptions that may occurpublic void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
readExternal in interface java.io.Externalizablejava.lang.ClassNotFoundException - If the class for an object being
restored cannot be found.java.io.IOExceptionpublic java.lang.Object clone()
clone in class java.lang.Object