public class MediaType
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
MediaType.Type
Represents the type of a Media Type
|
Modifier and Type | Field and Description |
---|---|
static MediaType |
APPLICATION_XML_UTF_8
application/xml
|
static MediaType |
GIF
image/gif
|
static MediaType |
JPEG
image/jpeg
|
static MediaType |
JSON_UTF_8
application/json
|
static MediaType |
PLAIN_TEXT
Deprecated.
use PLAIN_TEXT_UTF_8 instead
|
static MediaType |
PLAIN_TEXT_UTF_8
text/plain
|
static MediaType |
PNG
image/png
|
static MediaType |
SVG_UTF_8
image/svg+xml
|
static MediaType |
XML_UTF_8
text/xml
|
Constructor and Description |
---|
MediaType(MediaType.Type type,
java.lang.String subType,
boolean binary)
Deprecated.
please use static factory methods instead
|
Modifier and Type | Method and Description |
---|---|
static MediaType |
application(java.lang.String subType)
Creates a binary application media type with the given subtype.
|
static MediaType |
applicationUtf8(java.lang.String subType)
Creates a textual application media type with the given subtype and UTF-8 encoding
|
java.lang.String |
asString() |
static MediaType |
audio(java.lang.String subType)
Creates a binary audio media type with the given subtype.
|
static MediaType |
binary(MediaType.Type type,
java.lang.String subType)
Creates a binary media type with the given type and subtype
|
java.nio.charset.Charset |
getCharset() |
java.lang.String |
getSubType()
The subtype of the Media Type.
|
MediaType.Type |
getType()
The type of the Media Type.
|
static MediaType |
image(java.lang.String subType)
Creates a binary image media type with the given subtype.
|
static MediaType |
imageUtf8(java.lang.String subType)
Creates a textual image media type with the given subtype and UTF-8 encoding
|
boolean |
isBinary()
Whether this media type is binary or not.
|
boolean |
isImage() |
static MediaType |
nonBinary(MediaType.Type type,
java.lang.String subType,
java.nio.charset.Charset charSet)
Creates a non-binary media type with the given type, subtype, and charSet
|
static MediaType |
nonBinaryUtf8(MediaType.Type type,
java.lang.String subType)
Creates a non-binary media type with the given type, subtype, and UTF-8 encoding
|
static MediaType |
text(java.lang.String subType)
Deprecated.
use a method with a specific encoding
|
static MediaType |
text(java.lang.String subType,
java.nio.charset.Charset charset)
Creates a non-binary text media type with the given subtype and a specified encoding
|
static MediaType |
textUtf8(java.lang.String subType)
Creates a non-binary text media type with the given subtype.
|
static MediaType |
video(java.lang.String subType)
Creates a binary video media type with the given subtype.
|
public static final MediaType GIF
public static final MediaType PNG
public static final MediaType JPEG
public static final MediaType SVG_UTF_8
@Deprecated public static final MediaType PLAIN_TEXT
public static final MediaType PLAIN_TEXT_UTF_8
public static final MediaType JSON_UTF_8
public static final MediaType APPLICATION_XML_UTF_8
public static final MediaType XML_UTF_8
@Deprecated public MediaType(MediaType.Type type, java.lang.String subType, boolean binary)
type
- the typesubType
- the subtypebinary
- whether or not content of this media type is binary. If true
, the
content will be encoded as Base64 when stored in the JSON model.JGivenWrongUsageException
- if any of the parameters is null
public MediaType.Type getType()
public java.lang.String getSubType()
public boolean isBinary()
public boolean isImage()
public java.nio.charset.Charset getCharset()
java.lang.IllegalArgumentException
- if no charset is specifiedpublic java.lang.String asString()
public static MediaType binary(MediaType.Type type, java.lang.String subType)
JGivenWrongUsageException
- if any of the given arguments is null
public static MediaType nonBinary(MediaType.Type type, java.lang.String subType, java.nio.charset.Charset charSet)
JGivenWrongUsageException
- if any of the given arguments is null
public static MediaType nonBinaryUtf8(MediaType.Type type, java.lang.String subType)
JGivenWrongUsageException
- if any of the given arguments is null
public static MediaType image(java.lang.String subType)
public static MediaType imageUtf8(java.lang.String subType)
public static MediaType application(java.lang.String subType)
public static MediaType applicationUtf8(java.lang.String subType)
public static MediaType video(java.lang.String subType)
public static MediaType audio(java.lang.String subType)
@Deprecated public static MediaType text(java.lang.String subType)
public static MediaType text(java.lang.String subType, java.nio.charset.Charset charset)
public static MediaType textUtf8(java.lang.String subType)