Debian Codegraph @

net/sf/saxon/expr/flwor/LetClausePull.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.flwor;
9
10 import net.sf.saxon.expr.XPathContext;
11 import net.sf.saxon.om.Sequence;
12 import net.sf.saxon.trans.XPathException;
13
14 /**
15 * Implements the changes to a tuple stream effected by the Let clause in a FLWOR expression
16 */
17 public class LetClausePull extends TuplePull {
18
19 TuplePull base;
20 LetClause letClause;
21
22 public LetClausePull(TuplePull base, LetClause letClause) {
23 this.base = base;
24 this.letClause = letClause;
25 }
26
27 /**
28 * Move on to the next tuple. Before returning, this method must set all the variables corresponding
29 * to the "returned" tuple in the local stack frame associated with the context object
30 *
31 * @param context the dynamic evaluation context
32 * @return true if another tuple has been generated; false if the tuple stream is exhausted. If the
33 * method returns false, the values of the local variables corresponding to this tuple stream
34 * are undefined.
35 */
36 @Override
37 public boolean nextTuple(XPathContext context) throws XPathException {
38 if (!base.nextTuple(context)) {
39 return false;
40 }
41 Sequence<?> val = letClause.getEvaluator().evaluate(letClause.getSequence(), context);
42 context.setLocalVariable(letClause.getRangeVariable().getLocalSlotNumber(), val);
43 return true;
44 }
45
46 /**
47 * Close the tuple stream, indicating that although not all tuples have been read,
48 * no further tuples are required and resources can be released
49 */
50 @Override
51 public void close() {
52 base.close();
53 }
54 }
55