org.restlet.data
Class MediaType

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

public final class MediaType
extends Metadata

Media type used in representations and preferences.

Author:
Jerome Louvel
See Also:
MIME types on Wikipedia

Field Summary
static MediaType ALL
           
static MediaType APPLICATION_ALL
           
static MediaType APPLICATION_ALL_XML
           
static MediaType APPLICATION_ATOM_SERVICE_XML
           
static MediaType APPLICATION_ATOM_XML
           
static MediaType APPLICATION_CAB
           
static MediaType APPLICATION_COMPRESS
           
static MediaType APPLICATION_EXCEL
           
static MediaType APPLICATION_FLASH
           
static MediaType APPLICATION_GNU_TAR
           
static MediaType APPLICATION_GNU_ZIP
           
static MediaType APPLICATION_HTTP_COOKIES
           
static MediaType APPLICATION_JAVA
           
static MediaType APPLICATION_JAVA_ARCHIVE
           
static MediaType APPLICATION_JAVA_OBJECT
           
static MediaType APPLICATION_JAVASCRIPT
           
static MediaType APPLICATION_JNLP
           
static MediaType APPLICATION_JSON
           
static MediaType APPLICATION_LATEX
           
static MediaType APPLICATION_MAC_BINHEX40
           
static MediaType APPLICATION_MATHML_XML
           
static MediaType APPLICATION_OCTET_STREAM
           
static MediaType APPLICATION_PDF
           
static MediaType APPLICATION_POSTSCRIPT
           
static MediaType APPLICATION_POWERPOINT
           
static MediaType APPLICATION_PROJECT
           
static MediaType APPLICATION_RDF_XML
           
static MediaType APPLICATION_RELAXNG_COMPACT
           
static MediaType APPLICATION_RELAXNG_XML
           
static MediaType APPLICATION_RSS_XML
           
static MediaType APPLICATION_RTF
           
static MediaType APPLICATION_STUFFIT
           
static MediaType APPLICATION_TAR
           
static MediaType APPLICATION_TEX
           
static MediaType APPLICATION_TROFF_MAN
           
static MediaType APPLICATION_VOICEXML
           
static MediaType APPLICATION_W3C_SCHEMA_XML
           
static MediaType APPLICATION_W3C_XSLT
           
static MediaType APPLICATION_WADL_XML
           
static MediaType APPLICATION_WORD
           
static MediaType APPLICATION_WWW_FORM
           
static MediaType APPLICATION_XHTML_XML
           
static MediaType APPLICATION_XML
           
static MediaType APPLICATION_XML_DTD
           
static MediaType APPLICATION_XUL
           
static MediaType APPLICATION_ZIP
           
static MediaType AUDIO_ALL
           
static MediaType AUDIO_BASIC
           
static MediaType AUDIO_MIDI
           
static MediaType AUDIO_MPEG
           
static MediaType AUDIO_REAL
           
static MediaType AUDIO_WAV
           
static MediaType IMAGE_ALL
           
static MediaType IMAGE_BMP
           
static MediaType IMAGE_GIF
           
static MediaType IMAGE_ICON
           
static MediaType IMAGE_JPEG
           
static MediaType IMAGE_PNG
           
static MediaType IMAGE_SVG
           
static MediaType IMAGE_TIFF
           
static MediaType MESSAGE_ALL
           
static MediaType MODEL_ALL
           
static MediaType MODEL_VRML
           
static MediaType MULTIPART_ALL
           
static MediaType MULTIPART_FORM_DATA
           
static MediaType TEXT_ALL
           
static MediaType TEXT_CALENDAR
           
static MediaType TEXT_CSS
           
static MediaType TEXT_HTML
           
static MediaType TEXT_J2ME_APP_DESCRIPTOR
           
static MediaType TEXT_JAVASCRIPT
           
static MediaType TEXT_PLAIN
           
static MediaType TEXT_RDF_N3
           
static MediaType TEXT_URI_LIST
           
static MediaType TEXT_VCARD
           
static MediaType TEXT_XML
           
static MediaType VIDEO_ALL
           
static MediaType VIDEO_AVI
           
static MediaType VIDEO_MP4
           
static MediaType VIDEO_MPEG
           
static MediaType VIDEO_QUICKTIME
           
static MediaType VIDEO_WMV
           
 
Constructor Summary
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.
 
Method Summary
 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 MediaTypes of the given array of MediaTypes.
 Series<Parameter> getParameters()
          Returns the modifiable list of parameters.
 java.lang.String getSubType()
          Returns the sub-type.
 int hashCode()
          
 boolean includes(MediaType included)
          Indicates if a given media type is included in the current one.
 boolean isCompatible(MediaType otherMediaType)
          Checks if this MediaType is compatible with the given media type.
 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).
 java.lang.String toString()
          Returns the metadata name.
static MediaType valueOf(java.lang.String name)
          Returns the media type associated to a name.
 
Methods inherited from class org.restlet.data.Metadata
getDescription, getName
 
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_XML

public static final MediaType APPLICATION_ALL_XML

APPLICATION_ATOM_SERVICE_XML

public static final MediaType APPLICATION_ATOM_SERVICE_XML

APPLICATION_ATOM_XML

public static final MediaType APPLICATION_ATOM_XML

APPLICATION_CAB

public static final MediaType APPLICATION_CAB

APPLICATION_COMPRESS

public static final MediaType APPLICATION_COMPRESS

APPLICATION_EXCEL

public static final MediaType APPLICATION_EXCEL

APPLICATION_FLASH

public static final MediaType APPLICATION_FLASH

APPLICATION_GNU_TAR

public static final MediaType APPLICATION_GNU_TAR

APPLICATION_GNU_ZIP

public static final MediaType APPLICATION_GNU_ZIP

APPLICATION_HTTP_COOKIES

public static final MediaType APPLICATION_HTTP_COOKIES

APPLICATION_JAVA

public static final MediaType APPLICATION_JAVA

APPLICATION_JAVA_ARCHIVE

public static final MediaType APPLICATION_JAVA_ARCHIVE

APPLICATION_JAVA_OBJECT

public static final MediaType APPLICATION_JAVA_OBJECT

APPLICATION_JAVASCRIPT

public static final MediaType APPLICATION_JAVASCRIPT

APPLICATION_JNLP

public static final MediaType APPLICATION_JNLP

APPLICATION_JSON

public static final MediaType APPLICATION_JSON

APPLICATION_LATEX

public static final MediaType APPLICATION_LATEX

APPLICATION_MAC_BINHEX40

public static final MediaType APPLICATION_MAC_BINHEX40

APPLICATION_MATHML_XML

public static final MediaType APPLICATION_MATHML_XML

APPLICATION_OCTET_STREAM

public static final MediaType APPLICATION_OCTET_STREAM

APPLICATION_PDF

public static final MediaType APPLICATION_PDF

APPLICATION_POSTSCRIPT

public static final MediaType APPLICATION_POSTSCRIPT

APPLICATION_POWERPOINT

public static final MediaType APPLICATION_POWERPOINT

APPLICATION_PROJECT

public static final MediaType APPLICATION_PROJECT

APPLICATION_RDF_XML

public static final MediaType APPLICATION_RDF_XML

APPLICATION_RELAXNG_COMPACT

public static final MediaType APPLICATION_RELAXNG_COMPACT

APPLICATION_RELAXNG_XML

public static final MediaType APPLICATION_RELAXNG_XML

APPLICATION_RSS_XML

public static final MediaType APPLICATION_RSS_XML

APPLICATION_RTF

public static final MediaType APPLICATION_RTF

APPLICATION_STUFFIT

public static final MediaType APPLICATION_STUFFIT

APPLICATION_TAR

public static final MediaType APPLICATION_TAR

APPLICATION_TEX

public static final MediaType APPLICATION_TEX

APPLICATION_TROFF_MAN

public static final MediaType APPLICATION_TROFF_MAN

APPLICATION_VOICEXML

public static final MediaType APPLICATION_VOICEXML

APPLICATION_W3C_SCHEMA_XML

public static final MediaType APPLICATION_W3C_SCHEMA_XML

APPLICATION_W3C_XSLT

public static final MediaType APPLICATION_W3C_XSLT

APPLICATION_WADL_XML

public static final MediaType APPLICATION_WADL_XML

APPLICATION_WORD

public static final MediaType APPLICATION_WORD

APPLICATION_WWW_FORM

public static final MediaType APPLICATION_WWW_FORM

APPLICATION_XHTML_XML

public static final MediaType APPLICATION_XHTML_XML

APPLICATION_XML

public static final MediaType APPLICATION_XML

APPLICATION_XML_DTD

public static final MediaType APPLICATION_XML_DTD

APPLICATION_XUL

public static final MediaType APPLICATION_XUL

APPLICATION_ZIP

public static final MediaType APPLICATION_ZIP

AUDIO_ALL

public static final MediaType AUDIO_ALL

AUDIO_BASIC

public static final MediaType AUDIO_BASIC

AUDIO_MIDI

public static final MediaType AUDIO_MIDI

AUDIO_MPEG

public static final MediaType AUDIO_MPEG

AUDIO_REAL

public static final MediaType AUDIO_REAL

AUDIO_WAV

public static final MediaType AUDIO_WAV

IMAGE_ALL

public static final MediaType IMAGE_ALL

IMAGE_BMP

public static final MediaType IMAGE_BMP

IMAGE_GIF

public static final MediaType IMAGE_GIF

IMAGE_ICON

public static final MediaType IMAGE_ICON

IMAGE_JPEG

public static final MediaType IMAGE_JPEG

IMAGE_PNG

public static final MediaType IMAGE_PNG

IMAGE_SVG

public static final MediaType IMAGE_SVG

IMAGE_TIFF

public static final MediaType IMAGE_TIFF

MESSAGE_ALL

public static final MediaType MESSAGE_ALL

MODEL_ALL

public static final MediaType MODEL_ALL

MODEL_VRML

public static final MediaType MODEL_VRML

MULTIPART_ALL

public static final MediaType MULTIPART_ALL

MULTIPART_FORM_DATA

public static final MediaType MULTIPART_FORM_DATA

TEXT_ALL

public static final MediaType TEXT_ALL

TEXT_CALENDAR

public static final MediaType TEXT_CALENDAR

TEXT_CSS

public static final MediaType TEXT_CSS

TEXT_HTML

public static final MediaType TEXT_HTML

TEXT_J2ME_APP_DESCRIPTOR

public static final MediaType TEXT_J2ME_APP_DESCRIPTOR

TEXT_JAVASCRIPT

public static final MediaType TEXT_JAVASCRIPT

TEXT_PLAIN

public static final MediaType TEXT_PLAIN

TEXT_RDF_N3

public static final MediaType TEXT_RDF_N3

TEXT_URI_LIST

public static final MediaType TEXT_URI_LIST

TEXT_VCARD

public static final MediaType TEXT_VCARD

TEXT_XML

public static final MediaType TEXT_XML

VIDEO_ALL

public static final MediaType VIDEO_ALL

VIDEO_AVI

public static final MediaType VIDEO_AVI

VIDEO_MP4

public static final MediaType VIDEO_MP4

VIDEO_MPEG

public static final MediaType VIDEO_MPEG

VIDEO_QUICKTIME

public static final MediaType VIDEO_QUICKTIME

VIDEO_WMV

public static final MediaType VIDEO_WMV
Constructor Detail

MediaType

public MediaType(java.lang.String name)
Constructor.

Parameters:
name - The name.

MediaType

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

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

MediaType

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

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

MediaType

public MediaType(java.lang.String name,
                 java.lang.String description)
Constructor.

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

getMostSpecific

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

Examples:

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

register

public 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). 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(java.lang.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(java.lang.Object obj)

Overrides:
equals in class Metadata

equals

public boolean equals(java.lang.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 java.lang.String getMainType()
Returns the main type.

Returns:
The main type.

getParameters

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

Returns:
The list of parameters.

getSubType

public java.lang.String getSubType()
Returns the sub-type.

Returns:
The sub-type.

hashCode

public int hashCode()

Overrides:
hashCode in class Metadata

includes

public boolean includes(MediaType included)
Indicates if a given media type is included in the current one. 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.

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:
isCompatible(MediaType)

isCompatible

public boolean isCompatible(MediaType otherMediaType)
Checks if this MediaType is compatible with the given media type.

Examples:

Parameters:
otherMediaType - The other media type to compare.
Returns:
True if the media types are compatible.
See Also:
includes(MediaType)

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.

toString

public java.lang.String toString()
Description copied from class: Metadata
Returns the metadata name.

Overrides:
toString in class Metadata
Returns:
The metadata name.


Copyright © 2005-2008 Noelios Technologies.