javax.activation
Class MimeType

java.lang.Object
  |
  +--javax.activation.MimeType
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable

public class MimeType
extends java.lang.Object
implements java.io.Externalizable

Represents a MIME type as per RFC2046.

Version:
$Revision: 1.5 $
Author:
Andrew Selkirk
See Also:
Serialized Form

Constructor Summary
MimeType()
          Create empty MIME Type
MimeType(java.lang.String rawdata)
          Create a MIME Type object from a raw MIME Type entry.
MimeType(java.lang.String primary, java.lang.String sub)
          Create MIME Type object from primary/sub
 
Method Summary
 java.lang.String getBaseType()
          Get the Base of the MIME type.
 java.lang.String getParameter(java.lang.String name)
          Get the value of a MIME type parameter.
 MimeTypeParameterList getParameters()
          Get the parameter collection
 java.lang.String getPrimaryType()
          Get the primary type of the MIME type
 java.lang.String getSubType()
          Get the sub type of the MIME type
 boolean match(MimeType type)
          Determine if the MIME Type matches this MIME Type.
 boolean match(java.lang.String rawdata)
          Determine if the raw MIME Type entry matches this MIME Type.
 void readExternal(java.io.ObjectInput input)
          Read external.
 void removeParameter(java.lang.String name)
          Remove the specified parameter from the MIME type
 void setParameter(java.lang.String name, java.lang.String value)
          Set a MIME type parameter.
 void setPrimaryType(java.lang.String primary)
          Set the primary type of the MIME type.
 void setSubType(java.lang.String sub)
          Set the sub type of the MIME type.
 java.lang.String toString()
          Get a MIME type string encoding.
 void writeExternal(java.io.ObjectOutput output)
          Write external.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MimeType

public MimeType(java.lang.String rawdata)
         throws MimeTypeParseException
Create a MIME Type object from a raw MIME Type entry.
Parameters:
rawdata - MIME Type entry

MimeType

public MimeType(java.lang.String primary,
                java.lang.String sub)
Create MIME Type object from primary/sub
Parameters:
primary - MIME Type primary
sub - MIME Type sub type

MimeType

public MimeType()
Create empty MIME Type
Method Detail

toString

public java.lang.String toString()
Get a MIME type string encoding. The format is primary type/subtype; parameters
Overrides:
toString in class java.lang.Object
Returns:
canonical representation of the MIME type

getBaseType

public java.lang.String getBaseType()
Get the Base of the MIME type. Consists of the format: primary type/subtype
Returns:
Base type

getParameter

public java.lang.String getParameter(java.lang.String name)
Get the value of a MIME type parameter.
Parameters:
name - Parameter name
Returns:
Parameter value, or null

getParameters

public MimeTypeParameterList getParameters()
Get the parameter collection
Returns:
Parameter object

removeParameter

public void removeParameter(java.lang.String name)
Remove the specified parameter from the MIME type
Parameters:
name - Parameter name

setParameter

public void setParameter(java.lang.String name,
                         java.lang.String value)
Set a MIME type parameter.
Parameters:
name - Parameter name
value - Parameter value

getPrimaryType

public java.lang.String getPrimaryType()
Get the primary type of the MIME type
Returns:
Primary type

getSubType

public java.lang.String getSubType()
Get the sub type of the MIME type
Returns:
Sub type

setPrimaryType

public void setPrimaryType(java.lang.String primary)
                    throws MimeTypeParseException
Set the primary type of the MIME type.
Parameters:
primary - Primary type
Throws:
MimeTypeParseException - Parsing exception occurred

setSubType

public void setSubType(java.lang.String sub)
                throws MimeTypeParseException
Set the sub type of the MIME type.
Parameters:
sub - Sub type
Throws:
MimeTypeParseException - Parsing exception occurred

match

public boolean match(java.lang.String rawdata)
              throws MimeTypeParseException
Determine if the raw MIME Type entry matches this MIME Type.
Parameters:
rawdata - MIME type entry to check
Returns:
true if it matches, false otherwise
Throws:
MimeTypeParseException - Parsing exception occurred

match

public boolean match(MimeType type)
Determine if the MIME Type matches this MIME Type.
Parameters:
type - MIME type to check
Returns:
true if matches, false otherwise

readExternal

public void readExternal(java.io.ObjectInput input)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Read external. Part of serialization.
Specified by:
readExternal in interface java.io.Externalizable
Parameters:
input - Object input
Throws:
java.io.IOException - IOException occurred
java.lang.ClassNotFoundException - ClassNotFoundException occurred

writeExternal

public void writeExternal(java.io.ObjectOutput output)
                   throws java.io.IOException
Write external. Part of serialization.
Specified by:
writeExternal in interface java.io.Externalizable
Parameters:
output - Object output
Throws:
java.io.IOException - IO exception occurred


© Copyright 2002 the Free Software Foundation, all rights reserved.