org.eclipse.rdf4j.common.iteration

## Class AbstractCloseableIteration<E,X extends Exception>

- java.lang.Object
- - org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration<E,X>

- All Implemented Interfaces:
    AutoCloseable, CloseableIteration<E,X>, Iteration<E,X>
  Direct Known Subclasses:
    CloseableIterationBase, CloseableIteratorIteration, CloseDependentConnectionIteration, CollectionIteration, ConvertingIteration, DelayedIteration, EmptyIteration, ExceptionConvertingIteration, GraphToBindingSetConversionIteration, IterationWrapper, LookAheadIteration, PrintingIteration, QueryContextIteration, QueryResultIteration, RepositoryResult, SingleBindingSetIteration, SingletonIteration, StatementConversionIteration, StopRemainingExecutionsOnCloseIteration

      public abstract class AbstractCloseableIteration<E,X extends Exception>
      extends Object
      implements CloseableIteration<E,X>

  Base class for `CloseableIteration`s offering common functionality. This class keeps track of whether the iteration has been closed and handles multiple calls to `close()` by ignoring all but the first call.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractCloseableIteration()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Calls `handleClose()` upon first call and makes sure the resource closures are only executed once.
    `protected void` | `handleClose()` Called by `close()` when it is called for the first time.
    `boolean` | `isClosed()` Checks whether this CloseableIteration has been closed.

    - ### 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.Iteration

      `hasNext, next, remove, stream`

- - ### Constructor Detail

    - #### AbstractCloseableIteration

          public AbstractCloseableIteration()

  - ### Method Detail

    - #### isClosed

          public final boolean isClosed()

      Checks whether this CloseableIteration has been closed.
      Returns:
        `true` if the CloseableIteration has been closed, `false` otherwise.

    - #### close

          public final void close()
                           throws X extends Exception

      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,X extends Exception>`
      Throws:
        `X extends Exception`

    - #### handleClose

          protected void handleClose()
                              throws X extends Exception

      Called by `close()` when it is called for the first time. This method is only called once on each iteration. By default, this method does nothing.
      Throws:
        `X`
        `X extends Exception`

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