| 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.trans.XPathException; |
| 11 | |
| 12 | |
| 13 | /** |
| 14 | * A LastPositionFinder is an interface implemented by any SequenceIterator that is |
| 15 | * able to return the position of the last item in the sequence. |
| 16 | */ |
| 17 | |
| 18 | @FunctionalInterface |
| 19 | public interface LastPositionFinder { |
| 20 | |
| 21 | /** |
| 22 | * Get the last position (that is, the number of items in the sequence). This method is |
| 23 | * non-destructive: it does not change the state of the iterator. |
| 24 | * The result is undefined if the next() method of the iterator has already returned null. |
| 25 | * This method must not be called unless the result of getProperties() on the iterator |
| 26 | * includes the bit setting {@link net.sf.saxon.om.SequenceIterator#LAST_POSITION_FINDER} |
| 27 | * |
| 28 | * @return the number of items in the sequence |
| 29 | * @throws XPathException if an error occurs evaluating the sequence in order to determine |
| 30 | * the number of items |
| 31 | */ |
| 32 | |
| 33 | int getLength() throws XPathException; |
| 34 | |
| 35 | } |
| 36 |