Package org.eclipse.rdf4j.sail.base
Class SailClosingIteration<T,X extends Exception>
java.lang.Object
org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration<T,X>
org.eclipse.rdf4j.common.iteration.IterationWrapper<T,X>
org.eclipse.rdf4j.sail.base.SailClosingIteration<T,X>
- All Implemented Interfaces:
AutoCloseable
,CloseableIteration<T,
,X> Iteration<T,
X>
An
Iteration
that holds on to a SailClosable
until the Iteration is closed. Upon closing, the
underlying Iteration is closed before the lock is released. This iterator closes itself as soon as all elements have
been read.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final SailClosable[]
The lock to release when the Iteration is closed.Fields inherited from class org.eclipse.rdf4j.common.iteration.IterationWrapper
wrappedIter
-
Constructor Summary
ConstructorsConstructorDescriptionSailClosingIteration
(CloseableIteration<? extends T, X> iter, SailClosable... closes) Creates a newIteration
that automatically closes the givenSailClosable
s. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Closes this Iteration and also closes the wrapped Iteration if it is aCloseableIteration
.protected abstract void
Handler for exceptions generated by the closure of theSailClosable
array given to this object.boolean
hasNext()
Checks whether the wrapped Iteration contains more elements, closing this Iteration when this is not the case.static <E> SailClosingIteration
<E, SailException> makeClosable
(CloseableIteration<? extends E, SailException> iter, SailClosable... closes) Creates a newIteration
that automatically closes the givenSailClosable
s.next()
Returns the next element from the wrapped Iteration.void
remove()
Removes the last element that has been returned from the wrapped Iteration.Methods inherited from class org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration
close, isClosed
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.rdf4j.common.iteration.CloseableIteration
stream
-
Field Details
-
closes
The lock to release when the Iteration is closed.
-
-
Constructor Details
-
SailClosingIteration
Creates a newIteration
that automatically closes the givenSailClosable
s.- Parameters:
iter
- The underlying Iteration, must not be null.closes
- TheSailClosable
s toSailClosable.close()
when the itererator is closed.
-
-
Method Details
-
makeClosable
public static <E> SailClosingIteration<E,SailException> makeClosable(CloseableIteration<? extends E, SailException> iter, SailClosable... closes) Creates a newIteration
that automatically closes the givenSailClosable
s.- Parameters:
iter
- The underlying Iteration, must not be null.closes
- TheSailClosable
s toSailClosable.close()
when the itererator is closed.- Returns:
- a
CloseableIteration
that closes the givenSailClosable
-
hasNext
public boolean hasNext() throws XDescription copied from class:IterationWrapper
Checks whether the wrapped Iteration contains more elements, closing this Iteration when this is not the case. -
next
Description copied from class:IterationWrapper
Returns the next element from the wrapped Iteration. -
remove
public void remove() throws XDescription copied from class:IterationWrapper
Removes the last element that has been returned from the wrapped Iteration. -
handleClose
protected void handleClose() throws XDescription copied from class:IterationWrapper
Closes this Iteration and also closes the wrapped Iteration if it is aCloseableIteration
.- Overrides:
handleClose
in classIterationWrapper<T,
X extends Exception> - Throws:
X
-
handleSailException
Handler for exceptions generated by the closure of theSailClosable
array given to this object.
This method is called after all of theSailClosable
objects have had close called on them.- Parameters:
e
- TheSailException
to handle.- Throws:
X
- Instances of this generic-typed exception in response to the givenSailException
if the handler decides to propagate the exception.
-