org.entityfs.util.itr
Class LocationAwareDepthLastIteratorImpl

java.lang.Object
  extended by org.entityfs.util.itr.AbstractIterator<T,U>
      extended by org.entityfs.util.itr.LocationAwareDepthLastIteratorImpl
All Implemented Interfaces:
Iterator<EntityAndRelativeLocation<EntityView>>, DepthLastIterator<EntityAndRelativeLocation<EntityView>>

public class LocationAwareDepthLastIteratorImpl
extends AbstractIterator<T,U>

This is an implementation of DepthLastIterator that returns EntityAndRelativeLocation objects. The location of the returned objects is the relative location of the entity to the root directory of the iteration.

This class should perhaps have been named LocationAwareBreadthFirstIteratorImpl...

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

Since:
1.1
Author:
Karl Gustafsson
See Also:
DepthLastIteratorImpl, LocationAwareDepthFirstIteratorImpl

Constructor Summary
LocationAwareDepthLastIteratorImpl(EntityListable dv, boolean returnThis)
          Create a new depth-last (breadth-first) iterator.
LocationAwareDepthLastIteratorImpl(EntityListable dv, Filter<? super EntityView> filter, boolean returnThis)
          Create a new depth-last (breadth-first) iterator.
 
Method Summary
protected  LocationAwareDepthLastIteratorContextImpl createChildIteratorContext(EntityAndRelativeLocation<EntityView> earl, LocationAwareDepthLastIteratorContextImpl parentContext)
           
protected  EntityAndRelativeLocation<EntityView> getObjectForRootDirectory(DirectoryView rootDirectory)
          Get an object to return from the iterator for the root directory of the recursive iteration.
protected  boolean testAndSetNext()
           
 
Methods inherited from class org.entityfs.util.itr.AbstractIterator
getContextStack, getFilter, hasNext, next, remove, setNext, testAndSetNextChildEntity, testAndSetNextSubdirectory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Iterator
hasNext, next, remove
 

Constructor Detail

LocationAwareDepthLastIteratorImpl

public LocationAwareDepthLastIteratorImpl(EntityListable dv,
                                          Filter<? super EntityView> filter,
                                          boolean returnThis)
Create a new depth-last (breadth-first) iterator. Only the entities passing the filter will be returned from the iterator.

Parameters:
dv - The start directory for the iterator. If returnThis is true, this argument must be a DirectoryView (such as a Directory.
filter - The filter that entities must pass to be returned from the iterator. The iterator will not visit subdirectories that do not pass this filter.
returnThis - Should the starting directory be returned as the first entity from the iterator (if it passes the filter)?

LocationAwareDepthLastIteratorImpl

public LocationAwareDepthLastIteratorImpl(EntityListable dv,
                                          boolean returnThis)
Create a new depth-last (breadth-first) iterator.

Parameters:
dv - The start directory for the iterator. If returnThis is true, this argument must be a DirectoryView (such as a Directory.
returnThis - Should the starting directory be returned as the first entity from the iterator?
Method Detail

createChildIteratorContext

protected LocationAwareDepthLastIteratorContextImpl createChildIteratorContext(EntityAndRelativeLocation<EntityView> earl,
                                                                               LocationAwareDepthLastIteratorContextImpl parentContext)
Specified by:
createChildIteratorContext in class AbstractIterator<LocationAwareDepthLastIteratorContextImpl,EntityAndRelativeLocation<EntityView>>

getObjectForRootDirectory

protected EntityAndRelativeLocation<EntityView> getObjectForRootDirectory(DirectoryView rootDirectory)
Get an object to return from the iterator for the root directory of the recursive iteration. This is only called if DepthLastIteratorContext.testAndClearShouldReturnThis() returns true for the current context.

Parameters:
rootDirectory - The root directory of the iteration.

testAndSetNext

protected final boolean testAndSetNext()
Specified by:
testAndSetNext in class AbstractIterator<T extends org.entityfs.util.itr.DepthLastIteratorContext<U>,U>