public class

Repeat

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

Class Overview

The Repeat parser returns a successful match if its subject parser matches at least min times, but not more than max times. The Repeat parser is used to implement the Parser.star() and Parser.plus() methods by specifying appropriate values for min and max. The following matches a string of 1 to 3 letters: Parse p = Chset.ALPHA.repeat(1, 3); p.parse("") -> no match p.parse("a") -> matches "a" p.parse("aa") -> matches "aa" p.parse("aaa") -> matches "aaa" p.parse("aaaa") -> matches "aaa"

Summary

[Expand]
Inherited Constants
From class com.google.gdata.util.parser.Parser
Fields
private int max
private int min
private Parser<T> subject
Public Constructors
Repeat(Parser<T> subject, int min)
Class constructor that is used for creating a Repeat object that will match its subject min or more times.
Repeat(Parser<T> subject, int min, int max)
Class constructor that is used for creating a Repeat object that will match its subject at least min times but not more than max times.
Public Methods
int parse(char[] buf, int start, int end, T data)
Matches the subject parser against the prefix of the buffer (buf[start,end)) being parsed if the subject parser matches at least min times and not more than max times in sequence.
[Expand]
Inherited Methods
From class com.google.gdata.util.parser.Parser
From class java.lang.Object

Fields

private int max

private int min

private Parser<T> subject

Public Constructors

public Repeat (Parser<T> subject, int min)

Class constructor that is used for creating a Repeat object that will match its subject min or more times.

Parameters
subject The Parse that this parser will repeatedly match.
min The minimum number of times the subject parser must match.

public Repeat (Parser<T> subject, int min, int max)

Class constructor that is used for creating a Repeat object that will match its subject at least min times but not more than max times. Specifying -1 for max causes the parser to match as many times as possible.

Parameters
subject The Parse that this parser will repeatedly match.
min The minimum number of times the subject parser must match.
max The maximum number of times the subject parser can match.

Public Methods

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

Matches the subject parser against the prefix of the buffer (buf[start,end)) being parsed if the subject parser matches at least min times and not more than max times 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