Class TraversingIterator
- java.lang.Object
-
- org.codehaus.commons.compiler.util.iterator.TraversingIterator
-
- All Implemented Interfaces:
java.util.Iterator<java.lang.Object>
public class TraversingIterator extends java.lang.Object implements java.util.Iterator<java.lang.Object>AnIteratorthat iterates over a delegate, and while it encounters an array, aCollection, anEnumerationor aIteratorelement, it iterates over it recursively.Be aware that
hasNext()must read ahead one element.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Stack<java.util.Iterator<?>>nestprivate java.lang.ObjectnextElementprivate booleannextElementRead
-
Constructor Summary
Constructors Constructor Description TraversingIterator(java.util.Iterator<?> delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanhasNext()java.lang.Objectnext()private booleanreadNext()Reads the next element and stores it innextElement.voidremove()
-
-
-
Field Detail
-
nest
private final java.util.Stack<java.util.Iterator<?>> nest
-
nextElement
@Nullable private java.lang.Object nextElement
-
nextElementRead
private boolean nextElementRead
-
-
Method Detail
-
hasNext
public boolean hasNext()
- Specified by:
hasNextin interfacejava.util.Iterator<java.lang.Object>
-
next
public java.lang.Object next()
- Specified by:
nextin interfacejava.util.Iterator<java.lang.Object>
-
readNext
private boolean readNext()
Reads the next element and stores it innextElement.- Returns:
falseif no more element can be read
-
remove
public void remove()
- Specified by:
removein interfacejava.util.Iterator<java.lang.Object>- Throws:
java.lang.UnsupportedOperationException- TheIteratorcurrently being traversed doesn't support element removal- See Also:
Iterator.remove()
-
-