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>
AnIteration
that holds on to aSailClosable
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
Fields Modifier and Type Field Description private SailClosable[]
closes
The 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 newIteration
that automatically closes the givenSailClosable
s.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
handleClose()
Closes this Iteration and also closes the wrapped Iteration if it is aCloseableIteration
.protected abstract void
handleSailException(SailException e)
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.T
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 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 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 Detail
-
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 X extends java.lang.Exception
Description copied from class:IterationWrapper
Checks 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:IterationWrapper
Returns the next element from the wrapped Iteration.
-
remove
public void remove() throws X extends java.lang.Exception
Description copied from class:IterationWrapper
Removes the last element that has been returned from the wrapped Iteration.
-
handleClose
protected void handleClose() throws X extends java.lang.Exception
Description copied from class:IterationWrapper
Closes this Iteration and also closes the wrapped Iteration if it is aCloseableIteration
.- Overrides:
handleClose
in classIterationWrapper<T,X extends java.lang.Exception>
- Throws:
X
X 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 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.X extends java.lang.Exception
-
-