Class WrappedIterator<T>

java.lang.Object
org.apache.jena.util.iterator.NiceIterator<T>
org.apache.jena.util.iterator.WrappedIterator<T>
All Implemented Interfaces:
Iterator<T>, org.apache.jena.atlas.iterator.IteratorCloseable<T>, org.apache.jena.atlas.lib.Closeable, ClosableIterator<T>, ExtendedIterator<T>
Direct Known Subclasses:
FilterIterator, NodeIteratorImpl, NsIteratorImpl, RandomOrderIterator, ResIteratorImpl, StmtIteratorImpl, TrackingTripleIterator

public class WrappedIterator<T> extends NiceIterator<T>
a WrappedIterator is an ExtendedIterator wrapping around a plain (or presented as plain) Iterator. The wrapping allows the usual extended operations (filtering, concatenating) to be done on an Iterator derived from some other source.
  • Method Details

    • create

      public static <T> ExtendedIterator<T> create(Iterator<T> it)
      Answer an ExtendedIterator returning the elements of it. If it is itself an ExtendedIterator, return that; otherwise wrap it.
    • createNoRemove

      public static <T> WrappedIterator<T> createNoRemove(Iterator<T> it)
      Answer an ExtendedIterator wrapped round it which does not permit .remove() even if it does.
    • ofStream

      public static <T> WrappedIterator<T> ofStream(Stream<T> stream)
      Answer an ExtendedIterator wrapped round a Stream. The extended iterator does not permit .remove().

      The stream should not be used directly. The effect of doing so is undefined.

    • createIteratorIterator

      public static <T> ExtendedIterator<T> createIteratorIterator(Iterator<Iterator<T>> it)
      Given an Iterator that returns Iterator's, this creates an Iterator over the next level values. Similar to list splicing in lisp.
    • forTestingOnly_getBase

      public Iterator<? extends T> forTestingOnly_getBase()
    • hasNext

      public boolean hasNext()
      hasNext: defer to the base iterator
      Specified by:
      hasNext in interface Iterator<T>
      Overrides:
      hasNext in class NiceIterator<T>
    • next

      public T next()
      next: defer to the base iterator
      Specified by:
      next in interface Iterator<T>
      Overrides:
      next in class NiceIterator<T>
    • forEachRemaining

      public void forEachRemaining(Consumer<? super T> action)
      forEachRemaining: defer to the base iterator
    • remove

      public void remove()
      Description copied from class: NiceIterator
      default remove: we have no elements, so we can't remove any.
      Specified by:
      remove in interface Iterator<T>
      Overrides:
      remove in class NiceIterator<T>
    • close

      public void close()
      close: defer to the base, iff it is closable
      Specified by:
      close in interface ClosableIterator<T>
      Specified by:
      close in interface org.apache.jena.atlas.lib.Closeable
      Overrides:
      close in class NiceIterator<T>
    • close

      public static void close(Iterator<?> it)
      if it is a Closableiterator, close it. Abstracts away from tests [that were] scattered through the code.