| 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.flwor; |
| 9 | |
| 10 | import net.sf.saxon.expr.XPathContext; |
| 11 | import net.sf.saxon.trans.XPathException; |
| 12 | |
| 13 | /** |
| 14 | * Abtract class representing a tuple stream (used to evaluate a FLWOR expression) in pull mode |
| 15 | * (where the consumer of tuples activates the provider of those tuples) |
| 16 | */ |
| 17 | public abstract class TuplePull { |
| 18 | |
| 19 | /** |
| 20 | * Move on to the next tuple. Before returning, this method must set all the variables corresponding |
| 21 | * to the "returned" tuple in the local stack frame associated with the context object |
| 22 | * |
| 23 | * @param context the dynamic evaluation context |
| 24 | * @return true if another tuple has been generated; false if the tuple stream is exhausted. If the |
| 25 | * method returns false, the values of the local variables corresponding to this tuple stream |
| 26 | * are undefined. |
| 27 | */ |
| 28 | |
| 29 | public abstract boolean nextTuple(XPathContext context) throws XPathException; |
| 30 | |
| 31 | /** |
| 32 | * Close the tuple stream, indicating that although not all tuples have been read, |
| 33 | * no further tuples are required and resources can be released |
| 34 | */ |
| 35 | |
| 36 | public void close() { |
| 37 | // default implementation takes no action |
| 38 | } |
| 39 | } |
| 40 |