public class ContentType extends ParameterizedArgument
This class handles the HTTP Content-Type header field.
See: RFC HTTP/1.1 RFC2616 14.1 Content-Type
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
KEY_CHARSET
The string "charset".
|
argument, PARAMETER_SEP, TOKEN_SEP
CR, currentString, HT, LF, separator, SP
Constructor and Description |
---|
ContentType()
Empty Constructor.
|
ContentType(java.lang.String mimeType)
Constructor with MIME type parameter.
|
ContentType(java.lang.String mimeType,
java.lang.String charset)
Constructor with MIME type and character set parameters.
|
Modifier and Type | Method and Description |
---|---|
void |
endParse()
IS2T-API Canonises the MIME type.
|
java.lang.StringBuilder |
generate(java.lang.StringBuilder sb)
Appends the current character set to the
StringBuffer sb in the following form:
;charset=<character-set-string> . |
java.lang.String |
getCharset()
Returns the optional charset.
|
java.lang.String |
getMIMEType()
Returns the canonized MIME type (converted to lower case).
|
protected void |
initializeNbParameters(int nbParameters)
Does nothing.
|
protected void |
newParameter(int id,
int startKey,
int stopKey,
int startValue,
int stopValue)
Checks if the key value (from index startKey to index stopKey) equals to "charset" and updates the internally
stored charset to the value extracted from index startValue to index stopValue from the
CharacterSeparatedList.currentString . |
getArgument, initializeNbTokens, newToken
parse, parse
public static final java.lang.String KEY_CHARSET
The string "charset".
public ContentType()
Empty Constructor.
public ContentType(java.lang.String mimeType)
Constructor with MIME type parameter.
mimeType
- the MIME type to use for content typepublic ContentType(java.lang.String mimeType, java.lang.String charset)
Constructor with MIME type and character set parameters.
mimeType
- the MIME type to use as content typecharset
- the character set to usepublic void endParse()
At the end of the parsing, converts the MIME type to lower case and interns it.
endParse
in class CharacterSeparatedList
public java.lang.StringBuilder generate(java.lang.StringBuilder sb)
Appends the current character set to the StringBuffer
sb
in the following form:
;charset=<character-set-string>
.
generate
in class ParameterizedArgument
sb
- the StringBuffer
StringBuffer
sb
.public java.lang.String getCharset()
Returns the optional charset. Could be null.
public java.lang.String getMIMEType()
Returns the canonized MIME type (converted to lower case).
protected void initializeNbParameters(int nbParameters)
initializeNbParameters
in class ParameterizedArgument
nbParameters
- not used.protected void newParameter(int id, int startKey, int stopKey, int startValue, int stopValue)
CharacterSeparatedList.currentString
.newParameter
in class ParameterizedArgument
id
- not usedstartKey
- start index of keystopKey
- end index of keystartValue
- start index of character set substringstopValue
- end index of character set substringnewParameter(int, int, int, int, int)
,
QualityArgument.newParameter(int, int, int, int, int)