org.entityfs.util.itr
Class AbstractIterator<T extends org.entityfs.util.itr.IteratorContext<U>,U>

java.lang.Object
  extended by org.entityfs.util.itr.AbstractIterator<T,U>
All Implemented Interfaces:
Iterator<U>
Direct Known Subclasses:
DepthFirstIteratorImpl, DepthLastIteratorImpl, LocationAwareDepthFirstIteratorImpl, LocationAwareDepthLastIteratorImpl

public abstract class AbstractIterator<T extends org.entityfs.util.itr.IteratorContext<U>,U>
extends Object
implements Iterator<U>

This is an abstract class that can be inherited by EntityView iterator implementations. It implements a recursive iterator that can be configured to do the following things:

Subclasses implement the createChildIteratorContext(Object, IteratorContext) to create child directory iterators.

EntityFS iterators are not thread safe. Don't use them concurrently from several threads without synchronizing access to them.

Since:
1.0
Author:
Karl Gustafsson

Constructor Summary
protected AbstractIterator(Filter<? super EntityView> f, T firstOnStack)
           
 
Method Summary
protected abstract  T createChildIteratorContext(U dv, T parentContext)
           
protected  LinkedList<T> getContextStack()
           
protected  Filter<? super EntityView> getFilter()
           
 boolean hasNext()
           
 U next()
           
 void remove()
           
protected  void setNext(U ev)
           
protected abstract  boolean testAndSetNext()
           
protected  boolean testAndSetNextChildEntity(T curContext)
           
protected  boolean testAndSetNextSubdirectory(T curContext)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractIterator

protected AbstractIterator(Filter<? super EntityView> f,
                           T firstOnStack)
Method Detail

getContextStack

protected LinkedList<T> getContextStack()

getFilter

protected Filter<? super EntityView> getFilter()

setNext

protected void setNext(U ev)

createChildIteratorContext

protected abstract T createChildIteratorContext(U dv,
                                                T parentContext)

testAndSetNextSubdirectory

protected boolean testAndSetNextSubdirectory(T curContext)

testAndSetNextChildEntity

protected boolean testAndSetNextChildEntity(T curContext)

testAndSetNext

protected abstract boolean testAndSetNext()

next

public U next()
Specified by:
next in interface Iterator<U>

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<U>

remove

public void remove()
            throws UnsupportedOperationException
Specified by:
remove in interface Iterator<U>
Throws:
UnsupportedOperationException - Always.