Package ej.hoka.http.support
Class ContentType
- java.lang.Object
-
- ej.hoka.http.support.CharacterSeparatedList
-
- ej.hoka.http.support.ParameterizedArgument
-
- ej.hoka.http.support.ContentType
-
public class ContentType extends ParameterizedArgument
This class handles the HTTP Content-Type header field. See: RFC HTTP/1.1 RFC2616 14.1 Content-Type
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringKEY_CHARSETThe string "charset".-
Fields inherited from class ej.hoka.http.support.ParameterizedArgument
argument, PARAMETER_SEP, TOKEN_SEP
-
Fields inherited from class ej.hoka.http.support.CharacterSeparatedList
CR, currentString, HT, LF, separator, SP
-
-
Constructor Summary
Constructors Constructor 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidendParse()IS2T-API Canonises the MIME type.java.lang.StringBuildergenerate(java.lang.StringBuilder sb)Appends the current character set to theStringBuffersbin the following form:;charset=<character-set-string>.java.lang.StringgetCharset()Returns the optional charset.java.lang.StringgetMIMEType()Returns the canonized MIME type (converted to lower case).protected voidinitializeNbParameters(int nbParameters)Does nothing.protected voidnewParameter(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 theCharacterSeparatedList.currentString.-
Methods inherited from class ej.hoka.http.support.ParameterizedArgument
getArgument, initializeNbTokens, newToken
-
Methods inherited from class ej.hoka.http.support.CharacterSeparatedList
parse, parse
-
-
-
-
Field Detail
-
KEY_CHARSET
public static final java.lang.String KEY_CHARSET
The string "charset".- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ContentType
public ContentType()
Empty Constructor.
-
ContentType
public ContentType(java.lang.String mimeType)
Constructor with MIME type parameter.- Parameters:
mimeType- the MIME type to use for content type
-
ContentType
public ContentType(java.lang.String mimeType, java.lang.String charset)Constructor with MIME type and character set parameters.- Parameters:
mimeType- the MIME type to use as content typecharset- the character set to use
-
-
Method Detail
-
endParse
public void endParse()
IS2T-API Canonises the MIME type.At the end of the parsing, converts the MIME type to lower case and interns it.
- Overrides:
endParsein classCharacterSeparatedList
-
generate
public java.lang.StringBuilder generate(java.lang.StringBuilder sb)
Appends the current character set to theStringBuffersbin the following form:;charset=<character-set-string>.- Overrides:
generatein classParameterizedArgument- Parameters:
sb- theStringBuffer- Returns:
- the
StringBuffersb.
-
getCharset
@Nullable public java.lang.String getCharset()
Returns the optional charset. Could be null.- Returns:
- the optional charset.
-
getMIMEType
@Nullable public java.lang.String getMIMEType()
Returns the canonized MIME type (converted to lower case).- Returns:
- the canonized MIME type (converted to lower case)
-
initializeNbParameters
protected void initializeNbParameters(int nbParameters)
Does nothing.- Specified by:
initializeNbParametersin classParameterizedArgument- Parameters:
nbParameters- not used.
-
newParameter
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 theCharacterSeparatedList.currentString.- Specified by:
newParameterin classParameterizedArgument- Parameters:
id- not usedstartKey- start index of keystopKey- end index of keystartValue- start index of character set substringstopValue- end index of character set substring- See Also:
newParameter(int, int, int, int, int),QualityArgument.newParameter(int, int, int, int, int)
-
-