public final class MediaType extends Metadata
Metadata.getName()
method returns a full String representation of the media
type including the parameters.Modifier and Type | Field and Description |
---|---|
static MediaType |
ALL |
static MediaType |
APPLICATION_ALL |
static MediaType |
APPLICATION_ALL_JSON |
static MediaType |
APPLICATION_ALL_XML |
static MediaType |
APPLICATION_ATOM |
static MediaType |
APPLICATION_JAVA_OBJECT_GWT |
static MediaType |
APPLICATION_JAVASCRIPT |
static MediaType |
APPLICATION_JSON |
static MediaType |
APPLICATION_JSON_SMILE |
static MediaType |
APPLICATION_MSML |
static MediaType |
APPLICATION_SDP |
static MediaType |
APPLICATION_WWW_FORM |
static MediaType |
APPLICATION_XHTML |
static MediaType |
APPLICATION_XMI |
static MediaType |
APPLICATION_XML |
static MediaType |
TEXT_ALL |
static MediaType |
TEXT_CSS |
static MediaType |
TEXT_HTML |
static MediaType |
TEXT_JAVASCRIPT |
static MediaType |
TEXT_PLAIN |
static MediaType |
TEXT_URI_LIST |
static MediaType |
TEXT_XML |
Constructor and Description |
---|
MediaType(java.lang.String name)
Constructor.
|
MediaType(java.lang.String name,
Series<Parameter> parameters)
Constructor.
|
MediaType(java.lang.String name,
Series<Parameter> parameters,
java.lang.String description)
Constructor.
|
MediaType(java.lang.String name,
java.lang.String description)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
boolean |
equals(java.lang.Object obj,
boolean ignoreParameters)
Test the equality of two media types, with the possibility to ignore the
parameters.
|
java.lang.String |
getMainType()
Returns the main type.
|
static MediaType |
getMostSpecific(MediaType... mediaTypes)
Returns the first of the most specific media type of the given array of
MediaType s. |
Series<Parameter> |
getParameters()
Returns the unmodifiable list of parameters corresponding to subtype
modifiers.
|
MediaType |
getParent()
Returns the parent metadata if available or null.
|
java.lang.String |
getSubType()
Returns the sub-type.
|
int |
hashCode() |
boolean |
includes(Metadata included)
Indicates if a given media type is included in the current one @see
includes(Metadata, boolean) . |
boolean |
includes(Metadata included,
boolean ignoreParameters)
Indicates if a given media type is included in the current one @see
includes(Metadata, boolean) . |
boolean |
isConcrete()
Checks if the current media type is concrete.
|
static MediaType |
register(java.lang.String name,
java.lang.String description)
Register a media type as a known type that can later be retrieved using
valueOf(String) . |
static MediaType |
valueOf(java.lang.String name)
Returns the media type associated to a name.
|
getDescription, getName, isCompatible, toString
public static final MediaType ALL
public static final MediaType APPLICATION_ALL
public static final MediaType APPLICATION_ALL_JSON
public static final MediaType APPLICATION_ALL_XML
public static final MediaType APPLICATION_ATOM
public static final MediaType APPLICATION_JAVA_OBJECT_GWT
public static final MediaType APPLICATION_JAVASCRIPT
public static final MediaType APPLICATION_JSON
public static final MediaType APPLICATION_JSON_SMILE
public static final MediaType APPLICATION_MSML
public static final MediaType APPLICATION_SDP
public static final MediaType APPLICATION_WWW_FORM
public static final MediaType APPLICATION_XHTML
public static final MediaType APPLICATION_XMI
public static final MediaType APPLICATION_XML
public static final MediaType TEXT_ALL
public static final MediaType TEXT_CSS
public static final MediaType TEXT_HTML
public static final MediaType TEXT_JAVASCRIPT
public static final MediaType TEXT_PLAIN
public static final MediaType TEXT_URI_LIST
public static final MediaType TEXT_XML
public MediaType(java.lang.String name)
name
- The name.public MediaType(java.lang.String name, Series<Parameter> parameters)
name
- The name.parameters
- The list of parameters.public MediaType(java.lang.String name, Series<Parameter> parameters, java.lang.String description)
name
- The name.parameters
- The list of parameters.description
- The description.public MediaType(java.lang.String name, java.lang.String description)
name
- The name.description
- The description.public static MediaType getMostSpecific(MediaType... mediaTypes) throws java.lang.IllegalArgumentException
MediaType
s.
Examples:
mediaTypes
- An array of media types.java.lang.IllegalArgumentException
- If the array is null or empty.public static MediaType register(java.lang.String name, java.lang.String description)
valueOf(String)
. If the type already exists, the existing type
is returned, otherwise a new instance is created.name
- The name.description
- The description.public static MediaType valueOf(java.lang.String name)
name
- The name.public boolean equals(java.lang.Object obj, boolean ignoreParameters)
obj
- The object to compare to.ignoreParameters
- Indicates if parameters should be ignored during comparison.public java.lang.String getMainType()
public Series<Parameter> getParameters()
public MediaType getParent()
ALL
media type if it is already
the ALL
media type, or null.public java.lang.String getSubType()
public boolean includes(Metadata included)
includes(Metadata, boolean)
. It ignores the parameters.includes
in class Metadata
included
- The media type to test for inclusion.Metadata.isCompatible(Metadata)
public boolean includes(Metadata included, boolean ignoreParameters)
includes(Metadata, boolean)
. The test is true if both types are
equal or if the given media type is within the range of the current one.
For example, ALL includes all media types. Parameters are ignored for
this comparison. A null media type is considered as included into the
current one. It ignores the parameters.
Examples:
included
- The media type to test for inclusion.Metadata.isCompatible(Metadata)
public boolean isConcrete()
Copyright © 2005-2020 Restlet.