Top Description Fields Constructors Methods
java.awt.datatransfer

pack-priv Class MimeType

extends Object
implements Externalizable, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, java.io.Externalizable, java.io.Serializable
Imports
java.io.ByteArrayOutputStream, .Externalizable, .IOException, .ObjectInput, .ObjectOutput, .Serial, java.util.Locale

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

THIS IS *NOT* - REPEAT *NOT* - A PUBLIC CLASS! DataFlavor IS THE PUBLIC INTERFACE, AND THIS IS PROVIDED AS A ***PRIVATE*** (THAT IS AS IN *NOT* PUBLIC) HELPER CLASS!

Field Summary

Modifier and TypeField and Description
private transient MimeTypeParameterList
private transient String
private static final long
serialVersionUID

Use serialVersionUID from JDK 1.2 for interoperability.

private transient String
private static final String
TSPECIALS

A string that holds all the special chars.

Constructor Summary

AccessConstructor and Description
public
MimeType()

Constructor for externalization; this constructor should not be called directly by an application, since the result will be an uninitialized, immutable MimeType object.

public
MimeType(String
text used to initialize the MimeType
rawdata
)

Builds a MimeType from a String.

public
MimeType(String
the primary type of this MimeType
primary
,
String
the subtype of this MimeType
sub
)

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

public
MimeType(String
the primary type of this MimeType
primary
,
String
the subtype of this MimeType
sub
,
MimeTypeParameterList
the requested parameter list
mtpl
)

Builds a MimeType with a pre-defined and valid (or empty) parameter list.

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

a clone of this object
clone
()

Overrides java.lang.Object.clone.

Returns a clone of this object.

public boolean

Returns:

true if thatObject is a MimeType; otherwise returns false
equals
(Object
the object to be evaluated as a MimeType
thatObject
)

Overrides java.lang.Object.equals.

MimeTypes are equal if their primary types, subtypes, and parameters are all equal.

public String
getBaseType()

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

public String
getParameter(String name)

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

public MimeTypeParameterList
getParameters()

Retrieve a copy of this object's parameter list.

public String
getPrimaryType()

Retrieve the primary type of this object.

public String
getSubType()

Retrieve the sub type of this object.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

private static boolean
isTokenChar(char c)

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

private boolean
isValidToken(String s)

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

public boolean

Returns:

true if the primary type and the subtype of this object are the same as the specified type; otherwise returns false
match
(MimeType
the type to compare to this's type
type
)

Returns true if the primary type and the subtype of this object are the same as the specified type; otherwise returns false.

public boolean

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; if rawdata is null, returns false
match
(String
the raw data to be examined
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.

private void
parse(String rawdata)

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

public void
readExternal(ObjectInput
the stream to read data from in order to restore the object
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 name)

Remove any value associated with the given name.

public void
setParameter(String name, String value)

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

public String
toString()

Overrides java.lang.Object.toString.

Return the String representation of this object.

public void
writeExternal(ObjectOutput
the stream to write the object 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:
finalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

parametersback to summary
private transient MimeTypeParameterList parameters
primaryTypeback to summary
private transient String primaryType
serialVersionUIDback to summary
private static final long serialVersionUID

Use serialVersionUID from JDK 1.2 for interoperability.

Annotations
@Serial
subTypeback to summary
private transient 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()

Constructor for externalization; this constructor should not be called directly by an application, since the result will be an uninitialized, immutable MimeType object.

MimeTypeback to summary
public MimeType(String rawdata) throws MimeTypeParseException

Builds a MimeType from a String.

Parameters
rawdata:String

text used to initialize the MimeType

Exceptions
NullPointerException:
if rawdata is null
MimeTypeback to summary
public MimeType(String primary, String sub) throws MimeTypeParseException

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

Parameters
primary:String

the primary type of this MimeType

sub:String

the subtype of this MimeType

Exceptions
NullPointerException:
if either primary or sub is null
MimeTypeback to summary
public MimeType(String primary, String sub, MimeTypeParameterList mtpl) throws MimeTypeParseException

Builds a MimeType with a pre-defined and valid (or empty) parameter list.

Parameters
primary:String

the primary type of this MimeType

sub:String

the subtype of this MimeType

mtpl:MimeTypeParameterList

the requested parameter list

Exceptions
NullPointerException:
if either primary, sub or mtpl is null

Method Detail

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Returns a clone of this object.

Returns:Object

a clone of this object

equalsback to summary
public boolean equals(Object thatObject)

Overrides java.lang.Object.equals.

MimeTypes are equal if their primary types, subtypes, and parameters are all equal. No default values are taken into account.

Parameters
thatObject:Object

the object to be evaluated as a MimeType

Returns:boolean

true if thatObject is a MimeType; otherwise returns false

getBaseTypeback to summary
public String getBaseType()

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

getParameterback to summary
public String getParameter(String name)

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

getParametersback to summary
public MimeTypeParameterList getParameters()

Retrieve a copy of this object's parameter list.

getPrimaryTypeback to summary
public String getPrimaryType()

Retrieve the primary type of this object.

getSubTypeback to summary
public String getSubType()

Retrieve the sub type of this object.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

isTokenCharback to summary
private static boolean isTokenChar(char c)

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

isValidTokenback to summary
private boolean isValidToken(String s)

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

Exceptions
NullPointerException:
if s is null
matchback to summary
public 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.

Parameters
type:MimeType

the type to compare to this's type

Returns:boolean

true if the primary type and the subtype of this object are the same as the specified type; otherwise returns false

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

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.

Parameters
rawdata:String

the raw data to be examined

Returns:boolean

true 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 false

parseback to summary
private void parse(String rawdata) throws MimeTypeParseException

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

Exceptions
NullPointerException:
if rawdata is null
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

Doc from java.io.Externalizable.readExternal.

the stream to read data from in order to restore the object

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.

Exceptions
IllegalArgumentException:
if parameter may not be deleted
setParameterback to summary
public void setParameter(String name, String value)

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

Exceptions
IllegalArgumentException:
if parameter or value is illegal
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

Doc from java.io.Externalizable.writeExternal.

the stream to write the object to

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