|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.w3c.www.mime.MimeType
public class MimeType
This class is used to represent parsed MIME types. It creates this representation from a string based representation of the MIME type, as defined in the RFC 1345.
Field Summary | |
---|---|
static MimeType |
APPLICATION_OCTET_STREAM
|
static MimeType |
APPLICATION_POSTSCRIPT
|
static MimeType |
APPLICATION_RDF_XML
|
static MimeType |
APPLICATION_X_JAVA_AGENT
|
static MimeType |
APPLICATION_X_WWW_FORM_URLENCODED
|
static MimeType |
APPLICATION_XHTML_XML
|
static MimeType |
APPLICATION_XML
|
protected java.lang.String |
external
external form of this mime type |
static int |
MATCH_SPECIFIC_SUBTYPE
|
static int |
MATCH_SPECIFIC_TYPE
|
static int |
MATCH_SUBTYPE
|
static int |
MATCH_TYPE
|
static MimeType |
MESSAGE_HTTP
|
static MimeType |
MULTIPART_FORM_DATA
|
static int |
NO_MATCH
|
protected java.lang.String[] |
pnames
parameter names |
protected java.lang.String[] |
pvalues
parameter values |
static java.lang.String |
star
|
protected java.lang.String |
subtype
String representation of subtype |
static MimeType |
TEXT
|
static MimeType |
TEXT_CSS
|
static MimeType |
TEXT_HTML
List of well known MIME types: |
static MimeType |
TEXT_PLAIN
|
static MimeType |
TEXT_XML
|
protected java.lang.String |
type
String representation of type |
Constructor Summary | |
---|---|
MimeType(java.lang.String spec)
Construct MimeType object for the given string. |
|
MimeType(java.lang.String type,
java.lang.String subtype)
|
|
MimeType(java.lang.String type,
java.lang.String subtype,
java.lang.String[] pnames,
java.lang.String[] pvalues)
|
Method Summary | |
---|---|
void |
addParameter(java.lang.String param,
java.lang.String value)
adds a parameterto a MimeType |
void |
addParameters(java.lang.String[] param,
java.lang.String[] values)
adds some parameters to a MimeType |
boolean |
equiv(MimeType mtype)
Find out if mime types are equivalent, based on heuristics like text/xml <=> application/xml and other problems related to format that may have multiple mime types. |
MimeType |
getClone()
get a clone of this object |
java.lang.String |
getParameterValue(java.lang.String name)
Get a mime type parameter value. |
java.lang.String |
getSubtype()
Get the minor type (subtype) of this mime type. |
java.lang.String |
getType()
Get the major type of this mime type. |
boolean |
hasParameter(java.lang.String name)
Does this MIME type has some value for the given parameter ? |
static void |
main(java.lang.String[] args)
|
int |
match(MimeType other)
How good the given MimeType matches the receiver of the method ? This method returns a matching level among: NO_MATCHTypes not matching, MATCH_TYPETypes match, MATCH_SPECIFIC_TYPETypes match exactly, MATCH_SUBTYPETypes match, subtypes matches too MATCH_SPECIFIC_SUBTYPETypes match, subtypes matches exactly The matches are ranked from worst match to best match, a simple Max ( match[i], matched) will give the best match. |
void |
setParameter(java.lang.String param,
java.lang.String value)
Set the parameter to a MimeType (replace old value if any). |
java.lang.String |
toString()
A printable representation of this MimeType. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static MimeType TEXT_HTML
public static MimeType APPLICATION_POSTSCRIPT
public static MimeType TEXT_PLAIN
public static MimeType APPLICATION_X_WWW_FORM_URLENCODED
public static MimeType APPLICATION_OCTET_STREAM
public static MimeType MULTIPART_FORM_DATA
public static MimeType APPLICATION_X_JAVA_AGENT
public static MimeType MESSAGE_HTTP
public static MimeType TEXT_CSS
public static MimeType TEXT_XML
public static MimeType APPLICATION_XML
public static MimeType TEXT
public static MimeType APPLICATION_RDF_XML
public static MimeType APPLICATION_XHTML_XML
public static java.lang.String star
public static final int NO_MATCH
public static final int MATCH_TYPE
public static final int MATCH_SPECIFIC_TYPE
public static final int MATCH_SUBTYPE
public static final int MATCH_SPECIFIC_SUBTYPE
protected java.lang.String type
protected java.lang.String subtype
protected java.lang.String[] pnames
protected java.lang.String[] pvalues
protected java.lang.String external
Constructor Detail |
---|
public MimeType(java.lang.String spec) throws MimeTypeFormatException
MimeTypeFormatException
- if the string couldn't be parsed.public MimeType(java.lang.String type, java.lang.String subtype, java.lang.String[] pnames, java.lang.String[] pvalues)
public MimeType(java.lang.String type, java.lang.String subtype)
Method Detail |
---|
public int match(MimeType other)
other
- The other MimeType to match against ourself.public boolean equiv(MimeType mtype)
mtype,
- a MimeType
public java.lang.String toString()
toString
in class java.lang.Object
public boolean hasParameter(java.lang.String name)
name
- The parameter to check.
public java.lang.String getType()
public java.lang.String getSubtype()
public java.lang.String getParameterValue(java.lang.String name)
name
- The parameter whose value is to be returned.
public void addParameters(java.lang.String[] param, java.lang.String[] values)
param
- a String array of parameter namesvalues
- the corresponding String array of valuespublic MimeType getClone()
public void addParameter(java.lang.String param, java.lang.String value)
param
- the parameter name, as a Stringvalue
- the parameter value, as a Stingpublic void setParameter(java.lang.String param, java.lang.String value)
param
- the parameter name, as a Stringvalue
- the parameter value, as a Stingpublic static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |