@Immutable public final class ContentType extends Object implements Serializable
create(String, String)
method, however, may not
contain characters <">, <;>, <,> reserved by the HTTP specification.Modifier and Type | Field and Description |
---|---|
static ContentType |
APPLICATION_ATOM_XML |
static ContentType |
APPLICATION_FORM_URLENCODED |
static ContentType |
APPLICATION_JSON |
static ContentType |
APPLICATION_OCTET_STREAM |
static ContentType |
APPLICATION_SVG_XML |
static ContentType |
APPLICATION_XHTML_XML |
static ContentType |
APPLICATION_XML |
static ContentType |
DEFAULT_BINARY |
static ContentType |
DEFAULT_TEXT |
static ContentType |
MULTIPART_FORM_DATA |
static ContentType |
TEXT_HTML |
static ContentType |
TEXT_PLAIN |
static ContentType |
TEXT_XML |
static ContentType |
WILDCARD |
Modifier and Type | Method and Description |
---|---|
static ContentType |
create(String mimeType)
Creates a new instance of
ContentType without a charset. |
static ContentType |
create(String mimeType,
Charset charset)
Creates a new instance of
ContentType . |
static ContentType |
create(String mimeType,
String charset)
Creates a new instance of
ContentType . |
static ContentType |
get(HttpEntity entity)
Extracts
Content-Type value from HttpEntity exactly as
specified by the Content-Type header of the entity. |
Charset |
getCharset() |
String |
getMimeType() |
static ContentType |
getOrDefault(HttpEntity entity)
Extracts
Content-Type value from HttpEntity or returns default value
if not explicitly specified. |
static ContentType |
parse(String s)
Parses textual representation of
Content-Type value. |
String |
toString()
Converts a ContentType to a string which can be used as a ContentType header.
|
public static final ContentType APPLICATION_ATOM_XML
public static final ContentType APPLICATION_FORM_URLENCODED
public static final ContentType APPLICATION_JSON
public static final ContentType APPLICATION_OCTET_STREAM
public static final ContentType APPLICATION_SVG_XML
public static final ContentType APPLICATION_XHTML_XML
public static final ContentType APPLICATION_XML
public static final ContentType MULTIPART_FORM_DATA
public static final ContentType TEXT_HTML
public static final ContentType TEXT_PLAIN
public static final ContentType TEXT_XML
public static final ContentType WILDCARD
public static final ContentType DEFAULT_TEXT
public static final ContentType DEFAULT_BINARY
public String getMimeType()
public Charset getCharset()
public String toString()
public static ContentType create(String mimeType, Charset charset)
ContentType
.mimeType
- MIME type. It may not be null
or empty. It may not contain
characters <">, <;>, <,> reserved by the HTTP specification.charset
- charset.public static ContentType create(String mimeType)
ContentType
without a charset.mimeType
- MIME type. It may not be null
or empty. It may not contain
characters <">, <;>, <,> reserved by the HTTP specification.public static ContentType create(String mimeType, String charset) throws UnsupportedCharsetException
ContentType
.mimeType
- MIME type. It may not be null
or empty. It may not contain
characters <">, <;>, <,> reserved by the HTTP specification.charset
- charset. It may not contain characters <">, <;>, <,> reserved by the HTTP
specification. This parameter is optional.UnsupportedCharsetException
public static ContentType parse(String s) throws ParseException, UnsupportedCharsetException
Content-Type
value.s
- textParseException
- if the given text does not represent a valid
Content-Type
value.UnsupportedCharsetException
public static ContentType get(HttpEntity entity) throws ParseException, UnsupportedCharsetException
Content-Type
value from HttpEntity
exactly as
specified by the Content-Type
header of the entity. Returns null
if not specified.entity
- HTTP entityParseException
- if the given text does not represent a valid
Content-Type
value.UnsupportedCharsetException
public static ContentType getOrDefault(HttpEntity entity) throws ParseException, UnsupportedCharsetException
Content-Type
value from HttpEntity
or returns default value
if not explicitly specified.entity
- HTTP entityParseException
- if the given text does not represent a valid
Content-Type
value.UnsupportedCharsetException
Copyright © 2005-2015 The Apache Software Foundation. All Rights Reserved.