Top Description Fields Constructors Methods
jakarta.activation

public Class MimeType

extends Object
implements Externalizable
Class Inheritance
All Implemented Interfaces
java.io.Externalizable, java.io.Serializable
Imports
java.io.*, java.util.Locale

A Multipurpose Internet Mail Extension (MIME) type, as defined in RFC 2045 and 2046.

Field Summary

Modifier and TypeField and Description
private MimeTypeParameterList
private String
private static final long
private String
private static final String
TSPECIALS

A string that holds all the special chars.

Constructor Summary

AccessConstructor and Description
public
MimeType()

Default constructor.

public
MimeType(String
the MIME type string
rawdata
)

Constructor that builds a MimeType from a String.

public
MimeType(String
the primary MIME type
primary
,
String
the MIME sub-type
sub
)

Constructor that builds a MimeType with the given primary and sub type but has an empty parameter list.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the MIME type and sub-type
getBaseType
()

Return a String representation of this object without the parameter list.

public String

Returns:

the paramter's value
getParameter
(String
the parameter name
name
)

Retrieve the value associated with the given name, or null if there is no current association.

public MimeTypeParameterList

Returns:

a MimeTypeParameterList object representing the parameters
getParameters
()

Retrieve this object's parameter list.

public String

Returns:

the primary MIME type
getPrimaryType
()

Retrieve the primary type of this object.

public String

Returns:

the MIME subtype
getSubType
()

Retrieve the subtype of this object.

private static boolean
isTokenChar(char c)

Determine whether or not a given character belongs to a legal token.

private boolean
isValidToken(String s)

Determine whether or not a given string is a legal token.

public boolean

Returns:

true if they match
match
(MimeType
the MimeType object to compare with
type
)

Determine if the primary and sub type of this object is the same as what is in the given type.

public boolean

Returns:

true if they match
match
(String
the MIME type string to compare with
rawdata
)

Determine if the primary and sub type of this object is the same as the content type described in rawdata.

private void
parse(String rawdata)

A routine for parsing the MIME type out of a String.

public void
readExternal(ObjectInput
the ObjectInput object to read from
in
)

Implements java.io.Externalizable.readExternal.

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.
public void
removeParameter(String
the parameter name
name
)

Remove any value associated with the given name.

public void
setParameter(String
the parameter name
name
,
String
the paramter's value
value
)

Set the value to be associated with the given name, replacing any previous association.

public void
setPrimaryType(String
the primary MIME type
primary
)

Set the primary type for this object to the given String.

public void
setSubType(String
the MIME subtype
sub
)

Set the subtype for this object to the given String.

public String
toString()

Overrides java.lang.Object.toString.

Return the String representation of this object.
public void
writeExternal(ObjectOutput
the ObjectOutput object to write to
out
)

Implements java.io.Externalizable.writeExternal.

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.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

parametersback to summary
private MimeTypeParameterList parameters
primaryTypeback to summary
private String primaryType
serialVersionUIDback to summary
private static final long serialVersionUID
subTypeback to summary
private String subType
TSPECIALSback to summary
private static final String TSPECIALS

A string that holds all the special chars.

Constructor Detail

MimeTypeback to summary
public MimeType()

Default constructor.

MimeTypeback to summary
public MimeType(String rawdata) throws MimeTypeParseException

Constructor that builds a MimeType from a String.

Parameters
rawdata:String

the MIME type string

Exceptions
MimeTypeParseException:
if the MIME type can't be parsed
MimeTypeback to summary
public MimeType(String primary, String sub) throws MimeTypeParseException

Constructor that builds a MimeType with the given primary and sub type but has an empty parameter list.

Parameters
primary:String

the primary MIME type

sub:String

the MIME sub-type

Exceptions
MimeTypeParseException:
if the primary type or subtype is not a valid token

Method Detail

getBaseTypeback to summary
public String getBaseType()

Return a String representation of this object without the parameter list.

Returns:String

the MIME type and sub-type

getParameterback to summary
public String getParameter(String name)

Retrieve the value associated with the given name, or null if there is no current association.

Parameters
name:String

the parameter name

Returns:String

the paramter's value

getParametersback to summary
public MimeTypeParameterList getParameters()

Retrieve this object's parameter list.

Returns:MimeTypeParameterList

a MimeTypeParameterList object representing the parameters

getPrimaryTypeback to summary
public String getPrimaryType()

Retrieve the primary type of this object.

Returns:String

the primary MIME type

getSubTypeback to summary
public String getSubType()

Retrieve the subtype of this object.

Returns:String

the MIME subtype

isTokenCharback to summary
private static boolean isTokenChar(char c)

Determine whether or not a given character belongs to a legal token.

isValidTokenback to summary
private boolean isValidToken(String s)

Determine whether or not a given string is a legal token.

matchback to summary
public boolean match(MimeType type)

Determine if the primary and sub type of this object is the same as what is in the given type.

Parameters
type:MimeType

the MimeType object to compare with

Returns:boolean

true if they match

matchback to summary
public boolean match(String rawdata) throws MimeTypeParseException

Determine if the primary and sub type of this object is the same as the content type described in rawdata.

Parameters
rawdata:String

the MIME type string to compare with

Returns:boolean

true if they match

Exceptions
MimeTypeParseException:
if the MIME type can't be parsed
parseback to summary
private void parse(String rawdata) throws MimeTypeParseException

A routine for parsing the MIME type out of a String.

readExternalback to summary
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException

Implements java.io.Externalizable.readExternal.

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. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.

Parameters
in:ObjectInput

the ObjectInput object to read from

Exceptions
IOException:

Doc from java.io.Externalizable.readExternal.

if I/O errors occur

ClassNotFoundException:
If the class for an object being restored cannot be found.
removeParameterback to summary
public void removeParameter(String name)

Remove any value associated with the given name.

Parameters
name:String

the parameter name

setParameterback to summary
public void setParameter(String name, String value)

Set the value to be associated with the given name, replacing any previous association.

Parameters
name:String

the parameter name

value:String

the paramter's value

setPrimaryTypeback to summary
public void setPrimaryType(String primary) throws MimeTypeParseException

Set the primary type for this object to the given String.

Parameters
primary:String

the primary MIME type

Exceptions
MimeTypeParseException:
if the primary type is not a valid token
setSubTypeback to summary
public void setSubType(String sub) throws MimeTypeParseException

Set the subtype for this object to the given String.

Parameters
sub:String

the MIME subtype

Exceptions
MimeTypeParseException:
if the subtype is not a valid token
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Return the String representation of this object.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.

writeExternalback to summary
public void writeExternal(ObjectOutput out) throws IOException

Implements java.io.Externalizable.writeExternal.

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.

Parameters
out:ObjectOutput

the ObjectOutput object to write to

Exceptions
IOException:
Includes any I/O exceptions that may occur