Restlet Framework 2.2.2
Google Web Toolkit

org.restlet.client.data
Class MediaType

java.lang.Object
  extended by org.restlet.client.data.Metadata
      extended by org.restlet.client.data.MediaType

public final class MediaType
extends Metadata

Metadata used to specify the format of representations. The Metadata.getName() method returns a full String representation of the media type including the parameters.

Author:
Jerome Louvel
See Also:
MIME types on Wikipedia

Field Summary
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 Summary
MediaType(String name)
          Constructor.
MediaType(String name, Series<Parameter> parameters)
          Constructor.
MediaType(String name, Series<Parameter> parameters, String description)
          Constructor.
MediaType(String name, String description)
          Constructor.
 
Method Summary
 boolean equals(Object obj)
          
 boolean equals(Object obj, boolean ignoreParameters)
          Test the equality of two media types, with the possibility to ignore the parameters.
 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 MediaTypes.
 Series<Parameter> getParameters()
          Returns the unmodifiable list of parameters corresponding to subtype modifiers.
 MediaType getParent()
          Returns the parent metadata if available or null.
 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(String name, String description)
          Register a media type as a known type that can later be retrieved using valueOf(String).
static MediaType valueOf(String name)
          Returns the media type associated to a name.
 
Methods inherited from class org.restlet.client.data.Metadata
getDescription, getName, isCompatible, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ALL

public static final MediaType ALL

APPLICATION_ALL

public static final MediaType APPLICATION_ALL

APPLICATION_ALL_JSON

public static final MediaType APPLICATION_ALL_JSON

APPLICATION_ALL_XML

public static final MediaType APPLICATION_ALL_XML

APPLICATION_ATOM

public static final MediaType APPLICATION_ATOM

APPLICATION_JAVA_OBJECT_GWT

public static final MediaType APPLICATION_JAVA_OBJECT_GWT

APPLICATION_JAVASCRIPT

public static final MediaType APPLICATION_JAVASCRIPT

APPLICATION_JSON

public static final MediaType APPLICATION_JSON

APPLICATION_JSON_SMILE

public static final MediaType APPLICATION_JSON_SMILE

APPLICATION_MSML

public static final MediaType APPLICATION_MSML

APPLICATION_SDP

public static final MediaType APPLICATION_SDP

APPLICATION_WWW_FORM

public static final MediaType APPLICATION_WWW_FORM

APPLICATION_XHTML

public static final MediaType APPLICATION_XHTML

APPLICATION_XMI

public static final MediaType APPLICATION_XMI

APPLICATION_XML

public static final MediaType APPLICATION_XML

TEXT_ALL

public static final MediaType TEXT_ALL

TEXT_CSS

public static final MediaType TEXT_CSS

TEXT_HTML

public static final MediaType TEXT_HTML

TEXT_JAVASCRIPT

public static final MediaType TEXT_JAVASCRIPT

TEXT_PLAIN

public static final MediaType TEXT_PLAIN

TEXT_URI_LIST

public static final MediaType TEXT_URI_LIST

TEXT_XML

public static final MediaType TEXT_XML
Constructor Detail

MediaType

public MediaType(String name)
Constructor.

Parameters:
name - The name.

MediaType

public MediaType(String name,
                 Series<Parameter> parameters)
Constructor.

Parameters:
name - The name.
parameters - The list of parameters.

MediaType

public MediaType(String name,
                 Series<Parameter> parameters,
                 String description)
Constructor.

Parameters:
name - The name.
parameters - The list of parameters.
description - The description.

MediaType

public MediaType(String name,
                 String description)
Constructor.

Parameters:
name - The name.
description - The description.
Method Detail

getMostSpecific

public static MediaType getMostSpecific(MediaType... mediaTypes)
                                 throws IllegalArgumentException
Returns the first of the most specific media type of the given array of MediaTypes.

Examples:

Parameters:
mediaTypes - An array of media types.
Returns:
The most concrete MediaType.
Throws:
IllegalArgumentException - If the array is null or empty.

register

public static MediaType register(String name,
                                 String description)
Register a media type as a known type that can later be retrieved using valueOf(String). If the type already exists, the existing type is returned, otherwise a new instance is created.

Parameters:
name - The name.
description - The description.
Returns:
The registered media type

valueOf

public static MediaType valueOf(String name)
Returns the media type associated to a name. If an existing constant exists then it is returned, otherwise a new instance is created.

Parameters:
name - The name.
Returns:
The associated media type.

equals

public boolean equals(Object obj)

Overrides:
equals in class Metadata

equals

public boolean equals(Object obj,
                      boolean ignoreParameters)
Test the equality of two media types, with the possibility to ignore the parameters.

Parameters:
obj - The object to compare to.
ignoreParameters - Indicates if parameters should be ignored during comparison.
Returns:
True if both media types are equal.

getMainType

public String getMainType()
Returns the main type.

Returns:
The main type.

getParameters

public Series<Parameter> getParameters()
Returns the unmodifiable list of parameters corresponding to subtype modifiers. Creates a new instance if no one has been set.

Returns:
The list of parameters.

getParent

public MediaType getParent()
Returns the parent metadata if available or null.
In case the media type has parameters, this method returns the concatenation of the main type and the subtype. If the subtype is not equal to "*", it returns the concatenation of the main type and "*". Otherwise, it returns either the ALL media type if it is already the ALL media type, or null.

Specified by:
getParent in class Metadata
Returns:
The parent metadata.

getSubType

public String getSubType()
Returns the sub-type.

Returns:
The sub-type.

hashCode

public int hashCode()

Overrides:
hashCode in class Metadata

includes

public boolean includes(Metadata included)
Indicates if a given media type is included in the current one @see includes(Metadata, boolean). It ignores the parameters.

Specified by:
includes in class Metadata
Parameters:
included - The media type to test for inclusion.
Returns:
True if the given media type is included in the current one.
See Also:
Metadata.isCompatible(Metadata)

includes

public boolean includes(Metadata included,
                        boolean ignoreParameters)
Indicates if a given media type is included in the current one @see 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:

Parameters:
included - The media type to test for inclusion.
Returns:
True if the given media type is included in the current one.
See Also:
Metadata.isCompatible(Metadata)

isConcrete

public boolean isConcrete()
Checks if the current media type is concrete. A media type is concrete if neither the main type nor the sub-type are equal to "*".

Returns:
True if this media type is concrete.

Restlet Framework 2.2.2
Google Web Toolkit

Copyright © 2005-2014 Restlet.