public class TraversingIterator
extends java.lang.Object
implements java.util.Iterator
Iterator that iterates over a delegate, and while it encounters an array, a Collection, an Enumeration or a Iterator element, it iterates over it
recursively.
Be aware that hasNext() must read ahead one element.
| Modifier and Type | Field and Description |
|---|---|
private java.util.Stack |
nest |
private java.lang.Object |
nextElement |
private boolean |
nextElementRead |
| Constructor and Description |
|---|
TraversingIterator(java.util.Iterator delegate) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
hasNext() |
java.lang.Object |
next() |
private boolean |
readNext()
Reads the next element and stores it in
nextElement. |
void |
remove() |
private final java.util.Stack nest
private java.lang.Object nextElement
private boolean nextElementRead
public boolean hasNext()
hasNext in interface java.util.Iteratorpublic java.lang.Object next()
next in interface java.util.Iteratorprivate boolean readNext()
nextElement.false if no more element can be read.public void remove()
remove in interface java.util.Iteratorjava.lang.UnsupportedOperationException - iff the Iterator currently being
traversed doesn't support element removalIterator.remove()