public interface MediaType
Can also represent a non existent (i.e. empty) value.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
APPLICATION_FORM
"application/x-www-form-urlencoded".
|
static java.lang.String |
APPLICATION_JSON
"application/json".
|
static java.lang.String |
JSON_SUFFIX
"+json".
|
static java.lang.String |
PLAIN_TEXT_UTF8
"text/plain;charset=utf-8".
|
static java.lang.String |
TEXT_HTML
"text/html".
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getCharset()
The value of the "charset" parameter.
|
java.lang.String |
getCharset(java.lang.String defaultValue)
The value of the "charset" parameter, or the given default value of no charset was specified.
|
ImmutableListMultimap<java.lang.String,java.lang.String> |
getParams()
The multimap containing parameters of the mime type.
|
java.lang.String |
getType()
The type without parameters.
|
boolean |
isEmpty()
True if this represents the absence of a value (i.e.
|
boolean |
isForm()
True if this type equals "application/x-www-form-urlencoded".
|
boolean |
isHtml()
True if this type equals "text/html".
|
boolean |
isJson()
True if this type equals "application/json", or ends with "+json".
|
boolean |
isText()
True if this type starts with "
text/ ". |
static final java.lang.String PLAIN_TEXT_UTF8
static final java.lang.String APPLICATION_JSON
static final java.lang.String JSON_SUFFIX
static final java.lang.String APPLICATION_FORM
static final java.lang.String TEXT_HTML
@Nullable java.lang.String getType()
Given a mime type of "text/plain;charset=utf-8", returns "text/plain".
May be null to represent no content type.
ImmutableListMultimap<java.lang.String,java.lang.String> getParams()
Given a mime type of "application/json;charset=utf-8", the get("charset")
returns ["utf-8"]
".
May be empty, never null.
All param names have been lower cased. The charset
parameter values has been lower cased too.
@Nullable java.lang.String getCharset()
null
if the no charset parameter was specifiedjava.lang.String getCharset(java.lang.String defaultValue)
defaultValue
- the value if this type has no charsetboolean isText()
text/
".text/
".boolean isJson()
boolean isForm()
boolean isHtml()
boolean isEmpty()