org.glassfish.jersey.message.internal
Class QualitySourceMediaType

java.lang.Object
  extended by javax.ws.rs.core.MediaType
      extended by org.glassfish.jersey.message.internal.QualitySourceMediaType

public class QualitySourceMediaType
extends MediaType

A quality source media type.

Author:
Paul Sandoz, Marek Potociar (marek.potociar at oracle.com)

Field Summary
static String QUALITY_SOURCE_PARAMETER_NAME
          Quality source header value parameter name.
 
Fields inherited from class javax.ws.rs.core.MediaType
APPLICATION_ATOM_XML, APPLICATION_ATOM_XML_TYPE, APPLICATION_FORM_URLENCODED, APPLICATION_FORM_URLENCODED_TYPE, APPLICATION_JSON, APPLICATION_JSON_TYPE, APPLICATION_OCTET_STREAM, APPLICATION_OCTET_STREAM_TYPE, APPLICATION_SVG_XML, APPLICATION_SVG_XML_TYPE, APPLICATION_XHTML_XML, APPLICATION_XHTML_XML_TYPE, APPLICATION_XML, APPLICATION_XML_TYPE, CHARSET_PARAMETER, MEDIA_TYPE_WILDCARD, MULTIPART_FORM_DATA, MULTIPART_FORM_DATA_TYPE, TEXT_HTML, TEXT_HTML_TYPE, TEXT_PLAIN, TEXT_PLAIN_TYPE, TEXT_XML, TEXT_XML_TYPE, WILDCARD, WILDCARD_TYPE
 
Constructor Summary
QualitySourceMediaType(String type, String subtype)
          Create new quality source media type instance with a default quality factor value.
QualitySourceMediaType(String type, String subtype, int quality, Map<String,String> parameters)
          Create new quality source media type instance.
 
Method Summary
 boolean equals(Object obj)
           
 int getQualitySource()
          Get quality source factor value (in [ppt]).
static int getQualitySource(MediaType mediaType)
          Extract quality source information from the supplied MediaType value.
 int hashCode()
           
static QualitySourceMediaType valueOf(HttpHeaderReader reader)
          Create new quality source media type instance from the supplied HTTP header reader.
 
Methods inherited from class javax.ws.rs.core.MediaType
getParameters, getSubtype, getType, isCompatible, isWildcardSubtype, isWildcardType, toString, valueOf, withCharset
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

QUALITY_SOURCE_PARAMETER_NAME

public static final String QUALITY_SOURCE_PARAMETER_NAME
Quality source header value parameter name.

See Also:
Constant Field Values
Constructor Detail

QualitySourceMediaType

public QualitySourceMediaType(String type,
                              String subtype)
Create new quality source media type instance with a default quality factor value.

Parameters:
type - the primary type, null is equivalent to MediaType.MEDIA_TYPE_WILDCARD
subtype - the subtype, null is equivalent to MediaType.MEDIA_TYPE_WILDCARD

QualitySourceMediaType

public QualitySourceMediaType(String type,
                              String subtype,
                              int quality,
                              Map<String,String> parameters)
Create new quality source media type instance.

Parameters:
type - the primary type, null is equivalent to MediaType.MEDIA_TYPE_WILDCARD
subtype - the subtype, null is equivalent to MediaType.MEDIA_TYPE_WILDCARD
quality - quality source factor value in [ppt]. See Qualified.
parameters - a map of media type parameters, null is the same as an empty map.
Method Detail

getQualitySource

public int getQualitySource()
Get quality source factor value (in [ppt]).

Returns:
quality source factor value.

valueOf

public static QualitySourceMediaType valueOf(HttpHeaderReader reader)
                                      throws ParseException
Create new quality source media type instance from the supplied HTTP header reader.

Parameters:
reader - HTTP header reader.
Returns:
new acceptable media type instance.
Throws:
ParseException - in case the input data parsing failed.

getQualitySource

public static int getQualitySource(MediaType mediaType)
                            throws IllegalArgumentException
Extract quality source information from the supplied MediaType value. If no quality source parameter is present in the media type, default quality is returned.

Parameters:
mediaType - media type.
Returns:
quality source parameter value or default quality, if no quality source parameter is present.
Throws:
IllegalArgumentException - in case the quality source parameter value could not be parsed.

equals

public boolean equals(Object obj)
Overrides:
equals in class MediaType

hashCode

public int hashCode()
Overrides:
hashCode in class MediaType


Copyright © 2007-2012 Oracle Corporation. All Rights Reserved. Use is subject to license terms.