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 IterationWrapper
wrappedIter -
Constructor Summary
ConstructorsConstructorDescriptionSailClosingIteration(CloseableIteration<? extends T, X> iter, SailClosable... closes) Creates a newIterationthat automatically closes the givenSailClosables. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCloses this Iteration and also closes the wrapped Iteration if it is aCloseableIteration.protected abstract voidHandler for exceptions generated by the closure of theSailClosablearray given to this object.booleanhasNext()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 newIterationthat automatically closes the givenSailClosables.next()Returns the next element from the wrapped Iteration.voidremove()Removes the last element that has been returned from the wrapped Iteration.Methods inherited from class AbstractCloseableIteration
close, isClosedMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface CloseableIteration
stream
-
Field Details
-
closes
The lock to release when the Iteration is closed.
-
-
Constructor Details
-
SailClosingIteration
Creates a newIterationthat automatically closes the givenSailClosables.- Parameters:
iter- The underlying Iteration, must not be null.closes- TheSailClosables 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 newIterationthat automatically closes the givenSailClosables.- Parameters:
iter- The underlying Iteration, must not be null.closes- TheSailClosables toSailClosable.close()when the itererator is closed.- Returns:
- a
CloseableIterationthat closes the givenSailClosable
-
hasNext
public boolean hasNext() throws XDescription copied from class:IterationWrapperChecks whether the wrapped Iteration contains more elements, closing this Iteration when this is not the case. -
next
Description copied from class:IterationWrapperReturns the next element from the wrapped Iteration. -
remove
-
handleClose
protected void handleClose() throws XDescription copied from class:IterationWrapperCloses this Iteration and also closes the wrapped Iteration if it is aCloseableIteration.- Overrides:
handleClosein classIterationWrapper<T, X extends Exception>- Throws:
X
-
handleSailException
Handler for exceptions generated by the closure of theSailClosablearray given to this object.
This method is called after all of theSailClosableobjects have had close called on them.- Parameters:
e- TheSailExceptionto handle.- Throws:
X- Instances of this generic-typed exception in response to the givenSailExceptionif the handler decides to propagate the exception.
-