| 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 | * MappingFunction is an interface that must be satisfied by an object passed to a |
| 16 | * MappingIterator. It represents an object which, given an Item, can return a |
| 17 | * SequenceIterator that delivers a sequence of zero or more Items. |
| 18 | * |
| 19 | * <p>It maps an item of class F to a sequence of items of class T, returned as an iterator.</p> |
| 20 | */ |
| 21 | |
| 22 | public interface MappingFunction<F extends Item<?>, T extends Item<?>> { |
| 23 | |
| 24 | /** |
| 25 | * Map one item to a sequence. |
| 26 | * |
| 27 | * @param item The item to be mapped. |
| 28 | * @return one of the following: (a) a SequenceIterator over the sequence of items that the supplied input |
| 29 | * item maps to, or (b) null if it maps to an empty sequence. |
| 30 | * @throws XPathException if a dynamic error occurs |
| 31 | */ |
| 32 | |
| 33 | /*@Nullable*/ |
| 34 | SequenceIterator<? extends T> map(F item) throws XPathException; |
| 35 | |
| 36 | } |
| 37 |