Google Data APIs Client Library (1.41.1)
com.google.gdata.util.parser
Class Difference<T>
java.lang.Object
com.google.gdata.util.parser.Parser<T>
com.google.gdata.util.parser.Difference<T>
- Type Parameters:
T
-
public class Difference<T>
- extends Parser<T>
The Difference
parser matches the prefix of the parse buffer if
the left
parser matches and the right
parser does
not.
The following is a complicated way of constructing a parser which matches a
digit:
Parser p = Parser.difference(Chset.ALNUM, Chset.ALPHA);
p.parse("0") -> matches "0"
p.parse("a") -> no match
- See Also:
Parser
Fields inherited from class com.google.gdata.util.parser.Parser |
NO_MATCH |
Method Summary |
int |
parse(char[] buf,
int start,
int end,
T data)
Matches the prefix of the buffer (buf[start,end) ) being
parsed if, and only if, the left sub-parser matches the
incoming state of the buffer and the right sub-parser does
not match the incoming state of the parse buffer. |
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 |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Difference
public Difference(Parser<? super T> left,
Parser<? super T> right)
- Class constructor.
- Parameters:
left
- The Parser
that must match against the
parse buffer.right
- The Parser
that must not match against
the parse buffer.
parse
public int parse(char[] buf,
int start,
int end,
T data)
- Matches the prefix of the buffer (
buf[start,end)
) being
parsed if, and only if, the left
sub-parser matches the
incoming state of the buffer and the right
sub-parser does
not match the incoming state of the parse buffer. It does not make much
sense to specify a right
sub-parser that matches the empty
string as doing so will cause this function to always return
NO_MATCH
.
- Specified by:
parse
in class Parser<T>
- 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)