net.sf.parcinj
Class Sequence<P extends Processor>

java.lang.Object
  extended by net.sf.parcinj.AbstractSymbol<P>
      extended by net.sf.parcinj.Sequence<P>
All Implemented Interfaces:
Symbol<P>

public class Sequence<P extends Processor>
extends AbstractSymbol<P>

Sequence of symbols.


Field Summary
protected  java.util.List<Symbol<P>> _symbols
           
 
Constructor Summary
Sequence()
          Creates an empty sequence.
Sequence(Symbol<P> firstSymbol)
          Creates a sequence with one symbol.
 
Method Summary
 void addSymbol(Symbol<P> symbol)
          Adds the specified symbol.
 void doProcess(TokenIterator iterator, P processor)
          Processes this sequence by processing symbol by symbol.
 AbstractSymbol<P> followedBy(Symbol<P> symbol)
          Appends the specified symbol to this sequence.
 MatchingResult matches(Token token)
          Returns MatchingResult.OK if either the sequence is empty or the first symbol matches the specified token.
 
Methods inherited from class net.sf.parcinj.AbstractSymbol
oneOrMoreTimes, optional, or, process, zeroOrMoreTimes, zeroOrMoreTimesSeparatedBy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_symbols

protected final java.util.List<Symbol<P extends Processor>> _symbols
Constructor Detail

Sequence

public Sequence()
Creates an empty sequence.


Sequence

public Sequence(Symbol<P> firstSymbol)
Creates a sequence with one symbol.

Method Detail

followedBy

public AbstractSymbol<P> followedBy(Symbol<P> symbol)
Appends the specified symbol to this sequence.

Specified by:
followedBy in interface Symbol<P extends Processor>
Overrides:
followedBy in class AbstractSymbol<P extends Processor>
Returns:
this.

matches

public MatchingResult matches(Token token)
Returns MatchingResult.OK if either the sequence is empty or the first symbol matches the specified token.

Parameters:
token - Token to be checked. Will be null if beyond last token.

doProcess

public void doProcess(TokenIterator iterator,
                      P processor)
Processes this sequence by processing symbol by symbol. For each symbol Symbol.process(TokenIterator, Processor) is invoked.

Specified by:
doProcess in class AbstractSymbol<P extends Processor>
processor - Processor who does the actual processing.

addSymbol

public void addSymbol(Symbol<P> symbol)
Adds the specified symbol.