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 Details

    • FilterIteration

      protected FilterIteration(CloseableIteration<? extends E> iter)
      Parameters:
      iter -
  • Method Details

    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<E>
    • next

      public E next()
      Specified by:
      next in interface Iterator<E>
    • 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 interface Iterator<E>
      Throws:
      UnsupportedOperationException - If the wrapped Iteration does not support the remove operation.
      IllegalStateException - if the Iteration has been closed, or if next() has not yet been called, or remove() has already been called after the last call to next().
    • handleClose

      protected abstract void handleClose()
      Closes this Iteration and also closes the wrapped Iteration if it is a CloseableIteration.
    • close

      public final void close()
      Calls handleClose() upon first call and makes sure the resource closures are only executed once.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface CloseableIteration<E>