java.lang.Object
de.grogra.util.MimeType
- All Implemented Interfaces:
Serializable
This class implements a MIME type as specified by RFC 2045 and 2046.
A MIME type consists of the specification of a top-level media type
and a subtype, e.g.,
text/plain, and a (possibly empty)
set of parameters. In the string representation of a MIME type,
parameters are specified as the parameter charset in
text/plain; charset=iso-8859-1.- Author:
- Ole Kniemeyer
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final MimeTypeThe MIME typeapplication/xmlwithout parameters.static final StringThe nameclassof the parameter which indicates the Java class of the MIME typeJAVA_OBJECT.static final MimeTypeThe MIME typetext/x-csvwithout parameters.static final MimeTypeThe MIME typeapplication/x-gzipwithout parameters.static final MimeTypestatic final MimeTypeThe MIME typeapplication/x-jarwithout parameters.static final StringThe MIME type of local Java objects,application/x-java-jvm-local-objectref, as string.static final MimeTypeThe MIME typeapplication/octet-streamwithout parameters.static final MimeTypeThe MIME typeapplication/pdfwithout parameters.static final MimeTypeThe MIME typeimage/pngwithout parameters.static final MimeTypeThe MIME typeapplication/postscriptwithout parameters.static final MimeTypeThe MIME typetext/htmlwithout parameters.static final MimeTypeThe MIME typetext/plainwithout parameters.static final MimeTypeThe MIME typetext/scifor greenscilab parameter files.static final MimeTypeThe MIME typetext/xmlwithout parameters.static final String -
Constructor Summary
ConstructorsConstructorDescriptionParsesmimeTypeand constructs a newMimeTypeusing the parsed information.Constructs a newMimeTypefor the given parameters.Constructs a newMimeTypefor the given parameters. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the comment which has been parsed from the MIME type specification.Returns the media type of this MIME type asString, e.g.,text/plain.getParameter(String name) Returns the primary type of this MIME type, e.g.,textfor the media typetext/plain.Returns the subtype of this MIME type, e.g.,plainfor the media typetext/plain.inthashCode()booleanstatic booleanisAssignableFrom(String target, String source) booleanstatic StringtoString()static MimeTypeReturns a MIME type of media typeJAVA_OBJECTand representation classcls.static MimeTypeParsesmimeTypeand constructs a newMimeTypeas inMimeType(String); ifmimeTypeisnull,nullis returned.
-
Field Details
-
INVALID
-
TEXT_PLAIN
The MIME typetext/plainwithout parameters. -
TEXT_XML
The MIME typetext/xmlwithout parameters. -
TEXT_HTML
The MIME typetext/htmlwithout parameters. -
APPLICATION_XML
The MIME typeapplication/xmlwithout parameters. -
OCTET_STREAM
The MIME typeapplication/octet-streamwithout parameters. -
GZIP
The MIME typeapplication/x-gzipwithout parameters. -
JAR
The MIME typeapplication/x-jarwithout parameters. -
CSV
The MIME typetext/x-csvwithout parameters. -
PDF
The MIME typeapplication/pdfwithout parameters. -
POSTSCRIPT
The MIME typeapplication/postscriptwithout parameters. -
PNG
The MIME typeimage/pngwithout parameters. -
TEXT_SCI
The MIME typetext/scifor greenscilab parameter files. -
WRAPPED_TYPE_PARAM
- See Also:
-
CLASS_PARAM
The nameclassof the parameter which indicates the Java class of the MIME typeJAVA_OBJECT.- See Also:
-
JAVA_OBJECT
The MIME type of local Java objects,application/x-java-jvm-local-objectref, as string.- See Also:
-
-
Constructor Details
-
MimeType
Constructs a newMimeTypefor the given parameters.- Parameters:
mediaType- the media type (e.g.,text/plain)params- the parameters of the MIME typecls- the representation class of data of this MIME type
-
MimeType
Constructs a newMimeTypefor the given parameters.- Parameters:
mediaType- the media type (e.g.,text/plain)params- the parameters of the MIME type
-
MimeType
ParsesmimeTypeand constructs a newMimeTypeusing the parsed information. The complete syntax of RFC 2045 is supported.- Parameters:
mimeType- MIME type specification according to RFC 2045
-
-
Method Details
-
valueOf
Returns a MIME type of media typeJAVA_OBJECTand representation classcls.- Parameters:
cls- class of Java objects- Returns:
- MIME type corresponding to local Java objects
of class
cls
-
valueOf
ParsesmimeTypeand constructs a newMimeTypeas inMimeType(String); ifmimeTypeisnull,nullis returned.- Parameters:
mimeType- MIME type specification according to RFC 2045- Returns:
MimeTypeinstance ornull
-
getMediaType
Returns the media type of this MIME type asString, e.g.,text/plain. This does not contain parameters.- Returns:
- media type of this MIME type
-
getPrimaryType
Returns the primary type of this MIME type, e.g.,textfor the media typetext/plain.- Returns:
- primary type of this MIME type
-
getSubType
Returns the subtype of this MIME type, e.g.,plainfor the media typetext/plain.- Returns:
- subtype of this MIME type
-
getComment
Returns the comment which has been parsed from the MIME type specification.- Returns:
- MIME type comment
-
getParameter
-
getParameters
-
getRepresentationClass
-
isXMLMimeType
public boolean isXMLMimeType() -
isAssignableFrom
-
isAssignableFrom
-
equals
-
hashCode
public int hashCode() -
toString
-
quoteParameter
-