Class ExceptionConvertingIteration<E,X extends Exception>
java.lang.Object
org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration<E,X>
org.eclipse.rdf4j.common.iteration.ExceptionConvertingIteration<E,X>
- All Implemented Interfaces:
AutoCloseable
,CloseableIteration<E,X>
,Iteration<E,X>
- Direct Known Subclasses:
RepositoryExceptionConvertingIteration
public abstract class ExceptionConvertingIteration<E,X extends Exception>
extends AbstractCloseableIteration<E,X>
A CloseableIteration that converts an arbitrary iteration to an iteration with exceptions of type X.
Subclasses need to override
convert(Exception)
to do the conversion.-
Constructor Summary
ModifierConstructorDescriptionprotected
ExceptionConvertingIteration(Iteration<? extends E,? extends Exception> iter)
Creates a new ExceptionConvertingIteration that operates on the supplied iteration. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract X
Converts an exception from the underlying iteration to an exception of type X.protected void
Closes this Iteration as well as the wrapped Iteration if it happens to be aCloseableIteration
.boolean
hasNext()
Checks whether the underlying Iteration contains more elements.next()
Returns the next element from the wrapped Iteration.void
remove()
Calls remove() on the underlying Iteration.Methods inherited from class org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration
close, isClosed
-
Constructor Details
-
ExceptionConvertingIteration
Creates a new ExceptionConvertingIteration that operates on the supplied iteration.- Parameters:
iter
- The Iteration that this ExceptionConvertingIteration operates on, must not be null.
-
-
Method Details
-
convert
Converts an exception from the underlying iteration to an exception of type X. -
hasNext
Checks whether the underlying Iteration contains more elements.- Returns:
- true if the underlying Iteration contains more elements, false otherwise.
- Throws:
X
-
next
Returns the next element from the wrapped Iteration.- Returns:
- the next element in the iteration.
- Throws:
X
NoSuchElementException
- If all elements have been returned.IllegalStateException
- If the Iteration has been closed.
-
remove
Calls remove() on the underlying Iteration.- Throws:
UnsupportedOperationException
- If the wrapped Iteration does not support the remove operation.IllegalStateException
- If the Iteration has been closed, or ifnext()
has not yet been called, orremove()
has already been called after the last call tonext()
.X extends Exception
-
handleClose
Closes this Iteration as well as the wrapped Iteration if it happens to be aCloseableIteration
.- Overrides:
handleClose
in classAbstractCloseableIteration<E,X extends Exception>
- Throws:
X
-