Debian Codegraph @

net/sf/saxon/tree/iter/PrependSequenceIterator.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2018 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
8 package net.sf.saxon.tree.iter;
9
10 import net.sf.saxon.om.Item;
11 import net.sf.saxon.om.SequenceIterator;
12 import net.sf.saxon.trans.XPathException;
13
14 /**
15 * An iterator over nodes, that prepends a given node to the nodes
16 * returned by another iterator. Used to modify an iterator over axis A
17 * to one that iterates over A-OR-SELF.
18 */
19
20 public class PrependSequenceIterator<T extends Item<?>> implements SequenceIterator<T> {
21 T start;
22 SequenceIterator<T> base;
23
24 public PrependSequenceIterator(T start, SequenceIterator<T> base) {
25 this.start = start;
26 this.base = base;
27 }
28
29
30 /**
31 * Get the next item in the sequence.
32 * @return the next Item. If there are no more items, return null.
33 */
34
35 /*@Nullable*/
36 public T next() throws XPathException {
37 if (start != null) {
38 T temp = start;
39 start = null;
40 return temp;
41 } else {
42 return base.next();
43 }
44 }
45
46 public void close() {
47 base.close();
48 }
49
50 /**
51 * Get properties of this iterator, as a bit-significant integer.
52 *
53 * @return the properties of this iterator. This will be some combination of
54 * properties such as {@link #GROUNDED}, {@link #LAST_POSITION_FINDER},
55 * and {@link #LOOKAHEAD}. It is always
56 * acceptable to return the value zero, indicating that there are no known special properties.
57 * It is acceptable for the properties of the iterator to change depending on its state.
58 */
59
60 public int getProperties() {
61 return 0;
62 }
63
64
65 }
66