| 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 | |
| 12 | /** |
| 13 | * The "singularity" tuple stream delivers a single empty tuple. It is the base tuple stream |
| 14 | * for the outermost for/let clause in a FLWOR expression |
| 15 | */ |
| 16 | public class SingularityPull extends TuplePull { |
| 17 | |
| 18 | private boolean done = false; |
| 19 | |
| 20 | /** |
| 21 | * Move on to the next tuple. Before returning, this method must set all the variables corresponding |
| 22 | * to the "returned" tuple in the local stack frame associated with the context object |
| 23 | * |
| 24 | * @param context the dynamic evaluation context |
| 25 | * @return true if another tuple has been generated; false if the tuple stream is exhausted. If the |
| 26 | * method returns false, the values of the local variables corresponding to this tuple stream |
| 27 | * are undefined. |
| 28 | */ |
| 29 | @Override |
| 30 | public boolean nextTuple(XPathContext context) { |
| 31 | if (done) { |
| 32 | return false; |
| 33 | } else { |
| 34 | done = true; |
| 35 | return true; |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 |