Project

Profile

Help

Revision e90fc9e5

Added by Michael Kay over 1 year ago

Further fixes for bug #4750

View differences:

latest10/hej/net/sf/saxon/s9api/XdmSequenceIterator.java
7 7

  
8 8
package net.sf.saxon.s9api;
9 9

  
10
import net.sf.saxon.om.Item;
10 11
import net.sf.saxon.om.SequenceIterator;
11 12
import net.sf.saxon.s9api.streams.XdmStream;
12 13
import net.sf.saxon.trans.XPathException;
13
import net.sf.saxon.tree.iter.AxisIterator;
14
import net.sf.saxon.tree.iter.LookaheadIterator;
15
import net.sf.saxon.tree.iter.LookaheadIteratorImpl;
16
import net.sf.saxon.tree.iter.SingletonIterator;
17
import net.sf.saxon.tree.iter.UnfailingIterator;
14
import net.sf.saxon.tree.iter.*;
18 15

  
19 16
import java.util.Iterator;
17
import java.util.NoSuchElementException;
20 18
import java.util.Spliterator;
21 19
import java.util.Spliterators;
22 20
import java.util.stream.Stream;
......
67 65
     * rather than throwing an exception.)
68 66
     *
69 67
     * @return <tt>true</tt> if the iterator has more elements.
70
     * @throws SaxonApiUncheckedException if a dynamic error occurs during XPath evaluation that
71
     *                                    is detected at this point.
72 68
     */
73 69
    @Override
74
    public boolean hasNext() throws SaxonApiUncheckedException {
70
    public boolean hasNext() {
75 71
        return base.hasNext();
76 72
    }
77 73

  
......
81 77
     * return each element in the underlying collection exactly once.
82 78
     *
83 79
     * @return the next element in the iteration.
84
     * @throws java.util.NoSuchElementException
85
     *          iteration has no more elements.
80
     * @throws java.util.NoSuchElementException iteration has no more elements.
86 81
     */
87 82
    @Override
88 83
    public T next() {
89 84
        try {
90
            //noinspection unchecked
91
            return (T) XdmItem.wrapItem(base.next());
85
            Item it = base.next();
86
            if (it == null) {
87
                throw new NoSuchElementException();
88
            } else {
89
                return (T) XdmItem.wrapItem(it);
90
            }
92 91
        } catch (XPathException xe) {
93
            // I don't believe this is actually possible in this case
94 92
            throw new SaxonApiUncheckedException(xe);
95 93
        }
96 94
    }
......
111 109
     * data before reaching the end. This is particularly relevant if the query uses saxon:stream()
112 110
     * to read its input, since there will then be another thread supplying data, which will be left
113 111
     * in suspended animation if no-one is consuming the data.
112
     *
114 113
     * @since 9.5.1.5 (see bug 2016)
115 114
     */
116 115

  

Also available in: Unified diff