@BeanIgnore public final class MediaTypeRange extends Object implements Comparable<MediaTypeRange>
Modifier and Type | Method and Description |
---|---|
int |
compareTo(MediaTypeRange o)
Compares two MediaRanges for equality.
|
boolean |
equals(Object o)
Returns
MediaType , and has the same qValue, type,
parameters, and extensions. |
Map<String,Set<String>> |
getExtensions()
Returns the optional set of custom extensions defined for this type.
|
MediaType |
getMediaType()
Returns the media type enclosed by this media range.
|
Float |
getQValue()
Returns the
|
int |
hashCode()
Returns a hash based on this instance's
media-type . |
static MediaTypeRange[] |
parse(String value)
Parses an
Accept header value into an array of media ranges. |
String |
toString()
Provides a string representation of this media range, suitable for use as an
Accept header value. |
public static MediaTypeRange[] parse(String value)
Accept
header value into an array of media ranges.
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 value
complies with the syntax described in
RFC2616, Section 14.1, as described below:
Accept = "Accept" ":" #( media-range [ accept-params ] ) media-range = ( "*\/*" | ( type "/" "*" ) | ( type "/" subtype ) ) *( ";" parameter ) accept-params = ";" "q" "=" qvalue *( accept-extension ) accept-extension = ";" token [ "=" ( token | quoted-string ) ]
value
- The value to parse.
If MediaTypeRange
is returned that represents all types.public MediaType getMediaType()
public Float getQValue()
The quality value is a float between 0.0
(unacceptable) and 1.0
(most acceptable).
If 'q' value doesn't make sense for the context (e.g. this range was extracted from a
public Map<String,Set<String>> getExtensions()
Values are lowercase and never
public String toString()
Accept
header value.
The literal text generated will be all lowercase.
public boolean equals(Object o)
MediaType
, and has the same qValue, type,
parameters, and extensions.public int hashCode()
media-type
.public int compareTo(MediaTypeRange o)
The values are first compared according to qValue
values.
Should those values be equal, the type
is then lexicographically compared (case-insensitive) in
ascending order, with the MediaRanges
with the same type but different sub-types are compared - a more specific subtype is
promoted over the 'wildcard' subtype.
MediaRanges
with the same types but with extensions are promoted over those same types with no
extensions.
compareTo
in interface Comparable<MediaTypeRange>
o
- The range to compare to. Never Copyright © 2018 Apache. All rights reserved.