Class QualitySourceMediaType
- java.lang.Object
-
- jakarta.ws.rs.core.MediaType
-
- org.glassfish.jersey.message.internal.QualitySourceMediaType
-
-
Field Summary
Fields Modifier and Type Field Description static Comparator<QualitySourceMediaType>COMPARATORComparator for lists of quality source media types.-
Fields inherited from class jakarta.ws.rs.core.MediaType
APPLICATION_ATOM_XML, APPLICATION_ATOM_XML_TYPE, APPLICATION_FORM_URLENCODED, APPLICATION_FORM_URLENCODED_TYPE, APPLICATION_JSON, APPLICATION_JSON_PATCH_JSON, APPLICATION_JSON_PATCH_JSON_TYPE, 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, SERVER_SENT_EVENTS, SERVER_SENT_EVENTS_TYPE, TEXT_HTML, TEXT_HTML_TYPE, TEXT_PLAIN, TEXT_PLAIN_TYPE, TEXT_XML, TEXT_XML_TYPE, WILDCARD, WILDCARD_TYPE
-
-
Constructor Summary
Constructors Constructor Description QualitySourceMediaType(String type, String subtype)Create new quality source media type instance with adefault quality factorvalue.QualitySourceMediaType(String type, String subtype, int quality, Map<String,String> parameters)Create new quality source media type instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)Comparesobjto this media type to see if they are the same by comparing type, subtype and parameters.intgetQuality()Get quality source factor value (in [ppt]).static intgetQualitySource(MediaType mediaType)Extract quality source information from the suppliedMediaTypevalue.inthashCode()Generate a hash code from the type, subtype and parameters.StringtoString()Convert the media type to a string suitable for use as the value of a corresponding HTTP header.static QualitySourceMediaTypevalueOf(HttpHeaderReader reader)Create new quality source media type instance from the suppliedHTTP header reader.-
Methods inherited from class jakarta.ws.rs.core.MediaType
getParameters, getSubtype, getType, isCompatible, isWildcardSubtype, isWildcardType, valueOf, withCharset
-
-
-
-
Field Detail
-
COMPARATOR
public static final Comparator<QualitySourceMediaType> COMPARATOR
Comparator for lists of quality source media types.
-
-
Constructor Detail
-
QualitySourceMediaType
public QualitySourceMediaType(String type, String subtype)
Create new quality source media type instance with adefault quality factorvalue.- Parameters:
type- the primary type,nullis equivalent toMediaType.MEDIA_TYPE_WILDCARDsubtype- the subtype,nullis equivalent toMediaType.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,nullis equivalent toMediaType.MEDIA_TYPE_WILDCARDsubtype- the subtype,nullis equivalent toMediaType.MEDIA_TYPE_WILDCARDquality- quality source factor value in [ppt]. SeeQualified.parameters- a map of media type parameters,nullis the same as an empty map.
-
-
Method Detail
-
getQuality
public int getQuality()
Get quality source factor value (in [ppt]).- Specified by:
getQualityin interfaceQualified- Returns:
- quality source factor value.
-
valueOf
public static QualitySourceMediaType valueOf(HttpHeaderReader reader) throws ParseException
Create new quality source media type instance from the suppliedHTTP 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 suppliedMediaTypevalue. If no quality source parameter is present in the media type,default qualityis 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)
Description copied from class:MediaTypeCompares
Note that theobjto this media type to see if they are the same by comparing type, subtype and parameters. Note that the case-sensitivity of parameter values is dependent on the semantics of the parameter name, see HTTP/1.1. This method assumes that values are case-sensitive.equals(...)implementation does not perform a class equality check (this.getClass() == obj.getClass()). Therefore any class that extends fromMediaTypeclass and needs to override one of theequals(...)andMediaType.hashCode()methods must always override both methods to ensure the contract betweenObject.equals(java.lang.Object)andObject.hashCode()does not break.
-
hashCode
public int hashCode()
Description copied from class:MediaTypeGenerate a hash code from the type, subtype and parameters.
Note that theMediaType.equals(java.lang.Object)implementation does not perform a class equality check (this.getClass() == obj.getClass()). Therefore any class that extends fromMediaTypeclass and needs to override one of theMediaType.equals(Object)andhashCode()methods must always override both methods to ensure the contract betweenObject.equals(java.lang.Object)andObject.hashCode()does not break.
-
-