Package org.eclipse.rdf4j.sail.base
Class SailClosingIteration<T,X extends java.lang.Exception>
- java.lang.Object
-
- org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration<E,X>
-
- org.eclipse.rdf4j.common.iteration.IterationWrapper<T,X>
-
- org.eclipse.rdf4j.sail.base.SailClosingIteration<T,X>
-
- All Implemented Interfaces:
java.lang.AutoCloseable,CloseableIteration<T,X>,Iteration<T,X>
abstract class SailClosingIteration<T,X extends java.lang.Exception> extends IterationWrapper<T,X>
AnIterationthat holds on to aSailClosableuntil 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
Fields Modifier and Type Field Description private SailClosable[]closesThe lock to release when the Iteration is closed.-
Fields inherited from class org.eclipse.rdf4j.common.iteration.IterationWrapper
wrappedIter
-
-
Constructor Summary
Constructors Constructor Description SailClosingIteration(CloseableIteration<? extends T,X> iter, SailClosable... closes)Creates a newIterationthat automatically closes the givenSailClosables.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidhandleClose()Closes this Iteration and also closes the wrapped Iteration if it is aCloseableIteration.protected abstract voidhandleSailException(SailException e)Handler 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.Tnext()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 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 Detail
-
closes
private final SailClosable[] closes
The lock to release when the Iteration is closed.
-
-
Constructor Detail
-
SailClosingIteration
public SailClosingIteration(CloseableIteration<? extends T,X> 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.
-
-
Method Detail
-
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 X extends java.lang.ExceptionDescription copied from class:IterationWrapperChecks whether the wrapped Iteration contains more elements, closing this Iteration when this is not the case.
-
next
public T next() throws X extends java.lang.Exception
Description copied from class:IterationWrapperReturns the next element from the wrapped Iteration.
-
remove
public void remove() throws X extends java.lang.ExceptionDescription copied from class:IterationWrapperRemoves the last element that has been returned from the wrapped Iteration.
-
handleClose
protected void handleClose() throws X extends java.lang.ExceptionDescription copied from class:IterationWrapperCloses this Iteration and also closes the wrapped Iteration if it is aCloseableIteration.- Overrides:
handleClosein classIterationWrapper<T,X extends java.lang.Exception>- Throws:
XX extends java.lang.Exception
-
handleSailException
protected abstract void handleSailException(SailException e) throws X extends java.lang.Exception
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.X extends java.lang.Exception
-
-