Package org.apache.juneau.http.header
Class BasicMediaRangesHeader
java.lang.Object
org.apache.juneau.http.header.BasicHeader
org.apache.juneau.http.header.BasicStringHeader
org.apache.juneau.http.header.BasicMediaRangesHeader
- All Implemented Interfaces:
- Serializable,- Cloneable,- Header,- NameValuePair
- Direct Known Subclasses:
- Accept
Category of headers that consist of multiple parameterized string values.
 
Example
Accept: application/json;q=0.9,text/xml;q=0.1
See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionBasicMediaRangesHeader(String name, String value) Constructor.BasicMediaRangesHeader(String name, Supplier<MediaRanges> value) Constructor with delayed value.BasicMediaRangesHeader(String name, MediaRanges value) Constructor.
- 
Method SummaryModifier and TypeMethodDescriptionReturns the header value as aMediaRangeswrapped in anOptional.getRange(int index) Returns theMediaRangeat the specified index.getValue()booleanhasSubtypePart(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.intGiven a list of media types, returns the best match for thisAccept header.static BasicMediaRangesHeaderStatic creator.static BasicMediaRangesHeaderof(String name, MediaRanges value) Static creator.orElse(MediaRanges other) Return the value if present, otherwise returnother .Returns the header value as aMediaRanges.Methods inherited from class org.apache.juneau.http.header.BasicStringHeaderassertString, asString, of, ofPair, orElseMethods inherited from class org.apache.juneau.http.header.BasicHeaderassertName, assertStringValue, equals, equalsIgnoreCase, get, getElements, getName, hashCode, isNotEmpty, isPresent, of, of, toString
- 
Constructor Details- 
BasicMediaRangesHeaderConstructor.- Parameters:
- name- The header name.
- value- The header value.
 Must be parsable by- MediaRanges.of(String).
 Can be- null .
- Throws:
- IllegalArgumentException- If name is- null or empty.
 
- 
BasicMediaRangesHeaderConstructor.- Parameters:
- name- The header name.
- value- The header value.
 Can be- null .
- Throws:
- IllegalArgumentException- If name is- null or empty.
 
- 
BasicMediaRangesHeaderConstructor 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 be- null .
- Throws:
- IllegalArgumentException- If name is- null or empty.
 
 
- 
- 
Method Details- 
ofStatic creator.- Parameters:
- name- The header name.
- value- The header value.
 Must be parsable by- MediaRanges.of(String).
 Can be- null .
- Returns:
- A new header bean, or null if the value isnull .
- Throws:
- IllegalArgumentException- If name is- null or empty.
 
- 
ofStatic creator.- Parameters:
- name- The header name.
- value- The header value.
 Can be- null .
- Returns:
- A new header bean, or null if the value isnull .
- Throws:
- IllegalArgumentException- If name is- null or empty.
 
- 
asMediaRangesReturns the header value as aMediaRangeswrapped in anOptional.- Returns:
- The header value as a MediaRangeswrapped in anOptional. Nevernull .
 
- 
toMediaRangesReturns the header value as aMediaRanges.- Returns:
- The header value as a MediaRanges. Can benull .
 
- 
matchGiven 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.
 
- 
getRangeReturns theMediaRangeat the specified index.- Parameters:
- index- The index position of the media range.
- Returns:
- The MediaRangeat the specified index ornull if the index is out of range.
 
- 
hasSubtypePartConvenience 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.
 
- 
getValue- Specified by:
- getValuein interface- NameValuePair
- Overrides:
- getValuein class- BasicStringHeader
 
- 
orElseReturn the value if present, otherwise returnother .This is a shortened form for calling asMediaRanges().orElse( .other )- Parameters:
- other- The value to be returned if there is no value present, can be- null .
- Returns:
- The value, if present, otherwise other .
 
 
-