org.entityfs.util.itr
Class LocationAwareDepthFirstIteratorImpl

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

public class LocationAwareDepthFirstIteratorImpl
extends AbstractIterator<T,U>

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

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:
DepthFirstIteratorImpl, LocationAwareDepthLastIteratorImpl

Constructor Summary
LocationAwareDepthFirstIteratorImpl(EntityListable dv, boolean returnThis)
          Create a new depth-last (breadth-first) iterator.
LocationAwareDepthFirstIteratorImpl(EntityListable dv, Filter<? super EntityView> filter, boolean returnThis)
          Create a new depth-last (breadth-first) iterator.
 
Method Summary
protected  LocationAwareDepthFirstIteratorContextImpl createChildIteratorContext(EntityAndRelativeLocation<EntityView> earl, LocationAwareDepthFirstIteratorContextImpl 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

LocationAwareDepthFirstIteratorImpl

public LocationAwareDepthFirstIteratorImpl(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)?

LocationAwareDepthFirstIteratorImpl

public LocationAwareDepthFirstIteratorImpl(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 LocationAwareDepthFirstIteratorContextImpl createChildIteratorContext(EntityAndRelativeLocation<EntityView> earl,
                                                                                LocationAwareDepthFirstIteratorContextImpl parentContext)
Specified by:
createChildIteratorContext in class AbstractIterator<LocationAwareDepthFirstIteratorContextImpl,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 DepthFirstIteratorContext.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.DepthFirstIteratorContext<U>,U>