public final class MediaType extends Object implements Serializable
Also provides constants for common media types used in Mule.
| Modifier and Type | Field and Description |
|---|---|
static MediaType |
ANY |
static MediaType |
APPLICATION_JAVA |
static MediaType |
APPLICATION_JSON |
static MediaType |
APPLICATION_XML |
static MediaType |
ATOM |
static MediaType |
BINARY |
static MediaType |
HTML |
static MediaType |
JSON |
static MediaType |
MULTIPART_FORM_DATA |
static MediaType |
MULTIPART_MIXED |
static MediaType |
MULTIPART_RELATED |
static MediaType |
MULTIPART_X_MIXED_REPLACE |
static MediaType |
RSS |
static MediaType |
TEXT |
static MediaType |
UNKNOWN |
static MediaType |
XML |
| Modifier and Type | Method and Description |
|---|---|
static MediaType |
create(String primaryType,
String subType)
Returns a media-type for.
|
static MediaType |
create(String primaryType,
String subType,
Charset charset)
Returns a media-type for the given parameters.
|
boolean |
equals(Object obj) |
Optional<Charset> |
getCharset() |
String |
getParameter(String paramName) |
String |
getPrimaryType() |
String |
getSubType() |
int |
hashCode() |
boolean |
matches(MediaType other)
Evaluates the type of this object against the ones of the
other MediaType. |
static MediaType |
parse(String mediaType)
Parses a media type from its string representation.
|
String |
toRfcString() |
String |
toString() |
MediaType |
withCharset(Charset charset)
Creates a new
MediaType instance keeping the type and sub-type but replacing the
charset with the value passed. |
MediaType |
withoutParameters()
Creates a new
MediaType instance keeping the type and sub-type but removing all the
parameters (like the charset) |
public static final MediaType ANY
public static final MediaType JSON
public static final MediaType APPLICATION_JSON
public static final MediaType APPLICATION_JAVA
public static final MediaType ATOM
public static final MediaType RSS
public static final MediaType APPLICATION_XML
public static final MediaType XML
public static final MediaType TEXT
public static final MediaType HTML
public static final MediaType BINARY
public static final MediaType UNKNOWN
public static final MediaType MULTIPART_MIXED
public static final MediaType MULTIPART_FORM_DATA
public static final MediaType MULTIPART_RELATED
public static final MediaType MULTIPART_X_MIXED_REPLACE
public static MediaType parse(String mediaType)
mediaType - String representation to be parsedMediaType instance for the parsed mediaType string.IllegalArgumentException - if the mimeType cannot be parsed.public static MediaType create(String primaryType, String subType)
"{primaryType}/{subType}".primaryType - the left part of the represented type.subType - the right part of the represented type.MediaType instance for given parameters.public static MediaType create(String primaryType, String subType, Charset charset)
"{primaryType}/{subType}[; charset={charset}]".primaryType - the left part of the represented type.subType - the right part of the represented type.charset - the value of the charset parameter.MediaType instance for given parameters.public MediaType withCharset(Charset charset)
MediaType instance keeping the type and sub-type but replacing the
charset with the value passed.charset - the new charset to use or null to clear the current charset.MediaType instance.public MediaType withoutParameters()
MediaType instance keeping the type and sub-type but removing all the
parameters (like the charset)MediaType instance.public String getPrimaryType()
public String getSubType()
public Optional<Charset> getCharset()
charset parameter.
This may be not set, in which case it is up to the caller to determine the appropriate charset to use.
public String getParameter(String paramName)
paramName - the name of the parameter to get.paramName parameter.public boolean matches(MediaType other)
other MediaType.
This will ignore any optional parameters, such as the charset.
other - The MediaType to evaluate against.true if the types are the same.public String toRfcString()
"{primaryType}/{subType}[; charset={charset}][;
{params}]".public String toString()
Copyright © 2017 MuleSoft, Inc.. All rights reserved.