Class AcceptableMediaType
- java.lang.Object
-
- jakarta.ws.rs.core.MediaType
-
- org.glassfish.jersey.message.internal.AcceptableMediaType
-
-
Field Summary
Fields Modifier and Type Field Description static Comparator<AcceptableMediaType>COMPARATORComparator for collections of acceptable 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 AcceptableMediaType(String type, String subtype)Create new acceptable media type instance with adefault quality factorvalue.AcceptableMediaType(String type, String subtype, int quality, Map<String,String> parameters)Create new acceptable 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 factor value (in [ppt]).inthashCode()Generate a hash code from the type, subtype and parameters.static AcceptableMediaTypevalueOf(MediaType mediaType)Create new acceptable media type instance from the suppliedmedia type.static AcceptableMediaTypevalueOf(HttpHeaderReader reader)Create new acceptable media type instance from the suppliedHTTP header reader.-
Methods inherited from class jakarta.ws.rs.core.MediaType
getParameters, getSubtype, getType, isCompatible, isWildcardSubtype, isWildcardType, toString, valueOf, withCharset
-
-
-
-
Field Detail
-
COMPARATOR
public static final Comparator<AcceptableMediaType> COMPARATOR
Comparator for collections of acceptable media types.
-
-
Constructor Detail
-
AcceptableMediaType
public AcceptableMediaType(String type, String subtype)
Create new acceptable media type instance with adefault quality factorvalue.- Parameters:
type- the primary type,nullis equivalent toMediaType.MEDIA_TYPE_WILDCARDsubtype- the subtype, null is equivalent toMediaType.MEDIA_TYPE_WILDCARD
-
AcceptableMediaType
public AcceptableMediaType(String type, String subtype, int quality, Map<String,String> parameters)
Create new acceptable media type instance.- Parameters:
type- the primary type,nullis equivalent toMediaType.MEDIA_TYPE_WILDCARDsubtype- the subtype,nullis equivalent toMediaType.MEDIA_TYPE_WILDCARDquality- quality 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()
Description copied from interface:QualifiedGet quality factor value (in [ppt]).- Specified by:
getQualityin interfaceQualified- Returns:
- quality factor value.
-
valueOf
public static AcceptableMediaType valueOf(HttpHeaderReader reader) throws ParseException
Create new acceptable 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.
-
valueOf
public static AcceptableMediaType valueOf(MediaType mediaType) throws ParseException
Create new acceptable media type instance from the suppliedmedia type.- Parameters:
mediaType- general-purpose media type.- Returns:
- new acceptable media type instance.
- Throws:
ParseException- in case the quality parameter parsing failed.
-
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.
-
-