Package net.sf.saxon.s9api

## Class XdmSequenceIterator<T extends XdmItem>

- java.lang.Object
- - net.sf.saxon.s9api.XdmSequenceIterator<T>

- All Implemented Interfaces:
    `java.util.Iterator<T>`

      public class XdmSequenceIterator<T extends XdmItem>
      extends java.lang.Object
      implements java.util.Iterator<T>

  An iterator over an XPath sequence.

  This class implements the standard Java Iterator interface.

  Because the `Iterator` interface does not define any checked exceptions, the `hasNext()` method of this iterator throws an unchecked exception if a dynamic error occurs while evaluating the expression. Applications wishing to control error handling should take care to catch this exception.

- - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `protected` | `XdmSequenceIterator​(SequenceIterator base)` |
    `` | `XdmSequenceIterator​(UnfailingIterator base)` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `close()` | The close() method should be called to release resources if the caller wants to stop reading data before reaching the end.
    `boolean` | `hasNext()` | Returns `true` if the iteration has more elements.
    `T` | `next()` | Returns the next element in the iteration.
    `static XdmSequenceIterator<XdmAtomicValue>` | `ofAtomicValues​(UnfailingIterator base)` |
    `protected static XdmSequenceIterator<XdmNode>` | `ofNode​(XdmNode node)` |
    `static XdmSequenceIterator<XdmNode>` | `ofNodes​(AxisIterator base)` |
    `void` | `remove()` | Not supported on this implementation.
    `XdmStream<T>` | `stream()` | Convert this iterator to a Stream

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface java.util.Iterator

      `forEachRemaining`

- - ### Constructor Detail

    - #### XdmSequenceIterator

          protected XdmSequenceIterator​(SequenceIterator base)

    - #### XdmSequenceIterator

          public XdmSequenceIterator​(UnfailingIterator base)

  - ### Method Detail

    - #### ofNodes

          public static XdmSequenceIterator<XdmNode> ofNodes​(AxisIterator base)

    - #### ofAtomicValues

          public static XdmSequenceIterator<XdmAtomicValue> ofAtomicValues​(UnfailingIterator base)

    - #### ofNode

          protected static XdmSequenceIterator<XdmNode> ofNode​(XdmNode node)

    - #### hasNext

          public boolean hasNext()

      Returns `true` if the iteration has more elements. (In other words, returns `true` if `next` would return an element rather than throwing an exception.)
      Specified by:
        `hasNext` in interface `java.util.Iterator<T extends XdmItem>`
      Returns:
        `true` if the iterator has more elements.

    - #### next

          public T next()

      Returns the next element in the iteration. Calling this method repeatedly until the `hasNext()` method returns false will return each element in the underlying collection exactly once.
      Specified by:
        `next` in interface `java.util.Iterator<T extends XdmItem>`
      Returns:
        the next element in the iteration.
      Throws:
        `java.util.NoSuchElementException` - iteration has no more elements.

    - #### remove

          public void remove()

      Not supported on this implementation.
      Specified by:
        `remove` in interface `java.util.Iterator<T extends XdmItem>`
      Throws:
        `java.lang.UnsupportedOperationException` - always

    - #### close

          public void close()

      The close() method should be called to release resources if the caller wants to stop reading data before reaching the end. This is particularly relevant if the query uses saxon:stream() to read its input, since there will then be another thread supplying data, which will be left in suspended animation if no-one is consuming the data.
      Since:
        9.5.1.5 (see bug 2016)

    - #### stream

          public XdmStream<T> stream()

      Convert this iterator to a Stream
      Returns:
        a Stream delivering the same items as this iterator
      Since:
        9.9