Interface ClosableIterator<T>

All Superinterfaces:
org.apache.jena.atlas.lib.Closeable, Iterator<T>, org.apache.jena.atlas.iterator.IteratorCloseable<T>
All Known Subinterfaces:
ExtendedIterator<T>, NodeIterator, NsIterator, ResIterator, StmtIterator, TripleIterator
All Known Implementing Classes:
ContNodeIteratorImpl, FilterIterator, IteratorOfJenaSets, LazyIterator, LPTopGoalIterator, Map1Iterator, MapFilterIterator, NiceIterator, NodeIteratorImpl, NsIteratorImpl, NullIterator, ObjectIterator, RandomOrderIterator, ResIteratorImpl, RoaringBitmapTripleIterator, SafeTripleIterator, SeqNodeIteratorImpl, SingletonIterator, SparseArrayIterator, StmtIteratorImpl, StoreTripleIterator, TrackingTripleIterator, WrappedIterator

public interface ClosableIterator<T> extends org.apache.jena.atlas.iterator.IteratorCloseable<T>
An iterator which should be closed after use. Some iterators take up resources which should be free'd as soon as possible, eg large structures which can be discarded early, or external resources such as database cursors.

Users of ClosableIterators (and thus of ExtendedIterator) should close the iterator if they are done with it before it is exhausted (i.e. hasNext() is still true). If they do not, resources may leak, be reclaimed unpredictably or much later than convenient. It is harmless to close the iterator once it has become exhausted and to call close multiple times.

Implementors are encouraged to dispose of resources as soon as is convenient.

  • Method Details

    • close

      void close()
      Close the iterator. Other operations on this iterator may now throw an exception. A ClosableIterator may be closed as many times as desired - the subsequent calls do nothing.
      Specified by:
      close in interface org.apache.jena.atlas.lib.Closeable