Class MediaType
* character is treated as a wildcard and is used to represent any acceptable
type or subtype value. A media type may not have wildcard type with a declared subtype. The
* character has no special meaning as part of a parameter. All values for type, subtype,
parameter attributes or parameter values must be valid according to RFCs
2045 and
2046.
All portions of the media type that are case-insensitive (type, subtype, parameter attributes)
are normalized to lowercase. The value of the charset parameter is normalized to
lowercase, but all others are left as-is.
Note that this specifically does not represent the value of the MIME
Content-Type header and as such has no support for header-specific considerations such as
line folding and comments.
For media types that take a charset the predefined constants default to UTF-8 and have a
"_UTF_8" suffix. To get a version without a character set, use withoutParameters().
- Since:
- 12.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.This is a non-standard media type, but is commonly used in serving hosted binary files as it is known not to trigger content sniffing in current browsers.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.The media type for the Canon Image File Format (crwfiles), a widely-used "raw image" format for cameras.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.As described in the International Digital Publishing Forum EPUB is the distribution and interchange format standard for digital publications and documents.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.RFC 4329 declares this to be the correct media type for JavaScript, buttext/javascriptmay be necessary in certain situations for compatibility.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.As described in PKCS #12: Personal Information Exchange Syntax Standard, PKCS #12 defines an archive file format for storing many cryptography objects as a single file.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.The media type for the Photoshop File Format (psdfiles) as defined by IANA, and found in/etc/mime.types, e.g.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.RFC 4329 declaresapplication/javascriptto be the correct media type for JavaScript, but this may be necessary in certain situations for compatibility.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.static final MediaTypeDeprecated.As described in RFC 3023, this constant (text/xml) is used for XML documents that are "readable by casual users."APPLICATION_XML_UTF_8is provided for documents that are intended for applications.static final MediaTypeDeprecated.Media type for Extensible Resource Descriptors.static final MediaTypeDeprecated. -
Method Summary
Modifier and TypeMethodDescriptioncharset()Deprecated.Returns an optional charset for the value of the charset parameter if it is specified.static MediaTypeDeprecated.Creates a new media type with the given type and subtype.booleanDeprecated.inthashCode()Deprecated.booleanDeprecated.Returns true if either the type or subtype is the wildcard.booleanDeprecated.Returnstrueif this instance falls within the range (as defined by the HTTP Accept header) given by the argument according to three criteria: The type of the argument is the wildcard or equal to the type of this instance.Deprecated.Returns a multimap containing the parameters of this media type.static MediaTypeDeprecated.Parses a media type from its string representation.subtype()Deprecated.Returns the media subtype.toString()Deprecated.Returns the string representation of this media type in the format described in RFC 2045.type()Deprecated.Returns the top-level media type.withCharset(Charset charset) Deprecated.Returns a new instance with the same type and subtype as this instance, with thecharsetparameter set to thenameof the given charset.Deprecated.Returns a new instance with the same type and subtype as this instance, but without any parameters.withParameter(String attribute, String value) Deprecated.Replaces all parameters with the given attribute with a single parameter with the given value.withParameters(Multimap<String, String> parameters) Deprecated.Replaces all parameters with the given parameters.
-
Field Details
-
ANY_TYPE
Deprecated. -
ANY_TEXT_TYPE
Deprecated. -
ANY_IMAGE_TYPE
Deprecated. -
ANY_AUDIO_TYPE
Deprecated. -
ANY_VIDEO_TYPE
Deprecated. -
ANY_APPLICATION_TYPE
Deprecated. -
CACHE_MANIFEST_UTF_8
Deprecated. -
CSS_UTF_8
Deprecated. -
CSV_UTF_8
Deprecated. -
HTML_UTF_8
Deprecated. -
I_CALENDAR_UTF_8
Deprecated. -
PLAIN_TEXT_UTF_8
Deprecated. -
TEXT_JAVASCRIPT_UTF_8
Deprecated.RFC 4329 declaresapplication/javascriptto be the correct media type for JavaScript, but this may be necessary in certain situations for compatibility. -
TSV_UTF_8
Deprecated.- Since:
- 15.0
-
VCARD_UTF_8
Deprecated. -
WML_UTF_8
Deprecated. -
XML_UTF_8
Deprecated.As described in RFC 3023, this constant (text/xml) is used for XML documents that are "readable by casual users."APPLICATION_XML_UTF_8is provided for documents that are intended for applications. -
BMP
Deprecated. -
CRW
Deprecated.The media type for the Canon Image File Format (crwfiles), a widely-used "raw image" format for cameras. It is found in/etc/mime.types, e.g. in invalid input: '<'href= "http://anonscm.debian.org/gitweb/?p=collab-maint/mime-support.git;a=blob;f=mime.types;hb=HEAD" >Debian 3.48-1.- Since:
- 15.0
-
GIF
Deprecated. -
ICO
Deprecated. -
JPEG
Deprecated. -
PNG
Deprecated. -
PSD
Deprecated.The media type for the Photoshop File Format (psdfiles) as defined by IANA, and found in/etc/mime.types, e.g. of the Apache HTTPD project; for the specification, see invalid input: '<'href="http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/PhotoshopFileFormats.htm"> Adobe Photoshop Document Format and Wikipedia; this is the regular output/input of Photoshop (which can also export to various image formats; note that files with extension "PSB" are in a distinct but related format).This is a more recent replacement for the older, experimental type
x-photoshop: RFC-2046.6.- Since:
- 15.0
-
SVG_UTF_8
Deprecated. -
TIFF
Deprecated. -
WEBP
Deprecated. -
MP4_AUDIO
Deprecated. -
MPEG_AUDIO
Deprecated. -
OGG_AUDIO
Deprecated. -
WEBM_AUDIO
Deprecated. -
MP4_VIDEO
Deprecated. -
MPEG_VIDEO
Deprecated. -
OGG_VIDEO
Deprecated. -
QUICKTIME
Deprecated. -
WEBM_VIDEO
Deprecated. -
WMV
Deprecated. -
APPLICATION_XML_UTF_8
Deprecated. -
ATOM_UTF_8
Deprecated. -
BZIP2
Deprecated. -
EPUB
Deprecated.As described in the International Digital Publishing Forum EPUB is the distribution and interchange format standard for digital publications and documents. This media type is defined in the EPUB Open Container Format specification.- Since:
- 15.0
-
FORM_DATA
Deprecated. -
KEY_ARCHIVE
Deprecated.As described in PKCS #12: Personal Information Exchange Syntax Standard, PKCS #12 defines an archive file format for storing many cryptography objects as a single file.- Since:
- 15.0
-
APPLICATION_BINARY
Deprecated.This is a non-standard media type, but is commonly used in serving hosted binary files as it is known not to trigger content sniffing in current browsers. It should not be used in other situations as it is not specified by any RFC and does not appear in the /IANA MIME Media Types list. ConsiderOCTET_STREAMfor binary data that is not being served to a browser.- Since:
- 14.0
-
GZIP
Deprecated. -
JAVASCRIPT_UTF_8
Deprecated.RFC 4329 declares this to be the correct media type for JavaScript, buttext/javascriptmay be necessary in certain situations for compatibility. -
JSON_UTF_8
Deprecated. -
KML
Deprecated. -
KMZ
Deprecated. -
MBOX
Deprecated. -
MICROSOFT_EXCEL
Deprecated. -
MICROSOFT_POWERPOINT
Deprecated. -
MICROSOFT_WORD
Deprecated. -
OCTET_STREAM
Deprecated. -
OGG_CONTAINER
Deprecated. -
OOXML_DOCUMENT
Deprecated. -
OOXML_PRESENTATION
Deprecated. -
OOXML_SHEET
Deprecated. -
OPENDOCUMENT_GRAPHICS
Deprecated. -
OPENDOCUMENT_PRESENTATION
Deprecated. -
OPENDOCUMENT_SPREADSHEET
Deprecated. -
OPENDOCUMENT_TEXT
Deprecated. -
PDF
Deprecated. -
POSTSCRIPT
Deprecated. -
PROTOBUF
Deprecated.- Since:
- 15.0
-
RDF_XML_UTF_8
Deprecated. -
RTF_UTF_8
Deprecated. -
SHOCKWAVE_FLASH
Deprecated. -
SKETCHUP
Deprecated. -
TAR
Deprecated. -
XHTML_UTF_8
Deprecated. -
XRD_UTF_8
Deprecated.Media type for Extensible Resource Descriptors. This is not yet registered with the IANA, but it is specified by OASIS in the XRD definition and implemented in projects such as WebFinger. -
ZIP
Deprecated.
-
-
Method Details
-
type
Deprecated.Returns the top-level media type. For example,"text"in"text/plain". -
subtype
Deprecated.Returns the media subtype. For example,"plain"in"text/plain". -
parameters
Deprecated.Returns a multimap containing the parameters of this media type. -
charset
Deprecated.Returns an optional charset for the value of the charset parameter if it is specified.- Throws:
IllegalStateException- if multiple charset values have been set for this media typeIllegalCharsetNameException- if a charset value is present, but illegalUnsupportedCharsetException- if a charset value is present, but no support is available in this instance of the Java virtual machine
-
withoutParameters
Deprecated.Returns a new instance with the same type and subtype as this instance, but without any parameters. -
withParameters
Deprecated.Replaces all parameters with the given parameters.- Throws:
IllegalArgumentException- if any parameter or value is invalid
-
withParameter
Deprecated.Replaces all parameters with the given attribute with a single parameter with the given value. If multiple parameters with the same attributes are necessary usewithParameters(com.google.common.collect.Multimap<java.lang.String, java.lang.String>). PreferwithCharset(java.nio.charset.Charset)for setting thecharsetparameter when using aCharsetobject.- Throws:
IllegalArgumentException- if eitherattributeorvalueis invalid
-
withCharset
Deprecated.Returns a new instance with the same type and subtype as this instance, with thecharsetparameter set to thenameof the given charset. Only onecharsetparameter will be present on the new instance regardless of the number set on this one.If a charset must be specified that is not supported on this JVM (and thus is not representable as a
Charsetinstance, usewithParameter(java.lang.String, java.lang.String). -
hasWildcard
public boolean hasWildcard()Deprecated.Returns true if either the type or subtype is the wildcard. -
is
Deprecated.Returnstrueif this instance falls within the range (as defined by the HTTP Accept header) given by the argument according to three criteria:- The type of the argument is the wildcard or equal to the type of this instance.
- The subtype of the argument is the wildcard or equal to the subtype of this instance.
- All of the parameters present in the argument are present in this instance.
For example:
PLAIN_TEXT_UTF_8.is(PLAIN_TEXT_UTF_8) // true PLAIN_TEXT_UTF_8.is(HTML_UTF_8) // false PLAIN_TEXT_UTF_8.is(ANY_TYPE) // true PLAIN_TEXT_UTF_8.is(ANY_TEXT_TYPE) // true PLAIN_TEXT_UTF_8.is(ANY_IMAGE_TYPE) // false PLAIN_TEXT_UTF_8.is(ANY_TEXT_TYPE.withCharset(UTF_8)) // true PLAIN_TEXT_UTF_8.withoutParameters().is(ANY_TEXT_TYPE.withCharset(UTF_8)) // false PLAIN_TEXT_UTF_8.is(ANY_TEXT_TYPE.withCharset(UTF_16)) // falseNote that while it is possible to have the same parameter declared multiple times within a media type this method does not consider the number of occurrences of a parameter. For example,
"text/plain; charset=UTF-8"satisfies"text/plain; charset=UTF-8; charset=UTF-8". -
create
Deprecated.Creates a new media type with the given type and subtype.- Throws:
IllegalArgumentException- if type or subtype is invalid or if a wildcard is used for the type, but not the subtype.
-
parse
Deprecated.Parses a media type from its string representation.- Throws:
IllegalArgumentException- if the input is not parsable
-
equals
Deprecated. -
hashCode
public int hashCode()Deprecated. -
toString
Deprecated.Returns the string representation of this media type in the format described in RFC 2045.
-