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:
Paul.Sandoz@Sun.Com

Field Summary
static javax.ws.rs.core.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 javax.ws.rs.core.MediaType GENERAL_MEDIA_TYPE
          The general media type corresponding to \*\/*.
static java.util.List<javax.ws.rs.core.MediaType> GENERAL_MEDIA_TYPE_LIST
          A singleton list containing the general media type.
static java.util.Comparator<javax.ws.rs.core.MediaType> MEDIA_TYPE_COMPARATOR
          Comparator for media types.
static java.util.Comparator<java.util.List<javax.ws.rs.core.MediaType>> MEDIA_TYPE_LIST_COMPARATOR
          Comparator for lists of media types.
static javax.ws.rs.core.MediaType WADL
           
 
Method Summary
static java.util.List<javax.ws.rs.core.MediaType> createMediaTypes(javax.ws.rs.Consumes mime)
          Create a list of media type from the Consumes annotation.
static java.util.List<javax.ws.rs.core.MediaType> createMediaTypes(javax.ws.rs.Produces mime)
          Create a list of media type from the Produces annotation.
static java.util.List<javax.ws.rs.core.MediaType> createMediaTypes(java.lang.String[] mediaTypes)
          Create a list of memdia type from an array of media types.
static javax.ws.rs.core.MediaType mostSpecific(javax.ws.rs.core.MediaType m1, javax.ws.rs.core.MediaType m2)
          Get the most specific media type from a pair of media types.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WADL

public static final javax.ws.rs.core.MediaType WADL

FAST_INFOSET

public static final javax.ws.rs.core.MediaType FAST_INFOSET

MEDIA_TYPE_COMPARATOR

public static final java.util.Comparator<javax.ws.rs.core.MediaType> MEDIA_TYPE_COMPARATOR
Comparator for media types.

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


MEDIA_TYPE_LIST_COMPARATOR

public static final java.util.Comparator<java.util.List<javax.ws.rs.core.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 javax.ws.rs.core.MediaType GENERAL_MEDIA_TYPE
The general media type corresponding to \*\/*.


GENERAL_MEDIA_TYPE_LIST

public static final java.util.List<javax.ws.rs.core.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.

Method Detail

mostSpecific

public static final javax.ws.rs.core.MediaType mostSpecific(javax.ws.rs.core.MediaType m1,
                                                            javax.ws.rs.core.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<javax.ws.rs.core.MediaType> createMediaTypes(javax.ws.rs.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<javax.ws.rs.core.MediaType> createMediaTypes(javax.ws.rs.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<javax.ws.rs.core.MediaType> createMediaTypes(java.lang.String[] mediaTypes)
Create a list of memdia 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.


Copyright © 2008 Sun Microsystems, Inc. All Rights Reserved.