org.entityfs.util.itr
Class DepthLastIteratorImpl

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

public class DepthLastIteratorImpl
extends AbstractIterator<T,U>

Standard implementation of DepthLastIterator for EntityView :s.

This class should have been named BreadthFirstIteratorImpl...

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
See Also:
DepthFirstIteratorImpl, LocationAwareDepthLastIteratorImpl
In_jar:
entityfs-util

Constructor Summary
DepthLastIteratorImpl(EntityListable dv, boolean returnThis)
          Create a new depth-last (breadth-first) iterator.
DepthLastIteratorImpl(EntityListable dv, Filter<? super EntityView> filter, boolean returnThis)
          Create a new depth-last (breadth-first) iterator.
 
Method Summary
protected  org.entityfs.util.itr.DepthLastIteratorContextImpl createChildIteratorContext(EntityView dv, org.entityfs.util.itr.DepthLastIteratorContextImpl parentContext)
           
protected  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

DepthLastIteratorImpl

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

DepthLastIteratorImpl

public DepthLastIteratorImpl(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 org.entityfs.util.itr.DepthLastIteratorContextImpl createChildIteratorContext(EntityView dv,
                                                                                        org.entityfs.util.itr.DepthLastIteratorContextImpl parentContext)
Specified by:
createChildIteratorContext in class AbstractIterator<org.entityfs.util.itr.DepthLastIteratorContextImpl,EntityView>

getObjectForRootDirectory

protected 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>