org.antlr.stringtemplate.language
Class StripIterator

java.lang.Object
  extended by org.antlr.stringtemplate.language.StripIterator
All Implemented Interfaces:
java.util.Iterator

public class StripIterator
extends java.lang.Object
implements java.util.Iterator

Given an iterator, return only the non-null elements via next().


Field Summary
protected  java.util.Iterator it
           
protected  java.lang.Object lookahead
          To know if stripped iterator hasNext(), we need to see if there is another non-null element or not.
 
Constructor Summary
StripIterator(java.util.Iterator it)
           
 
Method Summary
protected  void consume()
          Set lookahead to next non-null element or null if nothing left
 boolean hasNext()
          Either the list has more stuff or our lookahead has last element
 java.lang.Object next()
           
 void remove()
           
 java.lang.String toString()
          The result of asking for the string of an iterator is the list of elements and so this is just the list w/o nulls.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

it

protected java.util.Iterator it

lookahead

protected java.lang.Object lookahead
To know if stripped iterator hasNext(), we need to see if there is another non-null element or not.

Constructor Detail

StripIterator

public StripIterator(java.util.Iterator it)
Method Detail

consume

protected void consume()
Set lookahead to next non-null element or null if nothing left


hasNext

public boolean hasNext()
Either the list has more stuff or our lookahead has last element

Specified by:
hasNext in interface java.util.Iterator

next

public java.lang.Object next()
Specified by:
next in interface java.util.Iterator

remove

public void remove()
Specified by:
remove in interface java.util.Iterator

toString

public java.lang.String toString()
The result of asking for the string of an iterator is the list of elements and so this is just the list w/o nulls. This is destructive in that the iterator cursors have moved to the end after printing.

Overrides:
toString in class java.lang.Object


Copyright ? 2006-2009 Terence Parr