public class

Sequence

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

Class Overview

The Sequence parser matches if its left parser matches the prefix of the parse buffer and then its right parser matches (in sequence) the prefix of whatever remains in the parse buffer. Contrast this with the Alternative and Intersection parsers which apply their sub-parsers to the same portion of the parse buffer. The following matches a string composed of letters followed by digits: Parser p = Parser.sequence(Chset.ALPHA.plus(), Chset.DIGIT.plus()); p.parse("a0") -> matches "a0" p.parse("aaa0") -> matches "aaa0" p.parse("aaa000") -> matches "aaa0000" p.parse("a1a") -> matches "a1" p.parse("a") -> no match, does not end in a digit p.parse("0") -> no match, does not start with a letter

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
Sequence(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 in sequence.
[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 Sequence (Parser<? super T> left, Parser<? super T> right)

Class constructor.

Parameters
left The Parser that is matched against the parse buffer first.
right The Parser that is matched against what remains of the parse buffer if the left parser 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 in sequence.

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