Class ConvertingIteration<S,T>

java.lang.Object
org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration<T>
org.eclipse.rdf4j.common.iteration.ConvertingIteration<S,T>
All Implemented Interfaces:
AutoCloseable, Iterator<T>, CloseableIteration<T>
Direct Known Subclasses:
BoundJoinConversionIteration, BoundJoinVALUESConversionIteration, ExtensionIterator, GroupedCheckConversionIteration, InsertBindingsIteration, ProjectionIterator, ServiceJoinConversionIteration

public abstract class ConvertingIteration<S,T> extends AbstractCloseableIteration<T>
A CloseableIteration that converts an iteration over objects of type S (the source type) to an iteration over objects of type T (the target type).
  • Constructor Details

    • ConvertingIteration

      protected ConvertingIteration(CloseableIteration<? extends S> iter)
      Creates a new ConvertingIteration that operates on the supplied source type iteration.
      Parameters:
      iter - The source type iteration for this ConvertingIteration, must not be null.
  • Method Details

    • convert

      protected abstract T convert(S sourceObject)
      Converts a source type object to a target type object.
    • hasNext

      public final boolean hasNext()
      Checks whether the source type iteration contains more elements.
      Returns:
      true if the source type iteration contains more elements, false otherwise.
    • next

      public final T next()
      Returns the next element from the source type iteration.
      Throws:
      NoSuchElementException - If all elements have been returned.
      IllegalStateException - If the iteration has been closed.
    • remove

      public final void 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 if next() has not yet been called, or remove() has already been called after the last call to next().
    • handleClose

      protected void handleClose()
      Closes this iteration as well as the wrapped iteration if it is a CloseableIteration.
      Specified by:
      handleClose in class AbstractCloseableIteration<T>