Class QCharset

  • All Implemented Interfaces:
    Comparable

    public class QCharset
    extends Object
    implements Comparable
    This class represent charset to be used. The sorting of this object is based on the Q factor associated with it. The charaset object with more Q factor will be greater.This object allows to represent charaset values received from HTTP header. Example Accept-Charset: ISO-8859-1;Q=0.9 UTF-8 imples UTF-8 takes more precedence over ISO-8859-1. Possible Q values are any floating points between 0 and 1. if Q factor is missing it is assumed to be 1.
    • Constructor Detail

      • QCharset

        public QCharset​(String name,
                        float q)
        Construct a QCharset object.
        Parameters:
        name - Name of the charset.
        q - Q factor to express preference. 0.0 < q < 1.0. Constructs new QCharset set object with charset name and q value.
      • QCharset

        public QCharset​(String name)
        Parameters:
        name - - Name of the charset Constructs new QCharset set object with charset name and q =1.0
    • Method Detail

      • getName

        public String getName()
      • getQFactor

        public float getQFactor()
      • compareTo

        public int compareTo​(Object o1)
        Returns 1 if o1's q value is higher. Returns -1 if o1's q value is lower. Returns 0 if o1's q value is the same.
        Specified by:
        compareTo in interface Comparable
        Parameters:
        o1 - QCharset type object.
        Returns:
        -1,0,1 based on q value.