public class QualityArgument extends ParameterizedArgument
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.5
The value of the q
is 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.
Modifier and Type | Field and Description |
---|---|
protected float |
quality
The parsed quality argument in the "Accept" header.
|
argument, PARAMETER_SEP, TOKEN_SEP
CR, currentString, HT, LF, separator, SP
Constructor and Description |
---|
QualityArgument() |
Modifier and Type | Method and Description |
---|---|
float |
getQuality()
Returns the quality value of this argument.
|
void |
initializeNbParameters(int nbTokens)
Sets the quality value to
1 if nbTokens equals to 0 . |
void |
newParameter(int index,
int startKey,
int stopKey,
int startValue,
int stopValue)
Sets the quality value.
|
generate, getArgument, initializeNbTokens, newToken
endParse, parse, parse
public float getQuality()
public void initializeNbParameters(int nbTokens)
1
if nbTokens
equals to 0
.initializeNbParameters
in class ParameterizedArgument
nbTokens
- Sets the quality value to 1
if nbTokens
equals to 0
public void newParameter(int index, int startKey, int stopKey, int startValue, int stopValue)
startValue
and end index
stopValue
. When the quality value String
cannot be parsed as a floating point number, the
value is considered to be 0.newParameter
in class ParameterizedArgument
index
- not usedstartKey
- not usedstopKey
- not usedstartValue
- start index of quality valuestopValue
- end index of quality valueContentType.newParameter(int, int, int, int, int)
,
newParameter(int, int, int, int, int)