org.eclipse.rdf4j.common.iteration

## Interface CloseableIteration<E,X extends Exception>

- All Superinterfaces:
    AutoCloseable, Iteration<E,X>
  All Known Subinterfaces:
    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, 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 CloseableIteration<E,X extends Exception>
      extends Iteration<E,X>, AutoCloseable

  An `Iteration` that can be closed to free resources that it is holding. CloseableIterations automatically free their resources when exhausted. If not read until exhaustion or if you want to make sure the iteration is properly closed, any code using the iterator should be placed in a try-with-resources block, closing the iteration automatically, e.g.:

       try (CloseableIteration<Object, Exception> iter = ...) {
          // read objects from the iterator
       }
       catch(Exception e) {
         // process the exception that can be thrown while processing.
       }

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Closes this iteration, freeing any resources that it is holding.

    - ### Methods inherited from interface org.eclipse.rdf4j.common.iteration.Iteration

      `hasNext, next, remove, stream`

- - ### Method Detail

    - #### close

          void close()
              throws X extends Exception

      Closes this iteration, freeing any resources that it is holding. If the iteration has already been closed then invoking this method has no effect.
      Specified by:
        `close` in interface `AutoCloseable`
      Throws:
        `X extends Exception`

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