public final class MediaType extends Object implements Comparable<MediaType>, Serializable
Modifier and Type | Field and Description |
---|---|
static MediaType |
APPLICATION_XML |
static MediaType |
APPLICATION_ZIP |
static MediaType |
EMPTY |
static MediaType |
OCTET_STREAM |
static MediaType |
TEXT_HTML |
static MediaType |
TEXT_PLAIN |
Constructor and Description |
---|
MediaType(MediaType type,
Charset charset)
Creates a media type by adding the "charset" parameter to a base type.
|
MediaType(MediaType type,
Map<String,String> parameters) |
MediaType(MediaType type,
String name,
String value)
Creates a media type by adding a parameter to a base type.
|
MediaType(String type,
String subtype) |
MediaType(String type,
String subtype,
Map<String,String> parameters) |
Modifier and Type | Method and Description |
---|---|
static MediaType |
application(String type) |
static MediaType |
audio(String type) |
int |
compareTo(MediaType that) |
boolean |
equals(Object object) |
MediaType |
getBaseType()
Returns the base form of the MediaType, excluding
any parameters, such as "text/plain" for
"text/plain; charset=utf-8"
|
Map<String,String> |
getParameters()
Returns an immutable sorted map of the parameters of this media type.
|
String |
getSubtype()
Return the Sub-Type of the MediaType,
such as "plain" for "text/plain"
|
String |
getType()
Return the Type of the MediaType, such as
"text" for "text/plain"
|
int |
hashCode() |
boolean |
hasParameters()
Checks whether this media type contains parameters.
|
static MediaType |
image(String type) |
static MediaType |
parse(String string)
Parses the given string to a media type.
|
static Set<MediaType> |
set(MediaType... types)
Convenience method that returns an unmodifiable set that contains
all the given media types.
|
static Set<MediaType> |
set(String... types)
Convenience method that parses the given media type strings and
returns an unmodifiable set that contains all the parsed types.
|
static MediaType |
text(String type) |
String |
toString() |
static MediaType |
video(String type) |
public static final MediaType OCTET_STREAM
public static final MediaType EMPTY
public static final MediaType TEXT_PLAIN
public static final MediaType TEXT_HTML
public static final MediaType APPLICATION_XML
public static final MediaType APPLICATION_ZIP
public MediaType(MediaType type, String name, String value)
type
- base typename
- parameter namevalue
- parameter valuepublic static Set<MediaType> set(MediaType... types)
types
- media typespublic static Set<MediaType> set(String... types)
types
- media type stringspublic static MediaType parse(String string)
string
- media type string to be parsednull
if parsing failspublic MediaType getBaseType()
public String getType()
public String getSubtype()
public boolean hasParameters()
true
if this type has one or more parameters,
false
otherwisepublic Map<String,String> getParameters()
public int compareTo(MediaType that)
compareTo
in interface Comparable<MediaType>
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.