org.translet.processor
Class TokenIteratorImpl

java.lang.Object
  |
  +--org.translet.processor.TokenIteratorImpl
All Implemented Interfaces:
TokenIterator

public class TokenIteratorImpl
extends Object
implements TokenIterator

Iterator across a specified range of the tokens generated from the xpath expressions.

Version:
$Revision: 1.4 $
Author:
Karthikeyan M.

Constructor Summary
TokenIteratorImpl(Object[] tokens, int offset, int length)
           
 
Method Summary
 TokenIterator createSnapshot()
          Creates a snapshot since the time markForSnapshot was called including all the elements that was gotten using next().
 boolean hasNext()
          Moves the current token cursor to the next token
 boolean hasPrevious()
          Check if previous will return valid token.
 void markForSnapshot()
          Marks the position to start recoding.
 String next()
          Returns the value of the token.
 boolean nextTokenIs(char c)
          Returns true if the next token is the char specified.
 String peekNext()
          Peeks the next token w/o incrementing cursor.
 String previous()
          Returns the previous element in the list.
 void rewind()
          Re-initializes the iterator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TokenIteratorImpl

public TokenIteratorImpl(Object[] tokens,
                         int offset,
                         int length)
Parameters:
offset - The offset using a zero based array.
length - Number of tokens to be processed.
Method Detail

hasNext

public boolean hasNext()
Moves the current token cursor to the next token
Specified by:
hasNext in interface TokenIterator

nextTokenIs

public boolean nextTokenIs(char c)
Returns true if the next token is the char specified. Doesn't increment the cursor.
Specified by:
nextTokenIs in interface TokenIterator

peekNext

public String peekNext()
Description copied from interface: TokenIterator
Peeks the next token w/o incrementing cursor.
Specified by:
peekNext in interface TokenIterator
Following copied from interface: org.translet.processor.TokenIterator
Throws:
NoSuchElementException - - if the iteration has no previous element.

next

public String next()
Description copied from interface: TokenIterator
Returns the value of the token.
Specified by:
next in interface TokenIterator

previous

public String previous()
Description copied from interface: TokenIterator
Returns the previous element in the list. This method may be called repeatedly to iterate through the list backwards, or intermixed with calls to next to go back and forth. (Note that alternating calls to next and previous will return the same element repeatedly.)
Specified by:
previous in interface TokenIterator
Following copied from interface: org.translet.processor.TokenIterator
Throws:
NoSuchElementException - - if the iteration has no previous element.

markForSnapshot

public void markForSnapshot()
Description copied from interface: TokenIterator
Marks the position to start recoding. Illegal to call markForSnapshot twice before calling createSnapshot(). This means, it is not possible to create overlapping snapshots. The tokens would include that would have been returned by next() (Optional operation).
Specified by:
markForSnapshot in interface TokenIterator

createSnapshot

public TokenIterator createSnapshot()
Description copied from interface: TokenIterator
Creates a snapshot since the time markForSnapshot was called including all the elements that was gotten using next(). Resets the mark.
Specified by:
createSnapshot in interface TokenIterator

hasPrevious

public boolean hasPrevious()
Description copied from interface: TokenIterator
Check if previous will return valid token.
Specified by:
hasPrevious in interface TokenIterator

rewind

public void rewind()
Description copied from interface: TokenIterator
Re-initializes the iterator. Will also reset any snapshot marks.
Specified by:
rewind in interface TokenIterator