public final class MediaType
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
charset |
private java.lang.String |
mediaType |
private static java.util.regex.Pattern |
PARAMETER |
private static java.lang.String |
QUOTED |
private java.lang.String |
subtype |
private static java.lang.String |
TOKEN |
private java.lang.String |
type |
private static java.util.regex.Pattern |
TYPE_SUBTYPE |
Modifier | Constructor and Description |
---|---|
private |
MediaType(java.lang.String mediaType,
java.lang.String type,
java.lang.String subtype,
java.lang.String charset) |
Modifier and Type | Method and Description |
---|---|
java.nio.charset.Charset |
charset()
Returns the charset of this media type, or null if this media type doesn't specify a charset.
|
java.nio.charset.Charset |
charset(java.nio.charset.Charset defaultValue)
Returns the charset of this media type, or
defaultValue if either this media type
doesn't specify a charset, of it its charset is unsupported by the current runtime. |
boolean |
equals(java.lang.Object other) |
static MediaType |
get(java.lang.String string)
Returns a media type for
string . |
int |
hashCode() |
static MediaType |
parse(java.lang.String string)
Returns a media type for
string , or null if string is not a well-formed media
type. |
java.lang.String |
subtype()
Returns a specific media subtype, such as "plain" or "png", "mpeg", "mp4" or "xml".
|
java.lang.String |
toString()
Returns the encoded media type, like "text/plain; charset=utf-8", appropriate for use in a
Content-Type header.
|
java.lang.String |
type()
Returns the high-level media type, such as "text", "image", "audio", "video", or
"application".
|
private static final java.lang.String TOKEN
private static final java.lang.String QUOTED
private static final java.util.regex.Pattern TYPE_SUBTYPE
private static final java.util.regex.Pattern PARAMETER
private final java.lang.String mediaType
private final java.lang.String type
private final java.lang.String subtype
@Nullable private final java.lang.String charset
private MediaType(java.lang.String mediaType, java.lang.String type, java.lang.String subtype, @Nullable java.lang.String charset)
public static MediaType get(java.lang.String string)
string
.java.lang.IllegalArgumentException
- if string
is not a well-formed media type.@Nullable public static MediaType parse(java.lang.String string)
string
, or null if string
is not a well-formed media
type.public java.lang.String type()
public java.lang.String subtype()
@Nullable public java.nio.charset.Charset charset()
@Nullable public java.nio.charset.Charset charset(@Nullable java.nio.charset.Charset defaultValue)
defaultValue
if either this media type
doesn't specify a charset, of it its charset is unsupported by the current runtime.public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(@Nullable java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object