Class 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.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.

    • Field Detail

      • quality

        protected float quality
        The parsed quality argument in the "Accept" header.
    • Constructor Detail

      • QualityArgument

        public QualityArgument()
    • 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 to 1 if nbTokens equals to 0.
        Specified by:
        initializeNbParameters in class ParameterizedArgument
        Parameters:
        nbTokens - Sets the quality value to 1 if nbTokens equals to 0
      • 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 index 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.
        Specified by:
        newParameter in class ParameterizedArgument
        Parameters:
        index - not used
        startKey - not used
        stopKey - not used
        startValue - start index of quality value
        stopValue - end index of quality value
        See Also:
        ContentType.newParameter(int, int, int, int, int), newParameter(int, int, int, int, int)