info.aduna.collections.iterators
Class DelayedIterator<E>

java.lang.Object
  extended by info.aduna.iteration.CloseableIterationBase<E,X>
      extended by info.aduna.iteration.DelayedIteration<E,RuntimeException>
          extended by info.aduna.collections.iterators.DelayedIterator<E>
All Implemented Interfaces:
CloseableIterator<E>, CloseableIteration<E,RuntimeException>, Iteration<E,RuntimeException>, Closeable, Iterator<E>

public abstract class DelayedIterator<E>
extends DelayedIteration<E,RuntimeException>
implements CloseableIterator<E>

An iterator that delays the creation of the underlying iterator until it is being accessed. This is mainly useful for situations where iterator creation adds considerable overhead but where the iterator may not actually be used, or where a created iterator consumes scarce resources like JDBC-connections or memory. Subclasses must implement the createIterator method, which is called once when the iterator is first needed.


Field Summary
 
Fields inherited from class info.aduna.iteration.CloseableIterationBase
logger
 
Constructor Summary
DelayedIterator()
           
 
Method Summary
protected  Iteration<? extends E,RuntimeException> createIteration()
          Creates the iteration that should be iterated over.
protected abstract  Iterator<? extends E> createIterator()
          Creates the iterator that should be iterated over.
 
Methods inherited from class info.aduna.iteration.DelayedIteration
handleClose, hasNext, next, remove
 
Methods inherited from class info.aduna.iteration.CloseableIterationBase
close, isClosed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface info.aduna.collections.iterators.CloseableIterator
close
 
Methods inherited from interface java.util.Iterator
hasNext, next, remove
 

Constructor Detail

DelayedIterator

public DelayedIterator()
Method Detail

createIteration

protected final Iteration<? extends E,RuntimeException> createIteration()
                                                                 throws RuntimeException
Description copied from class: DelayedIteration
Creates the iteration that should be iterated over. This method is called only once, when the iteration is first needed.

Specified by:
createIteration in class DelayedIteration<E,RuntimeException>
Throws:
RuntimeException

createIterator

protected abstract Iterator<? extends E> createIterator()
Creates the iterator that should be iterated over. This method is called only once, when the iterator is first needed.



Copyright © 1997-2008 Aduna. All Rights Reserved.