Google Data APIs Client Library (1.41.1)



com.google.gdata.util.parser
Class Repeat<T>

java.lang.Object
  extended by com.google.gdata.util.parser.Parser<T>
      extended by com.google.gdata.util.parser.Repeat<T>
Type Parameters:
T -

public class Repeat<T>
extends Parser<T>

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"


Field Summary
 
Fields inherited from class com.google.gdata.util.parser.Parser
NO_MATCH
 
Constructor Summary
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.
 
Method Summary
 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.
 
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
 

Constructor Detail

Repeat

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.

Repeat

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.
Method Detail

parse

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.

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)