public abstract class MediaType extends java.lang.Object implements MediaType, LazyValueBytesRenderable, WithQValue<MediaRange>
While knowledge of the MediaType alone suffices for being able to properly interpret binary content this
is not generally the case for non-binary (i.e. character-based) content, which also requires the definition
of a specific character encoding (HttpCharset).
Therefore MediaType instances are frequently encountered as a member of a ContentType, which
groups a MediaType with a potentially required HttpCharset to hold everything required for being
able to interpret an HttpEntity.
MediaTypes come in three basic forms:
1. Binary: These do not need an additional HttpCharset to be able to form a ContentType. Therefore
they can be implicitly converted to the latter.
2. WithOpenCharset: Most character-based MediaTypes are of this form, which can be combined with all
HttpCharset instances to form a ContentType.
3. WithFixedCharset: Some character-based MediaTypes prescribe a single, clearly defined charset and as such,
similarly to binary MediaTypes, do not require the addition of an HttpCharset instances to form a
ContentType. The most prominent example is probably application/json which must always be UTF-8 encoded.
Like binary MediaTypes WithFixedCharset types can be implicitly converted to a ContentType.
Not for user extension.
| Modifier and Type | Class and Description |
|---|---|
static class |
MediaType.Binary |
static class |
MediaType.Compressibility |
static class |
MediaType.Compressible$ |
static class |
MediaType.Gzipped$ |
static class |
MediaType.Multipart |
static class |
MediaType.NonBinary |
static class |
MediaType.NonMultipartWithOpenCharset |
static class |
MediaType.NotCompressible$ |
static class |
MediaType.WithFixedCharset |
static class |
MediaType.WithOpenCharset |
| Constructor and Description |
|---|
MediaType(java.lang.String _mainType,
java.lang.String _subType) |
| Modifier and Type | Method and Description |
|---|---|
static MediaType.Binary |
applicationBinary(java.lang.String subType,
MediaType.Compressibility comp,
scala.collection.immutable.Seq<java.lang.String> fileExtensions) |
static MediaType.WithFixedCharset |
applicationWithFixedCharset(java.lang.String subType,
HttpCharset charset,
scala.collection.immutable.Seq<java.lang.String> fileExtensions) |
static MediaType.WithOpenCharset |
applicationWithOpenCharset(java.lang.String subType,
scala.collection.immutable.Seq<java.lang.String> fileExtensions) |
static MediaType.Binary |
audio(java.lang.String subType,
MediaType.Compressibility comp,
scala.collection.immutable.Seq<java.lang.String> fileExtensions) |
abstract MediaType.Compressibility |
comp() |
static MediaType |
custom(java.lang.String value,
boolean binary,
MediaType.Compressibility comp,
scala.collection.immutable.List<java.lang.String> fileExtensions) |
static MediaType.Binary |
customBinary(java.lang.String mainType,
java.lang.String subType,
MediaType.Compressibility comp,
scala.collection.immutable.List<java.lang.String> fileExtensions,
scala.collection.immutable.Map<java.lang.String,java.lang.String> params,
boolean allowArbitrarySubtypes) |
static MediaType.Multipart |
customMultipart(java.lang.String subType,
scala.collection.immutable.Map<java.lang.String,java.lang.String> params) |
static MediaType.WithFixedCharset |
customWithFixedCharset(java.lang.String mainType,
java.lang.String subType,
HttpCharset charset,
scala.collection.immutable.List<java.lang.String> fileExtensions,
scala.collection.immutable.Map<java.lang.String,java.lang.String> params,
boolean allowArbitrarySubtypes) |
static MediaType.WithOpenCharset |
customWithOpenCharset(java.lang.String mainType,
java.lang.String subType,
scala.collection.immutable.List<java.lang.String> fileExtensions,
scala.collection.immutable.Map<java.lang.String,java.lang.String> params,
boolean allowArbitrarySubtypes) |
boolean |
equals(java.lang.Object that) |
abstract scala.collection.immutable.List<java.lang.String> |
fileExtensions() |
static MediaType.Binary |
font(java.lang.String subType,
MediaType.Compressibility comp,
scala.collection.immutable.Seq<java.lang.String> fileExtensions) |
int |
hashCode() |
static MediaType.Binary |
image(java.lang.String subType,
MediaType.Compressibility comp,
scala.collection.immutable.Seq<java.lang.String> fileExtensions) |
boolean |
isApplication() |
boolean |
isAudio() |
boolean |
isCompressible()
True when this media-type is generally compressible.
|
boolean |
isImage() |
boolean |
isMessage() |
boolean |
isMultipart() |
boolean |
isText() |
boolean |
isVideo() |
java.lang.String |
mainType()
The main-type of this media-type.
|
static MediaType.Binary |
message(java.lang.String subType,
MediaType.Compressibility comp,
scala.collection.immutable.Seq<java.lang.String> fileExtensions) |
abstract scala.collection.immutable.Map<java.lang.String,java.lang.String> |
params() |
static scala.util.Either<scala.collection.immutable.List<ErrorInfo>,MediaType> |
parse(java.lang.String value)
Tries to parse a
MediaType value from the given String. |
java.lang.String |
subType()
The sub-type of this media-type.
|
static MediaType.WithOpenCharset |
text(java.lang.String subType,
scala.collection.immutable.Seq<java.lang.String> fileExtensions) |
static MediaType.WithFixedCharset |
textWithFixedCharset(java.lang.String subType,
HttpCharset charset,
scala.collection.immutable.Seq<java.lang.String> fileExtensions) |
MediaRange |
toRange()
JAVA API
|
MediaRange |
toRange(float qValue)
Creates a media-range from this media-type with a given qValue.
|
static scala.Option<java.lang.String> |
unapply(MediaType mediaType) |
static MediaType.Binary |
video(java.lang.String subType,
MediaType.Compressibility comp,
scala.collection.immutable.Seq<java.lang.String> fileExtensions) |
abstract MediaType |
withComp(MediaType.Compressibility comp) |
abstract MediaType |
withParams(scala.collection.immutable.Map<java.lang.String,java.lang.String> params) |
MediaRange |
withQValue(float qValue) |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitrender, toString, value, valueByteswithQValuepublic MediaType(java.lang.String _mainType,
java.lang.String _subType)
public static MediaType.Binary applicationBinary(java.lang.String subType, MediaType.Compressibility comp, scala.collection.immutable.Seq<java.lang.String> fileExtensions)
public static MediaType.WithFixedCharset applicationWithFixedCharset(java.lang.String subType, HttpCharset charset, scala.collection.immutable.Seq<java.lang.String> fileExtensions)
public static MediaType.WithOpenCharset applicationWithOpenCharset(java.lang.String subType, scala.collection.immutable.Seq<java.lang.String> fileExtensions)
public static MediaType.Binary audio(java.lang.String subType, MediaType.Compressibility comp, scala.collection.immutable.Seq<java.lang.String> fileExtensions)
public static MediaType.Binary image(java.lang.String subType, MediaType.Compressibility comp, scala.collection.immutable.Seq<java.lang.String> fileExtensions)
public static MediaType.Binary message(java.lang.String subType, MediaType.Compressibility comp, scala.collection.immutable.Seq<java.lang.String> fileExtensions)
public static MediaType.WithOpenCharset text(java.lang.String subType, scala.collection.immutable.Seq<java.lang.String> fileExtensions)
public static MediaType.WithFixedCharset textWithFixedCharset(java.lang.String subType, HttpCharset charset, scala.collection.immutable.Seq<java.lang.String> fileExtensions)
public static MediaType.Binary video(java.lang.String subType, MediaType.Compressibility comp, scala.collection.immutable.Seq<java.lang.String> fileExtensions)
public static MediaType.Binary font(java.lang.String subType, MediaType.Compressibility comp, scala.collection.immutable.Seq<java.lang.String> fileExtensions)
public static MediaType.Binary customBinary(java.lang.String mainType, java.lang.String subType, MediaType.Compressibility comp, scala.collection.immutable.List<java.lang.String> fileExtensions, scala.collection.immutable.Map<java.lang.String,java.lang.String> params, boolean allowArbitrarySubtypes)
public static MediaType.WithFixedCharset customWithFixedCharset(java.lang.String mainType, java.lang.String subType, HttpCharset charset, scala.collection.immutable.List<java.lang.String> fileExtensions, scala.collection.immutable.Map<java.lang.String,java.lang.String> params, boolean allowArbitrarySubtypes)
public static MediaType.WithOpenCharset customWithOpenCharset(java.lang.String mainType, java.lang.String subType, scala.collection.immutable.List<java.lang.String> fileExtensions, scala.collection.immutable.Map<java.lang.String,java.lang.String> params, boolean allowArbitrarySubtypes)
public static MediaType.Multipart customMultipart(java.lang.String subType, scala.collection.immutable.Map<java.lang.String,java.lang.String> params)
public static MediaType custom(java.lang.String value, boolean binary, MediaType.Compressibility comp, scala.collection.immutable.List<java.lang.String> fileExtensions)
public static scala.util.Either<scala.collection.immutable.List<ErrorInfo>,MediaType> parse(java.lang.String value)
MediaType value from the given String.
Returns Right(mediaType) if successful and Left(errors) otherwise.value - (undocumented)public static scala.Option<java.lang.String> unapply(MediaType mediaType)
public java.lang.String mainType()
MediaTypepublic java.lang.String subType()
MediaTypepublic abstract scala.collection.immutable.List<java.lang.String> fileExtensions()
public abstract scala.collection.immutable.Map<java.lang.String,java.lang.String> params()
public abstract MediaType.Compressibility comp()
public boolean isApplication()
isApplication in interface MediaTypepublic boolean isMultipart()
isMultipart in interface MediaTypepublic abstract MediaType withParams(scala.collection.immutable.Map<java.lang.String,java.lang.String> params)
public abstract MediaType withComp(MediaType.Compressibility comp)
public MediaRange withQValue(float qValue)
withQValue in interface WithQValue<MediaRange>public boolean equals(java.lang.Object that)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic MediaRange toRange()
public MediaRange toRange(float qValue)
MediaTypepublic boolean isCompressible()
MediaTypeisCompressible in interface MediaType