## com.sun.jersey.core.header
Class MediaTypes

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

    public class MediaTypes

extends java.lang.Object

Common media types and functionality.

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.List<javax.ws.rs.core.MediaType>` `GENERAL_QUALITY_SOURCE_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<? extends javax.ws.rs.core.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 javax.ws.rs.core.MediaType` `WADL`
`static javax.ws.rs.core.MediaType` `WADL_JSON`
`static java.lang.String` `WADL_JSON_STRING`
`static java.lang.String` `WADL_STRING`

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 media type from an array of media types.
`static java.util.List<javax.ws.rs.core.MediaType>` `createQualitySourceMediaTypes(javax.ws.rs.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 javax.ws.rs.core.MediaType` `getTypeWildCart(javax.ws.rs.core.MediaType mediaType)` Returns MediaType with wildcard in subtype.
`static boolean` `intersects(java.util.List<? extends javax.ws.rs.core.MediaType> ml1, java.util.List<? extends javax.ws.rs.core.MediaType> ml2)`
`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.
`static boolean` `typeEquals(javax.ws.rs.core.MediaType m1, javax.ws.rs.core.MediaType m2)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### WADL_STRING

    public static final java.lang.String WADL_STRING

See Also:
  Constant Field Values

### WADL

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

### WADL_JSON_STRING

    public static final java.lang.String WADL_JSON_STRING

See Also:
  Constant Field Values

### WADL_JSON

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

### 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<? extends 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.

### 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<javax.ws.rs.core.MediaType> GENERAL_QUALITY_SOURCE_MEDIA_TYPE_LIST

  A singleton list containing the general media type.

Method Detail

### typeEquals

    public static final boolean typeEquals(javax.ws.rs.core.MediaType m1,
                                           javax.ws.rs.core.MediaType m2)

### intersects

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

### 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 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<javax.ws.rs.core.MediaType> createQualitySourceMediaTypes(javax.ws.rs.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 javax.ws.rs.core.MediaType getTypeWildCart(javax.ws.rs.core.MediaType mediaType)

  Returns MediaType with wildcard in subtype.

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

Copyright © 2017 Oracle Corporation. All Rights Reserved.