com.sun.jersey.core.header
Class MediaTypes

java.lang.Object
  extended by com.sun.jersey.core.header.MediaTypes

public class MediaTypes
extends java.lang.Object

Common media types and functonality.

Author:
[email protected]

Field Summary
static MediaType FAST_INFOSET
           
static AcceptableMediaType GENERAL_ACCEPT_MEDIA_TYPE
          The general acceptable media type corresponding to \*\/*.
static java.util.List<AcceptableMediaType> GENERAL_ACCEPT_MEDIA_TYPE_LIST
          A singleton list containing the general acceptable media type.
static MediaType GENERAL_MEDIA_TYPE
          The general media type corresponding to \*\/*.
static java.util.List<MediaType> GENERAL_MEDIA_TYPE_LIST
          A singleton list containing the general media type.
static java.util.List<MediaType> GENERAL_QUALITY_SOURCE_MEDIA_TYPE_LIST
          A singleton list containing the general media type.
static java.util.Comparator<MediaType> MEDIA_TYPE_COMPARATOR
          Comparator for media types.
static java.util.Comparator<java.util.List<? extends MediaType>> MEDIA_TYPE_LIST_COMPARATOR
          Comparator for lists of media types.
static java.util.Comparator<QualitySourceMediaType> QUALITY_SOURCE_MEDIA_TYPE_COMPARATOR
          Comparator for lists of quality source media types.
static MediaType WADL
           
 
Method Summary
static java.util.List<MediaType> createMediaTypes(Consumes mime)
          Create a list of media type from the Consumes annotation.
static java.util.List<MediaType> createMediaTypes(Produces mime)
          Create a list of media type from the Produces annotation.
static java.util.List<MediaType> createMediaTypes(java.lang.String[] mediaTypes)
          Create a list of media type from an array of media types.
static java.util.List<MediaType> createQualitySourceMediaTypes(Produces mime)
          Create a list of quality source media type from the Produces annotation.
static java.util.List<QualitySourceMediaType> createQualitySourceMediaTypes(java.lang.String[] mediaTypes)
          Create a list of quality source media type from an array of media types.
static MediaType getTypeWildCart(MediaType mediaType)
          Returns MediaType with wildcard in subtype.
static boolean intersects(java.util.List<? extends MediaType> ml1, java.util.List<? extends MediaType> ml2)
           
static MediaType mostSpecific(MediaType m1, MediaType m2)
          Get the most specific media type from a pair of media types.
static boolean typeEquals(MediaType m1, MediaType m2)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WADL

public static final MediaType WADL

FAST_INFOSET

public static final MediaType FAST_INFOSET

MEDIA_TYPE_COMPARATOR

public static final java.util.Comparator<MediaType> MEDIA_TYPE_COMPARATOR
Comparator for media types.

x/y < x/* < \*\/*


MEDIA_TYPE_LIST_COMPARATOR

public static final java.util.Comparator<java.util.List<? extends MediaType>> MEDIA_TYPE_LIST_COMPARATOR
Comparator for lists of media types.

The least specific content type of each list is obtained and then compared using MEDIA_TYPE_COMPARATOR.

Assumes each list is already ordered according to MEDIA_TYPE_COMPARATOR and therefore the least specific media type is at the end of the list.


GENERAL_MEDIA_TYPE

public static final MediaType GENERAL_MEDIA_TYPE
The general media type corresponding to \*\/*.


GENERAL_MEDIA_TYPE_LIST

public static final java.util.List<MediaType> GENERAL_MEDIA_TYPE_LIST
A singleton list containing the general media type.


GENERAL_ACCEPT_MEDIA_TYPE

public static final AcceptableMediaType GENERAL_ACCEPT_MEDIA_TYPE
The general acceptable media type corresponding to \*\/*.


GENERAL_ACCEPT_MEDIA_TYPE_LIST

public static final java.util.List<AcceptableMediaType> GENERAL_ACCEPT_MEDIA_TYPE_LIST
A singleton list containing the general acceptable media type.


QUALITY_SOURCE_MEDIA_TYPE_COMPARATOR

public static final java.util.Comparator<QualitySourceMediaType> QUALITY_SOURCE_MEDIA_TYPE_COMPARATOR
Comparator for lists of quality source media types.


GENERAL_QUALITY_SOURCE_MEDIA_TYPE_LIST

public static final java.util.List<MediaType> GENERAL_QUALITY_SOURCE_MEDIA_TYPE_LIST
A singleton list containing the general media type.

Method Detail

typeEquals

public static final boolean typeEquals(MediaType m1,
                                       MediaType m2)

intersects

public static final boolean intersects(java.util.List<? extends MediaType> ml1,
                                       java.util.List<? extends MediaType> ml2)

mostSpecific

public static final MediaType mostSpecific(MediaType m1,
                                           MediaType m2)
Get the most specific media type from a pair of media types. The most specific media type is the media type from the pair that has least wild cards present.

Parameters:
m1 - the first media type
m2 - the second media type
Returns:
the most specific media type. If the media types are equally specific then the first media type is returned.

createMediaTypes

public static java.util.List<MediaType> createMediaTypes(Consumes mime)
Create a list of media type from the Consumes annotation.

Parameters:
mime - the Consumes annotation.
Returns:
the list of MediaType, ordered according to MEDIA_TYPE_COMPARATOR.

createMediaTypes

public static java.util.List<MediaType> createMediaTypes(Produces mime)
Create a list of media type from the Produces annotation.

Parameters:
mime - the Produces annotation.
Returns:
the list of MediaType, ordered according to MEDIA_TYPE_COMPARATOR.

createMediaTypes

public static java.util.List<MediaType> createMediaTypes(java.lang.String[] mediaTypes)
Create a list of media type from an array of media types.

Parameters:
mediaTypes - the array of meda types.
Returns:
the list of MediaType, ordered according to MEDIA_TYPE_COMPARATOR.

createQualitySourceMediaTypes

public static java.util.List<MediaType> createQualitySourceMediaTypes(Produces mime)
Create a list of quality source media type from the Produces annotation.

Parameters:
mime - the Produces annotation.
Returns:
the list of QualitySourceMediaType, ordered according to QUALITY_SOURCE_MEDIA_TYPE_COMPARATOR.

createQualitySourceMediaTypes

public static java.util.List<QualitySourceMediaType> createQualitySourceMediaTypes(java.lang.String[] mediaTypes)
Create a list of quality source media type from an array of media types.

Parameters:
mediaTypes - the array of meda types.
Returns:
the list of QualitySourceMediaType, ordered according to the quality source as the primary key and MEDIA_TYPE_COMPARATOR as the secondary key.

getTypeWildCart

public static MediaType getTypeWildCart(MediaType mediaType)
Returns MediaType with wildcard in subtype.

Parameters:
mediaType - original MediaType.
Returns:
MediaType with wildcard in subtype.


Copyright © 2011 Oracle Corporation. All Rights Reserved.