public class MediaType extends Object
Modifier and Type | Field and Description |
---|---|
static String |
APPLICATION_ATOM_XML
"application/atom+xml"
|
static MediaType |
APPLICATION_ATOM_XML_TYPE
"application/atom+xml"
|
static String |
APPLICATION_FORM_URLENCODED
"application/x-www-form-urlencoded"
|
static MediaType |
APPLICATION_FORM_URLENCODED_TYPE
"application/x-www-form-urlencoded"
|
static String |
APPLICATION_JSON
"application/json"
|
static MediaType |
APPLICATION_JSON_TYPE
"application/json"
|
static String |
APPLICATION_OCTET_STREAM
"application/octet-stream"
|
static MediaType |
APPLICATION_OCTET_STREAM_TYPE
"application/octet-stream"
|
static String |
APPLICATION_SVG_XML
"application/svg+xml"
|
static MediaType |
APPLICATION_SVG_XML_TYPE
"application/svg+xml"
|
static String |
APPLICATION_XHTML_XML
"application/xhtml+xml"
|
static MediaType |
APPLICATION_XHTML_XML_TYPE
"application/xhtml+xml"
|
static String |
APPLICATION_XML
"application/xml"
|
static MediaType |
APPLICATION_XML_TYPE
"application/xml"
|
static String |
MEDIA_TYPE_WILDCARD
The value of a type or subtype wildcard: "*"
|
static String |
MULTIPART_FORM_DATA
"multipart/form-data"
|
static MediaType |
MULTIPART_FORM_DATA_TYPE
"multipart/form-data"
|
static String |
TEXT_HTML
"text/html"
|
static MediaType |
TEXT_HTML_TYPE
"text/html"
|
static String |
TEXT_PLAIN
"text/plain"
|
static MediaType |
TEXT_PLAIN_TYPE
"text/plain"
|
static String |
TEXT_XML
"text/xml"
|
static MediaType |
TEXT_XML_TYPE
"text/xml"
|
static String |
WILDCARD
"*/*"
|
static MediaType |
WILDCARD_TYPE
"*/*"
|
Constructor and Description |
---|
MediaType()
Creates a new instance of MediaType, both type and subtype are wildcards.
|
MediaType(String type,
String subtype)
Creates a new instance of MediaType with the supplied type and subtype.
|
MediaType(String type,
String subtype,
Map<String,String> parameters)
Creates a new instance of MediaType with the supplied type, subtype and
parameters.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
Compares obj to this media type to see if they are the same by comparing
type, subtype and parameters.
|
Map<String,String> |
getParameters()
Getter for a read-only parameter map.
|
String |
getSubtype()
Getter for subtype.
|
String |
getType()
Getter for primary type.
|
int |
hashCode()
Generate a hashcode from the type, subtype and parameters.
|
boolean |
isCompatible(MediaType other)
Check if this media type is compatible with another media type.
|
boolean |
isWildcardSubtype()
Checks if the subtype is a wildcard
|
boolean |
isWildcardType()
Checks if the primary type is a wildcard.
|
String |
toString()
Convert the media type to a string suitable for use as the value of a
corresponding HTTP header.
|
static MediaType |
valueOf(String type)
Creates a new instance of MediaType by parsing the supplied string.
|
public static final String MEDIA_TYPE_WILDCARD
public static final String WILDCARD
public static final MediaType WILDCARD_TYPE
public static final String APPLICATION_XML
public static final MediaType APPLICATION_XML_TYPE
public static final String APPLICATION_ATOM_XML
public static final MediaType APPLICATION_ATOM_XML_TYPE
public static final String APPLICATION_XHTML_XML
public static final MediaType APPLICATION_XHTML_XML_TYPE
public static final String APPLICATION_SVG_XML
public static final MediaType APPLICATION_SVG_XML_TYPE
public static final String APPLICATION_JSON
public static final MediaType APPLICATION_JSON_TYPE
public static final String APPLICATION_FORM_URLENCODED
public static final MediaType APPLICATION_FORM_URLENCODED_TYPE
public static final String MULTIPART_FORM_DATA
public static final MediaType MULTIPART_FORM_DATA_TYPE
public static final String APPLICATION_OCTET_STREAM
public static final MediaType APPLICATION_OCTET_STREAM_TYPE
public static final String TEXT_PLAIN
public static final MediaType TEXT_PLAIN_TYPE
public static final String TEXT_XML
public static final MediaType TEXT_XML_TYPE
public static final String TEXT_HTML
public static final MediaType TEXT_HTML_TYPE
public MediaType(String type, String subtype, Map<String,String> parameters)
type
- the primary type, null is equivalent to
MEDIA_TYPE_WILDCARD
.subtype
- the subtype, null is equivalent to
MEDIA_TYPE_WILDCARD
.parameters
- a map of media type parameters, null is the same as an
empty map.public MediaType(String type, String subtype)
type
- the primary type, null is equivalent to
MEDIA_TYPE_WILDCARD
subtype
- the subtype, null is equivalent to
MEDIA_TYPE_WILDCARD
public MediaType()
WILDCARD_TYPE
instead.public static MediaType valueOf(String type) throws IllegalArgumentException
type
- the media type stringIllegalArgumentException
- if the supplied string cannot be parsed
or is nullpublic String getType()
public boolean isWildcardType()
public String getSubtype()
public boolean isWildcardSubtype()
public Map<String,String> getParameters()
public boolean isCompatible(MediaType other)
other
- the media type to compare withpublic boolean equals(Object obj)
public int hashCode()
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.