# Google Data APIs Client Library (1.43.0)

## com.google.gdata.util.parser
Class Chset

    java.lang.Object
      com.google.gdata.util.parser.Parser<java.lang.Object>
          com.google.gdata.util.parser.Chset

All Implemented Interfaces:
  java.lang.Cloneable

    public class Chset

extends Parser<java.lang.Object>
implements java.lang.Cloneable

The `Chset` (character set) parser matches the current character in the parse buffer against an arbitrary character set. The character set is represented as a sorted array of ranges for which a match should be successful. Matching takes O(log nranges) time. There are predefined character sets for matching any character (`ANYCHAR`), no characters (`NOTHING`) and some standard 7-bit ASCII ranges (`ALNUM`, `ALPHA`, `DIGIT`, `XDIGIT`, `LOWER`, `UPPER`, `WHITESPACE`), and `ASCII`. Note that the character set parser only matches a single character of the parse buffer. The `Sequence` or Repeat parsers need to be used to match more than one character. The following matches vowels and digits: Parser p = new Chset("uoiea0-9"); p.parse("a") -> matches "a" p.parse("3") -> matches "3" p.parse("b") -> no match

See Also:
  `Parser`

Field Summary
`static Chset` `ALNUM`
`static Chset` `ALPHA`
`static Chset` `ANYCHAR`
`static Chset` `ASCII`
`static Chset` `DIGIT`
`static Chset` `LOWER`
`protected static char` `MAX_CHAR`
`protected static char` `MIN_CHAR`
`static Chset` `NOTHING`
`static Chset` `UPPER`
`static Chset` `WHITESPACE`
`static Chset` `XDIGIT`

Fields inherited from class com.google.gdata.util.parser.Parser
`NO_MATCH`

Constructor Summary
`Chset()` Class constructor for an empty character set.
`Chset(char ch)` Class constructor for a character literal.
`Chset(char min, char max)` Class constructor for a single character range.
`Chset(java.lang.String spec)` Class constructor that initializes a `Chset` from a string specification.

Method Summary
`protected void` `clear(char min, char max)`
`java.lang.Object` `clone()` Returns a clone character set of `this`.
`static Chset` `difference(Chset left, Chset right)` Creates a new character set which matches a character if that character matches the `left` character set but does not match the `right` character set.
`static Chset` `intersection(Chset left, Chset right)` Creates a new character set which matches a character if that character matches both the `left` and `right` character sets.
`static Chset` `not(Chset subject)` Creates a new character set which matches a character if that character does not match the `subject` character set.
`int` `parse(char[] buf, int start, int end, java.lang.Object data)` Matches `buf[start]` against the character set.
`protected void` `set(char min, char max)`
`protected int` `size()` Returns the size of the range array.
`boolean` `test(char ch)` Tests to see if a single character matches the character set.
`protected boolean` `testRanges(char ch)` Tests to see if a single character matches the character set, but only looks at the ranges representation.
`java.lang.String` `toString()`
`static Chset` `union(Chset left, Chset right)` Creates a new character set which matches a character if that character matches either the `left` or `right` character sets.
`static Chset` `xor(Chset left, Chset right)` Creates a new character set which matches a character if that character matches the `left` character set or the `right` character set, but not both.

Methods inherited from class com.google.gdata.util.parser.Parser
`action, alternative, difference, intersection, list, optional, parse, parse, parse, plus, repeat, repeat, sequence, sequence, sequence, sequence, star`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### MIN_CHAR

    protected static final char MIN_CHAR

See Also:
  Constant Field Values

### MAX_CHAR

    protected static final char MAX_CHAR

See Also:
  Constant Field Values

### ANYCHAR

    public static final Chset ANYCHAR

### NOTHING

    public static final Chset NOTHING

### ALNUM

    public static final Chset ALNUM

### ALPHA

    public static final Chset ALPHA

### DIGIT

    public static final Chset DIGIT

### XDIGIT

    public static final Chset XDIGIT

### LOWER

    public static final Chset LOWER

### UPPER

    public static final Chset UPPER

### WHITESPACE

    public static final Chset WHITESPACE

### ASCII

    public static final Chset ASCII

Constructor Detail

### Chset

    public Chset()

  Class constructor for an empty character set.

### Chset

    public Chset(char ch)

  Class constructor for a character literal.

  Parameters:
    `ch` - The character literal for this character set to match against.

### Chset

    public Chset(char min,
                 char max)

  Class constructor for a single character range. The range is inclusive: all character including `min` and `max` match.

  Parameters:
    `min` - The beginning of the character range.
    `max` - The end of the character range.

### Chset

    public Chset(java.lang.String spec)

  Class constructor that initializes a `Chset` from a string specification.

  Parameters:
    `spec` - The string specification to intialize the `Chset` from.

Method Detail

### clone

    public java.lang.Object clone()

  Returns a clone character set of `this`.

  Overrides:
    `clone` in class `java.lang.Object`

### parse

    public int parse(char[] buf,
                     int start,
                     int end,
                     java.lang.Object data)

  Matches `buf[start]` against the character set.

  Specified by:
    `parse` in class `Parser<java.lang.Object>`
  Parameters:
    `buf` - The character array to match against.
    `start` - The start offset of data within the character array to match against.
    `end` - The end offset of data within the character array to match against.
    `data` - User defined object that is passed to `Callback.handle` when an `Action` fires.
  See Also:
    `Parser.parse(char[], int, int, T)`

### test

    public boolean test(char ch)

  Tests to see if a single character matches the character set.

  Parameters:
    `ch` - The character to test.

### testRanges

    protected boolean testRanges(char ch)

  Tests to see if a single character matches the character set, but only looks at the ranges representation.

  Parameters:
    `ch` - The character to test.

### set

    protected void set(char min,
                       char max)

  See Also:
    `set(char, char)`

### clear

    protected void clear(char min,
                         char max)

  See Also:
    `clear(char, char)`

### size

    protected int size()

  Returns the size of the range array.

### not

    public static Chset not(Chset subject)

  Creates a new character set which matches a character if that character does not match the `subject` character set. This operation is implemented by taking the difference of the `ANYCHAR` character set and the `subject` character set. ~subject --> anychar - subject

  Parameters:
    `subject` - The source character set.

### union

    public static Chset union(Chset left,
                              Chset right)

  Creates a new character set which matches a character if that character matches either the `left` or `right` character sets. left | right

  Parameters:
    `left` - The left source character set.
    `right` - The right source character set.

### difference

    public static Chset difference(Chset left,
                                   Chset right)

  Creates a new character set which matches a character if that character matches the `left` character set but does not match the `right` character set. left - right

  Parameters:
    `left` - The left source character set.
    `right` - The right source character set.

### intersection

    public static Chset intersection(Chset left,
                                     Chset right)

  Creates a new character set which matches a character if that character matches both the `left` and `right` character sets. left & right --> left - ~right

  Parameters:
    `left` - The left source character set.
    `right` - The right source character set.

### xor

    public static Chset xor(Chset left,
                            Chset right)

  Creates a new character set which matches a character if that character matches the `left` character set or the `right` character set, but not both. left ^ right --> (left - right) | (right - left)

  Parameters:
    `left` - The left source character set.
    `right` - The right source character set.

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`