Class MediaType
java.lang.Object
com.contentgrid.opa.client.rest.http.MediaType
Represents a RFC 2046 Media Type.
A media type consists of
type/subtype and MAY be followed by parameters in the form of
name=value{code} paris.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturn the character set, as indicated by acharsetparameter, if available.getParameter(String name) Return a generic parameter value, given a parameter name.Returns all media type parameters in a read-only MapdoubleReturn the quality factor, as indicated by aqparameter, if any.Return the subtype.getType()Return the primary type.booleanIndicate whether thisMediaTypeincludes the given media type.booleanIndicates whether the subtype is the wildcard character*or the wildcard character followed by a suffix (e.g.static MediaTypeparseMediaType(String mediaType) parseMediaTypes(String... mediaTypes) toString()static StringtoString(Collection<MediaType> mediaTypes) Return a string representation of the given list ofMediaTypeobjects, to be used in anAcceptorContent-Typeheader.
-
Field Details
-
APPLICATION_JSON
-
APPLICATION_OCTET_STREAM
-
TEXT_ALL
-
TEXT_PLAIN
-
WILDCARD
- See Also:
-
-
Constructor Details
-
MediaType
Create a newMediaTypefor the given primary type and subtype, with empty parameters.- Parameters:
type- the primary typesubtype- the subtype- Throws:
IllegalArgumentException- if any of the arguments contain illegal characters
-
MediaType
Create a newMediaTypefor the given type, subtype, and parameters.- Parameters:
type- the primary typesubtype- the subtypeparameters- the parameters, may benull- Throws:
IllegalArgumentException- if any of the arguments contain illegal characters
-
-
Method Details
-
getType
Return the primary type. -
getSubtype
Return the subtype. -
getCharset
Return the character set, as indicated by acharsetparameter, if available.- Returns:
- the character set wrapped in an
Optional, orOptional.empty()if not available
-
isWildcardSubtype
public boolean isWildcardSubtype()Indicates whether the subtype is the wildcard character*or the wildcard character followed by a suffix (e.g.*+xml).- Returns:
- whether the subtype is a wildcard
-
getParameter
Return a generic parameter value, given a parameter name.- Parameters:
name- the parameter name- Returns:
- the parameter value, or
nullif not present
-
getParameters
Returns all media type parameters in a read-only Map- Returns:
- an immutable map with all parameters, never
null
-
getQualityValue
public double getQualityValue()Return the quality factor, as indicated by aqparameter, if any. Defaults to1.0.- Returns:
- the quality factor as double value
-
includes
Indicate whether thisMediaTypeincludes the given media type. For example,text/*should includestext/plainandtext/html, andapplication/*+xmlincludesapplication/soap+xml.- Parameters:
other- the reference media type with which to compare- Returns:
trueif this media type includes the given media type;falseotherwise
-
parseMediaType
-
parseMediaTypes
-
toString
-
toString
Return a string representation of the given list ofMediaTypeobjects, to be used in anAcceptorContent-Typeheader.- Parameters:
mediaTypes- the media types to create a string representation for- Returns:
- the string representation
-