Package org.apache.sling.api.request.header

# 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 code `MediaRange` represents an entry in a `MediaRangeList`. The `MediaRange` consists of a `supertype` and a `subtype`, optionally a quality factor parameter `q` and other arbitrary parameters.

## Constructor Summary

Constructors
Constructor
Description
`MediaRange(String exp)`
Constructs a `MediaRange` from a `String` expression.

## Method Summary

Modifier and Type
Method
Description
`int`
`compareTo(MediaRangeList.MediaRange o)`
`boolean`
`equals(Object obj)`
`boolean`
`equals(String s)`
`String`
`getParameter(String key)`
`Map<String,String>`
`getParameters()`
`double`
`getQ()`
Get the value of the quality factor parameter (`q`).
`String`
`getSubtype()`
`String`
`getSupertype()`
`boolean`
`matchesAll()`
Returns `true` if this is a catch-all media range (`*/*`).
`String`
`toString()`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### MediaRange

public MediaRange(String exp)
Constructs a `MediaRange` from a `String` expression.

Parameters:
  `exp` - The `String` to construct the `MediaRange` 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/*`
  - `*/*`
  Note that if the supertype component is wildcard (`*`), then the subtype component must also be wildcard.

  The quality factor parameter must be between `0` and `1`, inclusive (see RFC 2616 section 3.9). If the expression does not contain a `q` parameter, the `MediaRange` is given a default quality factor of `1`.

Throws:
  `IllegalArgumentException` - if `exp` can not be parsed to a valid media range
  `NullPointerException` - if `exp` is `null`

## Method Details

### matchesAll

public boolean matchesAll()
Returns `true` if this is a catch-all media range (`*/*`).

Returns:
  `true` if this range is a catch-all media range, `false` otherwise

### getParameter

public String getParameter(String key)

### 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

### getParameters

public Map<String,String> getParameters()

### compareTo

public int compareTo(MediaRangeList.MediaRange o)

Specified by:
  `compareTo` in interface `Comparable<MediaRangeList.MediaRange>`

### equals

public boolean equals(Object obj)

Overrides:
  `equals` in class `Object`

### equals

public boolean equals(String s)

### toString

public String toString()

Overrides:
  `toString` in class `Object`