Package ej.hoka.http.support
Class QualityArgument
- java.lang.Object
-
- ej.hoka.http.support.CharacterSeparatedList
-
- ej.hoka.http.support.ParameterizedArgument
-
- ej.hoka.http.support.QualityArgument
-
public class QualityArgument extends ParameterizedArgument
Class for handling HTTP "Accept" header quality argument.The class parses the quality argument in the following form:
Accept: text/html; q=1.0, text/*; q=0.8, image/gif; q=0.6, image/jpeg; q=0.6, image/*; q=0.5The value of the
qis a short floating point number (range: 0.0-1.0) denoting the relative "acceptance" value of a content-type. If omitted the default value is 1.0.
-
-
Field Summary
Fields Modifier and Type Field Description protected floatqualityThe parsed quality argument in the "Accept" header.-
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 QualityArgument()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description floatgetQuality()Returns the quality value of this argument.voidinitializeNbParameters(int nbTokens)Sets the quality value to1ifnbTokensequals to0.voidnewParameter(int index, int startKey, int stopKey, int startValue, int stopValue)Sets the quality value.-
Methods inherited from class ej.hoka.http.support.ParameterizedArgument
generate, getArgument, initializeNbTokens, newToken
-
Methods inherited from class ej.hoka.http.support.CharacterSeparatedList
endParse, parse, parse
-
-
-
-
Method Detail
-
getQuality
public float getQuality()
Returns the quality value of this argument.- Returns:
- the quality
-
initializeNbParameters
public void initializeNbParameters(int nbTokens)
Sets the quality value to1ifnbTokensequals to0.- Specified by:
initializeNbParametersin classParameterizedArgument- Parameters:
nbTokens- Sets the quality value to1ifnbTokensequals to0
-
newParameter
public void newParameter(int index, int startKey, int stopKey, int startValue, int stopValue)Sets the quality value. The value is in the substring within begin indexstartValueand end indexstopValue. When the quality valueStringcannot be parsed as a floating point number, the value is considered to be 0.- Specified by:
newParameterin classParameterizedArgument- Parameters:
index- not usedstartKey- not usedstopKey- not usedstartValue- start index of quality valuestopValue- end index of quality value- See Also:
ContentType.newParameter(int, int, int, int, int),newParameter(int, int, int, int, int)
-
-