Class IterableSequenceIterator<T extends Item>

java.lang.Object
net.sf.saxon.tree.jiter.IterableSequenceIterator<T>
Type Parameters:
T - The type of items returned. It is the caller's responsibility to ensure that the supplied SequenceIterator returns items of the correct type.
All Implemented Interfaces:
Iterable<T>, Iterator<T>

public class IterableSequenceIterator<T extends Item> extends Object implements Iterable<T>, Iterator<T>
Wraps a SequenceIterator in a Java iterable, allowing the convenience of processing the items in a Java for-each loop. The iterable can only be used once: it implements both Iterable<T> and Iterator<T>, and throws an exception if the iterator() method is called more than once.
  • Constructor Details

    • IterableSequenceIterator

      public IterableSequenceIterator(SequenceIterator in)
      Create a wrapping iterator
      Parameters:
      in - the input iterator
  • Method Details

    • iterator

      public Iterator<T> iterator()
      Returns an iterator over elements of type T.
      Specified by:
      iterator in interface Iterable<T extends Item>
      Returns:
      an Iterator.
    • hasNext

      public boolean hasNext()
      Returns true if the iteration has more elements.
      Specified by:
      hasNext in interface Iterator<T extends Item>
      Returns:
      true if the iteration has more elements
    • next

      public T next()
      Returns the next element in the iteration.
      Specified by:
      next in interface Iterator<T extends Item>
      Returns:
      the next element in the iteration