public class MimeType
extends java.lang.Object
implements java.io.Externalizable
Constructor and Description |
---|
MimeType()
Default constructor.
|
MimeType(java.lang.String rawdata)
Constructor that builds a MimeType from a String.
|
MimeType(java.lang.String primary,
java.lang.String sub)
Constructor that builds a MimeType with the given primary and sub type
but has an empty parameter list.
|
Modifier and Type | Method and Description |
---|---|
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.
|
MimeTypeParameterList |
getParameters()
Retrieve this object's parameter list.
|
java.lang.String |
getPrimaryType()
Retrieve the primary type of this object.
|
java.lang.String |
getSubType()
Retrieve the subtype of this object.
|
boolean |
match(MimeType type)
Determine if the primary and sub type of this object is
the same as what is in the given type.
|
boolean |
match(java.lang.String rawdata)
Determine if the primary and sub type of this object is
the same as the content type described in rawdata.
|
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.
|
void |
setPrimaryType(java.lang.String primary)
Set the primary type for this object to the given String.
|
void |
setSubType(java.lang.String sub)
Set the subtype for this object to the given String.
|
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()
public MimeType(java.lang.String rawdata) throws MimeTypeParseException
rawdata
- the MIME type stringMimeTypeParseException
- if the MIME type can't be parsedpublic MimeType(java.lang.String primary, java.lang.String sub) throws MimeTypeParseException
primary
- the primary MIME typesub
- the MIME sub-typeMimeTypeParseException
- if the primary type or subtype
is not a valid tokenpublic java.lang.String getPrimaryType()
public void setPrimaryType(java.lang.String primary) throws MimeTypeParseException
primary
- the primary MIME typeMimeTypeParseException
- if the primary type
is not a valid tokenpublic java.lang.String getSubType()
public void setSubType(java.lang.String sub) throws MimeTypeParseException
sub
- the MIME subtypeMimeTypeParseException
- if the subtype
is not a valid tokenpublic MimeTypeParameterList getParameters()
public java.lang.String getParameter(java.lang.String name)
name
- the parameter namepublic void setParameter(java.lang.String name, java.lang.String value)
name
- the parameter namevalue
- the paramter's valuepublic void removeParameter(java.lang.String name)
name
- the parameter namepublic java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getBaseType()
public boolean match(MimeType type)
type
- the MimeType object to compare withpublic boolean match(java.lang.String rawdata) throws MimeTypeParseException
rawdata
- the MIME type string to compare withMimeTypeParseException
- if the MIME type can't be parsedpublic void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
out
- the ObjectOutput object to write tojava.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.Externalizable
in
- the ObjectInput object to read fromjava.lang.ClassNotFoundException
- If the class for an object being
restored cannot be found.java.io.IOException