public class

Intersection

extends Parser<T>
java.lang.Object
   ↳ com.google.gdata.util.parser.Parser<T>
     ↳ com.google.gdata.util.parser.Intersection<T>

Class Overview

The Intersection parser provides one of the more powerful pieces of functionality in the parser framework. It returns a successful match only if both the left and right sub-parsers match. Additionally, the amount of parse data passed to the right parser is restricted to the size of the match for the left parser. This allows certain types of recursively defined grammars to be more easily specified. Note that this definition of intersection is not the same as a set-theoretic definition. In particular, this definition is not commutative. Parser i = Parser.intersection(Chset.ALPHA.plus(), Chset.ALNUM.plus()); i.parse("a", null) -> matches "a" i.parse("a1", null) -> matches "a" Parser j = Parser.intersection(Chset.ALNUM.plus(), Chset.ALPHA.plus()); j.parse("a", null) -> matches "a" j.parse("a1", null) -> no match, because ALNUM+ matches "a1" which doesn't match ALPHA+

See Also

Summary

[Expand]
Inherited Constants
From class com.google.gdata.util.parser.Parser
Fields
private Parser<? super T> left
private Parser<? super T> right
Public Constructors
Intersection(Parser<? super T> left, Parser<? super T> right)
Class constructor.
Public Methods
int parse(char[] buf, int start, int end, T data)
Matches the prefix of the buffer (buf[start,end)) being parsed against the left and right sub-parsers.
[Expand]
Inherited Methods
From class com.google.gdata.util.parser.Parser
From class java.lang.Object

Fields

private Parser<? super T> left

private Parser<? super T> right

Public Constructors

public Intersection (Parser<? super T> left, Parser<? super T> right)

Class constructor.

Parameters
left The Parser that is first matched against the parse buffer. It restricts the region of the parse buffer that is matched against the right parser.
right The Parser that is matched against the parse buffer if the left parses has already matched.

Public Methods

public int parse (char[] buf, int start, int end, T data)

Matches the prefix of the buffer (buf[start,end)) being parsed against the left and right sub-parsers.

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