Interface SequenceIterator

    • Method Detail

      • next

        Item next()
           throws XPathException
        Get the next item in the sequence. This method changes the state of the iterator.
        the next item, or null if there are no more items. Once a call on next() has returned null, no further calls should be made. The preferred action for an iterator if subsequent calls on next() are made is to return null again, and all implementations within Saxon follow this rule.
        XPathException - if an error occurs retrieving the next item
      • close

        default void close()
        Close the iterator. This indicates to the supplier of the data that the client does not require any more items to be delivered by the iterator. This may enable the supplier to release resources. After calling close(), no further calls on the iterator should be made; if further calls are made, the effect of such calls is undefined.

        For example, the iterator returned by the unparsed-text-lines() function has a close() method that causes the underlying input stream to be closed, whether or not the file has been read to completion.

        Closing an iterator is important when the data is being "pushed" in another thread. Closing the iterator terminates that thread and means that it needs to do no additional work. Indeed, failing to close the iterator may cause the push thread to hang waiting for the buffer to be emptied.

        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface
        9.1. Default implementation added in 9.9.
      • forEachOrFail

        default void forEachOrFail​(ItemConsumer<? super Item> consumer)
                            throws XPathException
        Process all the remaining items delivered by the SequenceIterator using a supplied consumer function.
        consumer - the supplied consumer function
        XPathException - if either (a) an error occurs obtaining an item from the input sequence, or (b) the consumer throws an exception.
      • materialize

        default GroundedValue materialize()
                                   throws XPathException
        Create a GroundedValue (a sequence materialized in memory) containing all the values delivered by this SequenceIterator. The method must only be used when the SequenceIterator is positioned at the start. If it is not positioned at the start, then it is implementation-dependant whether the returned sequence contains all the nodes delivered by the SequenceIterator from the beginning, or only those delivered starting at the current position.

        It is implementation-dependant whether this method consumes the SequenceIterator. (More specifically, in the current implementation: if the iterator is backed by a GroundedValue, then that value is returned and the iterator is not consumed; otherwise, the iterator is consumed and the method returns the remaining items after the current position only).

        a sequence containing all the items delivered by this SequenceIterator.
        XPathException - if reading the SequenceIterator throws an error