@ConsumerType public class MediaRangeList extends java.util.TreeSet<MediaRangeList.MediaRange>
Modifier and Type | Class and Description |
---|---|
class |
MediaRangeList.MediaRange
A code
MediaRange represents an entry in a MediaRangeList . |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
HEADER_ACCEPT |
static java.lang.String |
PARAM_ACCEPT |
static java.lang.String |
WILDCARD |
Constructor and Description |
---|
MediaRangeList(javax.servlet.http.HttpServletRequest request)
Constructs a
MediaRangeList using information from the supplied HttpServletRequest . |
MediaRangeList(java.lang.String listStr)
Constructs a
MediaRangeList using a list of media ranges specified in a java.lang.String . |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(java.lang.String mediaType)
Determines if this MediaRangeList contains a given media type.
|
MediaRangeList.MediaRange |
prefer(java.util.Set<MediaRangeList.MediaRange> mediaRanges)
Given a list of media types, returns the one is preferred by this
MediaRangeList . |
java.lang.String |
prefer(java.lang.String... mediaRanges)
Determines which of the
mediaRanges specifications is preferred by this MediaRangeList . |
add, addAll, ceiling, clear, clone, comparator, contains, descendingIterator, descendingSet, first, floor, headSet, headSet, higher, isEmpty, iterator, last, lower, pollFirst, pollLast, remove, size, spliterator, subSet, subSet, tailSet, tailSet
containsAll, retainAll, toArray, toArray, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
public static final java.lang.String HEADER_ACCEPT
public static final java.lang.String PARAM_ACCEPT
public static final java.lang.String WILDCARD
public MediaRangeList(javax.servlet.http.HttpServletRequest request)
MediaRangeList
using information from the supplied HttpServletRequest
.
if the request contains a PARAM_ACCEPT
query parameter, the query parameter value overrides any
HEADER_ACCEPT
header value.
If the request contains no PARAM_ACCEPT
parameter, or the parameter value is empty, the value of the
HEADER_ACCEPT
is used. If both values are missing, it is assumed that the client accepts all media types,
as per the RFC. See also MediaRangeList(java.lang.String)
request
- The HttpServletRequest
to extract a MediaRangeList
frompublic MediaRangeList(java.lang.String listStr)
MediaRangeList
using a list of media ranges specified in a java.lang.String
.
The string is a comma-separated list of media ranges, as specified by the RFC.text/*;q=0.3, text/html;q=0.7, text/html;level=1, text/html;level=2;q=0.4, */*;q=0.5
text/html;q=0.8, application/json
listStr
- The list of media range specificationspublic boolean contains(java.lang.String mediaType)
mediaType
- A string on the form type/subtype
. Neither type
or subtype
should be wildcard (*
).true
if this MediaRangeList
contains a media type that matches
mediaType
, false
otherwisejava.lang.IllegalArgumentException
- if mediaType
is not on an accepted formjava.lang.NullPointerException
- if mediaType
is null
public MediaRangeList.MediaRange prefer(java.util.Set<MediaRangeList.MediaRange> mediaRanges)
MediaRangeList
.mediaRanges
- An array of possible MediaRangeList.MediaRange
smediaRanges
that this MediaRangeList
prefers;
or null
if this MediaRangeList
does not contain any of the mediaRanges
java.lang.NullPointerException
- if mediaRanges
is null
or contains a null
valuepublic java.lang.String prefer(java.lang.String... mediaRanges)
mediaRanges
specifications is preferred by this MediaRangeList
.mediaRanges
- String representations of MediaRange
s. The strings must be
on the form required by MediaRange(String)
toString()
representation of the preferred MediaRange
, or null
if this MediaRangeList
does not contain any of the mediaRanges
prefer(java.util.Set)
Copyright © 2022 The Apache Software Foundation. All rights reserved.