Support StringTemplate, ANTLR Project by making a donation! Terence often pays for things like the antlr.org server, conference travel, and this site design (that alone cost US$1000). Buy him a beer and pizza remotely ;)
|
StripIterator
org.antlr.stringtemplate.language
Class StripIterator
java.lang.Object
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. |
|
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 |
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.
StripIterator
public StripIterator(java.util.Iterator it)
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
|