| java.lang.Object | ||
| ↳ | com.google.gdata.util.parser.Parser<T> | |
| ↳ | com.google.gdata.util.parser.Chset | |
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
| Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| char | MAX_ASCII_CHAR | ||||||||||
| char | MAX_CHAR | ||||||||||
| char | MIN_CHAR | ||||||||||
|
[Expand]
Inherited Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
com.google.gdata.util.parser.Parser
| |||||||||||
| Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| ALNUM | |||||||||||
| ALPHA | |||||||||||
| ANYCHAR | |||||||||||
| ASCII | |||||||||||
| DIGIT | |||||||||||
| LOWER | |||||||||||
| NOTHING | |||||||||||
| UPPER | |||||||||||
| WHITESPACE | |||||||||||
| XDIGIT | |||||||||||
| asciiSet | A secondary representation for ASCII members of the character set. | ||||||||||
| ranges | |||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Class constructor for an empty character set.
| |||||||||||
Class constructor for a character literal.
| |||||||||||
Class constructor for a single character range.
| |||||||||||
Class constructor that initializes a
Chset from a string
specification. | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Returns a clone character set of
this. | |||||||||||
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. | |||||||||||
Creates a new character set which matches a character if that character
matches both the
left and right character sets. | |||||||||||
Creates a new character set which matches a character if that character
does not match the
subject character set. | |||||||||||
Matches
buf[start] against the character set. | |||||||||||
Tests to see if a single character matches the character set.
| |||||||||||
Creates a new character set which matches a character if that character
matches either the
left or right character sets. | |||||||||||
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. | |||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Returns the size of the range array.
| |||||||||||
Tests to see if a single character matches the character set, but only
looks at the ranges representation.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
com.google.gdata.util.parser.Parser
| |||||||||||
From class
java.lang.Object
| |||||||||||
A secondary representation for ASCII members of the character set. Maintaining this bitmap allows us to check ASCII characters for set membership quickly.
Class constructor for an empty character set.
Class constructor for a character literal.
| ch | The character literal for this character set to match against. |
|---|
Class constructor for a single character range. The range is inclusive:
all character including min and max match.
| min | The beginning of the character range. |
|---|---|
| max | The end of the character range. |
Class constructor that initializes a Chset from a string
specification.
| spec | The string specification to intialize the Chset
from.
|
|---|
Returns a clone character set of this.
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
| left | The left source character set. |
|---|---|
| right | The right source character set. |
Creates a new character set which matches a character if that character
matches both the left and right character sets.
left & right --> left - ~right
| left | The left source character set. |
|---|---|
| right | The right source character set. |
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
| subject | The source character set. |
|---|
Matches buf[start] against the character set.
| 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.
|
Tests to see if a single character matches the character set.
| ch | The character to test. |
|---|
Creates a new character set which matches a character if that character
matches either the left or right character sets.
left | right
| left | The left source character set. |
|---|---|
| right | The right source character set. |
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)
| left | The left source character set. |
|---|---|
| right | The right source character set. |
Returns the size of the range array.
Tests to see if a single character matches the character set, but only looks at the ranges representation.
| ch | The character to test. |
|---|