Debian Codegraph @

net/sf/saxon/expr/EveryItemMappingIterator.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.expr;
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 * EveryItemMappingIterator applies a mapping function to each item in a sequence.
16 * The mapping function always returns a single item (never null)
17 * <p>This is a specialization of the more general MappingIterator class, for use
18 * in cases where a single input item always maps to exactly one output item</p>
19 */
20
21 public final class EveryItemMappingIterator implements SequenceIterator {
22
23 private SequenceIterator base;
24 private ItemMappingFunction action;
25
26 /**
27 * Construct an ItemMappingIterator that will apply a specified DummyItemMappingFunction to
28 * each Item returned by the base iterator.
29 *
30 * @param base the base iterator
31 * @param action the mapping function to be applied
32 */
33
34 public EveryItemMappingIterator(SequenceIterator base, ItemMappingFunction action) {
35 this.base = base;
36 this.action = action;
37 }
38
39 public Item next() throws XPathException {
40 Item nextSource = base.next();
41 if (nextSource == null) {
42 return null;
43 }
44 // Call the supplied mapping function
45 return action.mapItem(nextSource);
46 }
47
48 public void close() {
49 base.close();
50 }
51
52 /**
53 * Get properties of this iterator, as a bit-significant integer.
54 *
55 * @return the properties of this iterator. This will be some combination of
56 * properties such as {@link net.sf.saxon.om.SequenceIterator#GROUNDED},
57 * {@link net.sf.saxon.om.SequenceIterator#LAST_POSITION_FINDER},
58 * and {@link net.sf.saxon.om.SequenceIterator#LOOKAHEAD}. It is always
59 * acceptable to return the value zero, indicating that there are no known special properties.
60 * It is acceptable for the properties of the iterator to change depending on its state.
61 */
62
63 public int getProperties() {
64 return 0;
65 }
66 }
67