Class MediaRanges
The returned media ranges are sorted such that the most acceptable media is available at ordinal position
The syntax expected to be found in the referenced
Accept = "Accept" ":" #( media-range [ accept-params ] ) media-range = ( "*\/*" | ( type "/" "*" ) | ( type "/" subtype ) ) *( ";" parameter ) accept-params = ";" "q" "=" qvalue *( accept-extension ) accept-extension = ";" token [ "=" ( token | quoted-string ) ]
See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final MediaRanges
Represents an empty media ranges object. -
Constructor Summary
ConstructorDescriptionMediaRanges
(String value) Constructor.MediaRanges
(HeaderElement[] e) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionforEachRange
(Consumer<MediaRange> action) Performs an action on the media ranges that make up this object.getRange
(int index) Returns theMediaRange
at the specified index.boolean
hasSubtypePart
(String part) Convenience method for searching through all of the subtypes of all the media ranges in this header for the presence of a subtype fragment.int
Given a list of media types, returns the best match for thisAccept header.static MediaRanges
Returns a parsedAccept header value.toList()
Returns the media ranges that make up this object.toString()
-
Field Details
-
EMPTY
Represents an empty media ranges object.
-
-
Constructor Details
-
MediaRanges
Constructor.- Parameters:
value
- TheAccept header value.
-
MediaRanges
Constructor.- Parameters:
e
- The parsed header value.
-
-
Method Details
-
of
Returns a parsedAccept header value.- Parameters:
value
- The rawAccept header value.- Returns:
- A parsed
Accept header value.
-
match
Given a list of media types, returns the best match for thisAccept header.Note that fuzzy matching is allowed on the media types where the
Accept header may contain additional subtype parts.
For example, given identical q-values and anAccept value of"text/json+activity" , the media type"text/json" will match if"text/json+activity" or"text/activity+json" isn't found.
The purpose for this is to allow serializers to match when artifacts such asid properties are present in the header.- Parameters:
mediaTypes
- The media types to match against.- Returns:
- The index into the array of the best match, or
-1 if no suitable matches could be found.
-
getRange
Returns theMediaRange
at the specified index.- Parameters:
index
- The index position of the media range.- Returns:
- The
MediaRange
at the specified index ornull if the index is out of range.
-
hasSubtypePart
Convenience method for searching through all of the subtypes of all the media ranges in this header for the presence of a subtype fragment.For example, given the header
"text/json+activity" , callinghasSubtypePart(
returns"activity" )true .- Parameters:
part
- The media type subtype fragment.- Returns:
true if subtype fragment exists.
-
toList
Returns the media ranges that make up this object.- Returns:
- The media ranges that make up this object.
-
forEachRange
Performs an action on the media ranges that make up this object.- Parameters:
action
- The action to perform.- Returns:
- This object.
-
toString
-