Package org.apache.juneau.http.header
Class BasicStringRangesHeader
java.lang.Object
org.apache.juneau.http.header.BasicHeader
org.apache.juneau.http.header.BasicStringRangesHeader
- All Implemented Interfaces:
Serializable
,Cloneable
,Header
,NameValuePair
- Direct Known Subclasses:
AcceptCharset
,AcceptEncoding
,AcceptLanguage
,ContentDisposition
,TE
Category of headers that consist of simple comma-delimited lists of strings with q-values.
Example
Accept-Encoding: compress;q=0.5, gzip;q=1.0
See Also:
-
Constructor Summary
ConstructorDescriptionBasicStringRangesHeader
(String name, String value) Constructor.BasicStringRangesHeader
(String name, Supplier<StringRanges> value) Constructor with delayed value.BasicStringRangesHeader
(String name, StringRanges value) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionReturns the header value as aStringRanges
wrapped in anOptional
.getRange
(int index) Returns theMediaRange
at the specified index.getValue()
int
Given a list of media types, returns the best match for this string range header.static BasicStringRangesHeader
Static creator.static BasicStringRangesHeader
of
(String name, Supplier<StringRanges> value) Static creator with delayed value.static BasicStringRangesHeader
of
(String name, StringRanges value) Static creator.orElse
(StringRanges other) Return the value if present, otherwise returnother .Returns the header value as aStringRanges
.Methods inherited from class org.apache.juneau.http.header.BasicHeader
assertName, assertStringValue, asString, equals, equalsIgnoreCase, get, getElements, getName, hashCode, isNotEmpty, isPresent, of, of, orElse, toString
-
Constructor Details
-
BasicStringRangesHeader
Constructor.- Parameters:
name
- The header name.value
- The header value.
Must be parsable byStringRanges.of(String)
.
Can benull .- Throws:
IllegalArgumentException
- If name isnull or empty.
-
BasicStringRangesHeader
Constructor.- Parameters:
name
- The header name.value
- The header value.
Can benull .- Throws:
IllegalArgumentException
- If name isnull or empty.
-
BasicStringRangesHeader
Constructor with delayed value.Header value is re-evaluated on each call to
getValue()
.- Parameters:
name
- The header name.value
- The supplier of the header value.
Can benull .- Throws:
IllegalArgumentException
- If name isnull or empty.
-
-
Method Details
-
of
Static creator.- Parameters:
name
- The header name.value
- The header value.
Must be parsable byStringRanges.of(String)
.
Can benull .- Returns:
- A new header bean, or
null if the value isnull . - Throws:
IllegalArgumentException
- If name isnull or empty.
-
of
Static creator.- Parameters:
name
- The header name.value
- The header value.
Can benull .- Returns:
- A new header bean, or
null if the value isnull . - Throws:
IllegalArgumentException
- If name isnull or empty.
-
of
Static creator with delayed value.Header value is re-evaluated on each call to
getValue()
.- Parameters:
name
- The header name.value
- The supplier of the header value.
Can benull .- Returns:
- A new header bean, or
null if the value isnull . - Throws:
IllegalArgumentException
- If name isnull or empty.
-
getValue
- Specified by:
getValue
in interfaceNameValuePair
- Overrides:
getValue
in classBasicHeader
-
asStringRanges
Returns the header value as aStringRanges
wrapped in anOptional
.- Returns:
- The header value as a
StringRanges
wrapped in anOptional
. Nevernull .
-
toStringRanges
Returns the header value as aStringRanges
.- Returns:
- The header value as a
StringRanges
. Can benull .
-
match
Given a list of media types, returns the best match for this string range header.Note that fuzzy matching is allowed on the media types where the string range header may contain additional subtype parts.
For example, given identical q-values and an string range 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:
names
- The names 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.
-
orElse
Return the value if present, otherwise returnother .This is a shortened form for calling
asArray().orElse( .other )- Parameters:
other
- The value to be returned if there is no value present, can benull .- Returns:
- The value, if present, otherwise
other .
-