Class MediaRangeList.MediaRange
- java.lang.Object
-
- org.apache.sling.api.request.header.MediaRangeList.MediaRange
-
- All Implemented Interfaces:
java.lang.Comparable<MediaRangeList.MediaRange>
- Enclosing class:
- MediaRangeList
public class MediaRangeList.MediaRange extends java.lang.Object implements java.lang.Comparable<MediaRangeList.MediaRange>
A codeMediaRange
represents an entry in aMediaRangeList
. TheMediaRange
consists of asupertype
and asubtype
, optionally a quality factor parameterq
and other arbitrary parameters.
-
-
Constructor Summary
Constructors Constructor Description MediaRange(java.lang.String exp)
Constructs aMediaRange
from aString
expression.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(MediaRangeList.MediaRange o)
boolean
equals(java.lang.Object obj)
boolean
equals(java.lang.String s)
java.lang.String
getParameter(java.lang.String key)
java.util.Map<java.lang.String,java.lang.String>
getParameters()
double
getQ()
Get the value of the quality factor parameter (q
).java.lang.String
getSubtype()
java.lang.String
getSupertype()
boolean
matchesAll()
Returnstrue
if this is a catch-all media range (*/*
).java.lang.String
toString()
-
-
-
Constructor Detail
-
MediaRange
public MediaRange(java.lang.String exp)
Constructs aMediaRange
from aString
expression.- Parameters:
exp
- TheString
to construct theMediaRange
from. 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.8
text/html
text/html;level=3
text/html;level=3;q=0.7
text/*
*/*
*
), then the subtype component must also be wildcard.The quality factor parameter must be between
0
and1
, inclusive (see RFC 2616 section 3.9). If the expression does not contain aq
parameter, theMediaRange
is given a default quality factor of1
.- Throws:
java.lang.IllegalArgumentException
- ifexp
can not be parsed to a valid media rangejava.lang.NullPointerException
- ifexp
isnull
-
-
Method Detail
-
matchesAll
public boolean matchesAll()
Returnstrue
if this is a catch-all media range (*/*
).- Returns:
true
if this range is a catch-all media range,false
otherwise
-
getParameter
public java.lang.String getParameter(java.lang.String key)
-
getSupertype
public java.lang.String getSupertype()
-
getSubtype
public java.lang.String getSubtype()
-
getQ
public double getQ()
Get the value of the quality factor parameter (q
).- Returns:
- the quality factor
-
getParameters
public java.util.Map<java.lang.String,java.lang.String> getParameters()
-
compareTo
public int compareTo(MediaRangeList.MediaRange o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<MediaRangeList.MediaRange>
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
equals
public boolean equals(java.lang.String s)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-