Class FilterIteration<E>
- java.lang.Object
-
- org.eclipse.rdf4j.common.iteration.FilterIteration<E>
-
- All Implemented Interfaces:
AutoCloseable
,Iterator<E>
,CloseableIteration<E>
- Direct Known Subclasses:
DistinctIteration
,FilteringIteration
,FilterIterator
,IntersectIteration
,MinusIteration
,OffsetIteration
,ReducedIteration
,SPARQLMinusIteration
public abstract class FilterIteration<E> extends Object implements CloseableIteration<E>
A CloseableIteration that wraps another Iteration, applying a filter on the objects that are returned. Subclasses must implement the accept method to indicate which objects should be returned.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
FilterIteration(CloseableIteration<? extends E> iter)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract boolean
accept(E object)
Tests whether or not the specified object should be returned by this Iteration.void
close()
CallshandleClose()
upon first call and makes sure the resource closures are only executed once.protected abstract void
handleClose()
Closes this Iteration and also closes the wrapped Iteration if it is aCloseableIteration
.boolean
hasNext()
E
next()
void
remove()
Removes the last element that has been returned from the wrapped Iteration.-
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
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Constructor Detail
-
FilterIteration
protected FilterIteration(CloseableIteration<? extends E> iter)
- Parameters:
iter
-
-
-
Method Detail
-
accept
protected abstract boolean accept(E object)
Tests whether or not the specified object should be returned by this Iteration. All objects from the wrapped Iteration pass through this method in the same order as they are coming from the wrapped Iteration.- Parameters:
object
- The object to be tested.- Returns:
- true if the object should be returned, false otherwise.
-
remove
public void remove()
Removes the last element that has been returned from the wrapped Iteration.- Specified by:
remove
in interfaceIterator<E>
- 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()
.
-
handleClose
protected abstract void handleClose()
Closes this Iteration and also closes the wrapped Iteration if it is aCloseableIteration
.
-
close
public final void close()
CallshandleClose()
upon first call and makes sure the resource closures are only executed once.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseableIteration<E>
-
-