Class DelayedIteration<E,X extends Exception>
java.lang.Object
org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration<E,X>
org.eclipse.rdf4j.common.iteration.DelayedIteration<E,X>
- All Implemented Interfaces:
AutoCloseable
,CloseableIteration<E,
,X> Iteration<E,
X>
- Direct Known Subclasses:
OrderIterator
,QueryEvaluationStep.DelayedEvaluationIteration
public abstract class DelayedIteration<E,X extends Exception>
extends AbstractCloseableIteration<E,X>
An iteration that delays the creation of the underlying iteration until it is being accessed. This is mainly useful
for situations where iteration creation adds considerable overhead but where the iteration may not actually be used,
or where a created iteration consumes scarce resources like JDBC-connections or memory. Subclasses must implement the
createIteration method, which is called once when the iteration is first needed.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionCreates the iteration that should be iterated over.protected void
Closes this iteration as well as the underlying iteration if it has already been created and happens to be aCloseableIteration
.boolean
hasNext()
Calls the hasNext method of the underlying iteration.next()
Calls the next method of the underlying iteration.void
remove()
Calls the remove method of the underlying iteration.Methods inherited from class org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration
close, isClosed
-
Constructor Details
-
DelayedIteration
protected DelayedIteration()Creates a new DelayedIteration.
-
-
Method Details
-
createIteration
Creates the iteration that should be iterated over. This method is called only once, when the iteration is first needed. -
hasNext
Calls the hasNext method of the underlying iteration.- Returns:
- true if the iteration has more elements.
- Throws:
X
-
next
Calls the next method of the underlying iteration. -
remove
Calls the remove method of the underlying iteration. -
handleClose
Closes this iteration as well as the underlying iteration if it has already been created and happens to be aCloseableIteration
.- Overrides:
handleClose
in classAbstractCloseableIteration<E,
X extends Exception> - Throws:
X
-