public class

MimeType

extends Object
implements Externalizable
java.lang.Object
   ↳ com.google.code.javax.activation.MimeType

Class Overview

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

Summary

Constants
String TSPECIALS A string that holds all the special chars.
Fields
private MimeTypeParameterList parameters
private String primaryType
private String subType
Public Constructors
MimeType()
Default constructor.
MimeType(String rawdata)
Constructor that builds a MimeType from a String.
MimeType(String primary, String sub)
Constructor that builds a MimeType with the given primary and sub type but has an empty parameter list.
Public Methods
String getBaseType()
Return a String representation of this object without the parameter list.
String getParameter(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.
String getPrimaryType()
Retrieve the primary type of this object.
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(String rawdata)
Determine if the primary and sub type of this object is the same as the content type described in rawdata.
void readExternal(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(String name)
Remove any value associated with the given name.
void setParameter(String name, String value)
Set the value to be associated with the given name, replacing any previous association.
void setPrimaryType(String primary)
Set the primary type for this object to the given String.
void setSubType(String sub)
Set the subtype for this object to the given String.
String toString()
Return the String representation of this object.
void writeExternal(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.
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.io.Externalizable

Constants

private static final String TSPECIALS

A string that holds all the special chars.

Constant Value: "()<>@,;:/[]?=\""

Fields

private MimeTypeParameterList parameters

private String primaryType

private String subType

Public Constructors

public MimeType ()

Default constructor.

public MimeType (String rawdata)

Constructor that builds a MimeType from a String.

Parameters
rawdata The MIME type string

public MimeType (String primary, String sub)

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

Parameters
primary The primary MIME type
sub The MIME sub-type
Throws
MimeTypeParseException if the primary type or subtype is not a valid token

Public Methods

public String getBaseType ()

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

Returns
  • the MIME type and sub-type

public String getParameter (String name)

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

Parameters
name The parameter name
Returns
  • the paramter's value

public MimeTypeParameterList getParameters ()

Retrieve this object's parameter list.

Returns
  • a MimeTypeParameterList object representing the parameters

public String getPrimaryType ()

Retrieve the primary type of this object.

Returns
  • the primary MIME type

public String getSubType ()

Retrieve the subtype of this object.

Returns
  • the MIME subtype

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 The MimeType object to compare with
Returns
  • true if they match

public boolean match (String rawdata)

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

Parameters
rawdata The MIME type string to compare with
Returns
  • true if they match

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

Parameters
in The ObjectInput object to read from
Throws
ClassNotFoundException If the class for an object being restored cannot be found.
IOException

public void removeParameter (String name)

Remove any value associated with the given name.

Parameters
name The parameter name

public void setParameter (String name, String value)

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

Parameters
name The parameter name
value The paramter's value

public void setPrimaryType (String primary)

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

Parameters
primary The primary MIME type
Throws
MimeTypeParseException if the primary type is not a valid token

public void setSubType (String sub)

Set the subtype for this object to the given String.

Parameters
sub The MIME subtype
Throws
MimeTypeParseException if the subtype is not a valid token

public String toString ()

Return the String representation of this object.

public void writeExternal (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.

Parameters
out The ObjectOutput object to write to
Throws
IOException Includes any I/O exceptions that may occur