org.eclipse.rdf4j.common.iteration

## Interface Iteration<E,X extends Exception>

- Type Parameters:
    `E` - Object type of objects contained in the iteration.
    `X` - Exception type that is thrown when a problem occurs during iteration.
  All Known Subinterfaces:
    CloseableIteration<E,X>, GraphQueryResult, QueryResult<T>, TupleQueryResult
  All Known Implementing Classes:
    AbstractCloseableIteration, AbstractParserQuery.QueryInterruptIteration, AbstractParserQuery.QueryInterruptIteration, AlternativeCursor, BackgroundGraphResult, BackgroundGraphResult, BackgroundTupleResult, BackgroundTupleResult, BadlyDesignedLeftJoinIterator, BottomUpJoinIterator, BoundJoinConversionIteration, BoundJoinVALUESConversionIteration, CloseableIterationBase, CloseableIteratorIteration, CloseablePeakableIteration, CloseDependentConnectionIteration, CollectionIteration, CollectionIteration, CompatibleBindingSetFilter, ConsumingIteration, ControlledWorkerBoundJoin, ControlledWorkerJoin, ControlledWorkerLeftJoin, ControlledWorkerUnion, ConvertingIteration, CrossProductIteration, DelayedIteration, DescribeIteration, DistinctIteration, DistinctModelReducingUnionIteration, EmptyIteration, ExceptionConvertingIteration, ExtensionIterator, FedXQueueCursor, FilterCursor, FilteringInsertBindingsIteration, FilteringIteration, FilteringIteration, FilterIteration, FilterIterator, GraphQueryResultImpl, GraphToBindingSetConversionIteration, GroupedCheckConversionIteration, GroupIterator, HashJoin, HashJoinIteration, IndependentJoingroupBindingsIteration, IndependentJoingroupBindingsIteration2, IndependentJoingroupBindingsIteration3, InsertBindingSetCursor, InsertBindingSetCursor, InsertBindingsIteration, IntersectIteration, IteratingGraphQueryResult, IteratingTupleQueryResult, IterationWrapper, IteratorCloseableIteration, IteratorIteration, JoinExecutorBase, JoinExecutorBase, JoinExecutorBase, JoinIterator, LazyMutableClosableIteration, LeftJoinIterator, LimitedSizeBottomUpJoinIterator, LimitedSizeDistinctIteration, LimitedSizeHashJoinIteration, LimitedSizeIntersectIteration, LimitedSizeOrderIteration, LimitedSizePathIterator, LimitedSizeSPARQLMinusIteration, LimitedSizeZeroLengthPathIteration, LimitIteration, LockingIteration, LookAheadIteration, MemStatementIterator, MinusIteration, MultiProjectionIterator, MutableTupleQueryResult, OffsetIteration, OrderIterator, ParallelExecutorBase, ParallelJoinCursor, ParallelLeftJoinCursor, ParallelServiceExecutor, PathIteration, PrintingIteration, ProjectionIterator, QueryContextIteration, QueryResultIteration, QueueCursor, QueueCursor, QueueCursor, QueueCursor, QueueIteration, ReducedIteration, RepositoryExceptionConvertingIteration, RepositoryResult, ServiceCrossProductIteration, ServiceJoinConversionIteration, ServiceJoinConversionIteration, ServiceJoinIterator, SilentIteration, SilentIteration, SilentIteration, SingleBindingSetIteration, SingletonIteration, SPARQLCrossProductIteration, SPARQLMinusIteration, StatementConversionIteration, StopRemainingExecutionsOnCloseIteration, SynchronousBoundJoin, SynchronousJoin, SynchronousWorkerUnion, TimeLimitIteration, TupleQueryResultImpl, UnionExecutorBase, UnionIteration, WorkerUnionBase, ZeroLengthPathIteration

      public interface Iteration<E,X extends Exception>

  An Iteration is a typed Iterator-like object that can throw (typed) Exceptions while iterating. This is used in cases where the iteration is lazy and evaluates over a (remote) connection, for example accessing a database. In such cases an error can occur at any time and needs to be communicated through a checked exception, something `Iterator` can not do (it can only throw `RuntimeException`s.
  Author:
    jeen, Herko ter Horst
  See Also:
    `Iterator`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `hasNext()` Returns `true` if the iteration has more elements.
    `E` | `next()` Returns the next element in the iteration.
    `void` | `remove()` Removes from the underlying collection the last element returned by the iteration (optional operation).
    `default java.util.stream.Stream<E>` | `stream()` Convert the results to a Java 8 Stream.

- - ### Method Detail

    - #### hasNext

          boolean hasNext()
                   throws X extends Exception

      Returns `true` if the iteration has more elements. (In other words, returns `true` if `next()` would return an element rather than throwing a `NoSuchElementException`.)
      Returns:
        `true` if the iteration has more elements.
      Throws:
        `X`
        `X extends Exception`

    - #### next

          E next()
          throws X extends Exception

      Returns the next element in the iteration.
      Returns:
        the next element in the iteration.
      Throws:
        `NoSuchElementException` - if the iteration has no more elements or if it has been closed.
        `X extends Exception`

    - #### remove

          void remove()
               throws X extends Exception

      Removes from the underlying collection the last element returned by the iteration (optional operation). This method can be called only once per call to next.
      Throws:
        `UnsupportedOperationException` - if the remove operation is not supported by this Iteration.
        `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()`.
        `X extends Exception`

    - #### stream

          default java.util.stream.Stream<E> stream()

      Convert the results to a Java 8 Stream. If this iteration implements CloseableIteration it should be closed (by calling Stream#close() or using try-with-resource) if it is not fully consumed.
      Returns:
        stream

Copyright © 2015-2021 Eclipse Foundation. All Rights Reserved.