Class MediaRangeList.MediaRange
- java.lang.Object
-
- org.apache.sling.api.request.header.MediaRangeList.MediaRange
-
- All Implemented Interfaces:
Comparable<MediaRangeList.MediaRange>
- Enclosing class:
- MediaRangeList
public class MediaRangeList.MediaRange extends Object implements Comparable<MediaRangeList.MediaRange>
A codeMediaRangerepresents an entry in aMediaRangeList. TheMediaRangeconsists of asupertypeand asubtype, optionally a quality factor parameterqand other arbitrary parameters.
-
-
Constructor Summary
Constructors Constructor Description MediaRange(String exp)Constructs aMediaRangefrom aStringexpression.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(MediaRangeList.MediaRange o)booleanequals(Object obj)booleanequals(String s)StringgetParameter(String key)Map<String,String>getParameters()doublegetQ()Get the value of the quality factor parameter (q).StringgetSubtype()StringgetSupertype()booleanmatchesAll()Returnstrueif this is a catch-all media range (*/*).StringtoString()
-
-
-
Constructor Detail
-
MediaRange
public MediaRange(String exp)
Constructs aMediaRangefrom aStringexpression.- Parameters:
exp- TheStringto construct theMediaRangefrom. The string is expected to be on the form ( "*/*" | ( type "/" "*" ) | ( type "/" subtype ) ) *( ";" parameter )
as specified by RFC 2616, section 14.1.Examples:
text/html;q=0.8text/htmltext/html;level=3text/html;level=3;q=0.7text/**/*
*), then the subtype component must also be wildcard.The quality factor parameter must be between
0and1, inclusive (see RFC 2616 section 3.9). If the expression does not contain aqparameter, theMediaRangeis given a default quality factor of1.- Throws:
IllegalArgumentException- ifexpcan not be parsed to a valid media rangeNullPointerException- ifexpisnull
-
-
Method Detail
-
matchesAll
public boolean matchesAll()
Returnstrueif this is a catch-all media range (*/*).- Returns:
trueif this range is a catch-all media range,falseotherwise
-
getSupertype
public String getSupertype()
-
getSubtype
public String getSubtype()
-
getQ
public double getQ()
Get the value of the quality factor parameter (q).- Returns:
- the quality factor
-
compareTo
public int compareTo(MediaRangeList.MediaRange o)
- Specified by:
compareToin interfaceComparable<MediaRangeList.MediaRange>
-
equals
public boolean equals(String s)
-
-