public class ContentType extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ContentType.SettableContentType
Mutable
ContentType object. |
Modifier and Type | Method and Description |
---|---|
static byte[] |
compose(byte[] mimeType,
String charset)
Composes a content-type array, based on the mime-type represented by a byte array
and a charset attribute value, represented by a
String . |
String |
get() |
int |
getArrayLen()
Used in conjunction with
getByteArray() . |
byte[] |
getByteArray() |
String |
getCharacterEncoding() |
static String |
getCharsetFromContentType(String contentType)
Parse the character encoding from the specified content type header.
|
String |
getMimeType()
Returns the mime-type part of the content-type (the part without charset attribute).
|
boolean |
isMimeTypeSet() |
boolean |
isSet() |
static ContentType |
newContentType(String contentType)
Creates a
ContentType wrapper over a String
content-type representation. |
static ContentType |
newContentType(String mimeType,
String characterEncoding)
Creates a
ContentType wrapper over the passed mime-type and
character encoding. |
static ContentType.SettableContentType |
newSettableContentType() |
ContentType |
prepare()
Prepare the ContentType for the serialization.
|
static byte[] |
removeCharset(byte[] contentType)
Removes the charset attribute from the content-type represented by an array.
|
protected void |
reset()
Resets the ContentType state.
|
void |
serializeToDataChunk(DataChunk dc)
Serializes this ContentType value into a passed
DataChunk . |
protected void |
set(ContentType contentType)
Sets the content type.
|
protected void |
set(String contentType)
Sets the content type.
|
protected void |
setCharacterEncoding(String charset)
Sets the the character encoding (the content-type's charset attribute value).
|
protected void |
setMimeType(String mimeType)
Sets the mime-type part of the content-type (the part without charset attribute).
|
String |
toString() |
public static ContentType.SettableContentType newSettableContentType()
ContentType.SettableContentType
, the mutable ContentType
representation.public static ContentType newContentType(String contentType)
ContentType
wrapper over a String
content-type representation.contentType
- String
content-type representationContentType
wrapper over a String
content-type representationpublic static ContentType newContentType(String mimeType, String characterEncoding)
ContentType
wrapper over the passed mime-type and
character encoding.mimeType
- String
mimeType-type representation
(like "text/plain", "text/html", etc), which doesn't contain charset
informationcharacterEncoding
- charset attribute to be used with the mime-typeContentType
wrapper over the passed mime-type and
character encodingpublic ContentType prepare()
public boolean isSet()
public boolean isMimeTypeSet()
public String getMimeType()
protected void setMimeType(String mimeType)
mimeType
- the mime-type part of the content-type (the part without charset attribute)public String getCharacterEncoding()
protected void setCharacterEncoding(String charset)
charset
- the character encoding (the content-type's charset attribute value)public int getArrayLen()
getByteArray()
. The array returned by
the aforementioned method may be larger than the data contained therein.
This method will return the proper data length.getByteArray()
public byte[] getByteArray()
public String get()
protected void set(String contentType)
contentType
- the content typeprotected void set(ContentType contentType)
contentType
- the content typepublic void serializeToDataChunk(DataChunk dc)
DataChunk
.dc
- DataChunk
protected void reset()
public static String getCharsetFromContentType(String contentType)
null
is returned.contentType
- a content type headerpublic static byte[] removeCharset(byte[] contentType)
contentType
- the content-type represented by an arraypublic static byte[] compose(byte[] mimeType, String charset)
String
.mimeType
- a mime-type part of the content-type (doesn't contain charset attribute)charset
- charset attribute valueString
Copyright © 2015 Oracle Corporation. All rights reserved.