|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.datatransfer.MimeType
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 | |
private MimeTypeParameterList |
parameters
|
private String |
primaryType
|
(package private) static long |
serialVersionUID
|
private String |
subType
|
private static String |
TSPECIALS
A string that holds all the special chars. |
Constructor Summary | |
MimeType()
Constructor for externalization; this constructor should not be called directly by an application, since the result will be an uninitialized, immutable MimeType object. |
|
MimeType(String rawdata)
Builds a MimeType from a String . |
|
MimeType(String primary,
String sub)
Builds a MimeType with the given primary and sub
type but has an empty parameter list. |
|
MimeType(String primary,
String sub,
MimeTypeParameterList mtpl)
Builds a MimeType with a pre-defined
and valid (or empty) parameter list. |
Method Summary | |
Object |
clone()
Returns a clone of this object. |
boolean |
equals(Object thatObject)
MimeType s are equal if their primary types,
subtypes, and parameters are all equal. |
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 a copy of this object's parameter list. |
String |
getPrimaryType()
Retrieve the primary type of this object. |
String |
getSubType()
Retrieve the sub type of this object. |
int |
hashCode()
Returns a hash code value for the 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. |
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 . |
boolean |
match(String 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. |
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. |
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. |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
static final long serialVersionUID
private String primaryType
private String subType
private MimeTypeParameterList parameters
private static final String TSPECIALS
Constructor Detail |
public MimeType()
MimeType
object.
public MimeType(String rawdata) throws MimeTypeParseException
MimeType
from a String
.
rawdata
- text used to initialize the MimeType
NullPointerException
- if rawdata
is null
MimeTypeParseException
public MimeType(String primary, String sub) throws MimeTypeParseException
MimeType
with the given primary and sub
type but has an empty parameter list.
primary
- the primary type of this MimeType
sub
- the subtype of this MimeType
NullPointerException
- if either primary
or
sub
is null
MimeTypeParseException
public MimeType(String primary, String sub, MimeTypeParameterList mtpl) throws MimeTypeParseException
MimeType
with a pre-defined
and valid (or empty) parameter list.
primary
- the primary type of this MimeType
sub
- the subtype of this MimeType
mtpl
- the requested parameter list
NullPointerException
- if either primary
,
sub
or mtpl
is null
MimeTypeParseException
Method Detail |
public int hashCode()
Object
java.util.Hashtable
.
The general contract of hashCode
is:
hashCode
method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
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 hashtables.
As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)
hashCode
in class Object
Object.equals(java.lang.Object)
,
Hashtable
public boolean equals(Object thatObject)
MimeType
s are equal if their primary types,
subtypes, and parameters are all equal. No default values
are taken into account.
equals
in class Object
thatObject
- the object to be evaluated as a
MimeType
true
if thatObject
is
a MimeType
; otherwise returns false
Object.hashCode()
,
Hashtable
private void parse(String rawdata) throws MimeTypeParseException
NullPointerException
- if rawdata
is null
MimeTypeParseException
public String getPrimaryType()
public String getSubType()
public MimeTypeParameterList getParameters()
public String getParameter(String name)
public void setParameter(String name, String value)
public void removeParameter(String name)
public String toString()
toString
in class Object
public String getBaseType()
public boolean match(MimeType type)
true
if the primary type and the
subtype of this object are the same as the specified
type
; otherwise returns false
.
type
- the type to compare to this
's type
true
if the primary type and the
subtype of this object are the same as the
specified type
; otherwise returns
false
public boolean match(String rawdata) throws MimeTypeParseException
true
if the primary type and the
subtype of this object are the same as the content type
described in rawdata
; otherwise returns
false
.
rawdata
- the raw data to be examined
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
MimeTypeParseException
public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
out
- the stream to write the object to
IOException
- Includes any I/O exceptions that may occurpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
in
- the stream to read data from in order to restore the object
ClassNotFoundException
- If the class for an object being
restored cannot be found.
IOException
- if I/O errors occurpublic Object clone()
clone
in class Object
Cloneable
private static boolean isTokenChar(char c)
private boolean isValidToken(String s)
NullPointerException
- if s
is null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |