Debian Codegraph @

net/sf/saxon/expr/flwor/TraceClausePush.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.Controller;
11 import net.sf.saxon.expr.XPathContext;
12 import net.sf.saxon.trans.XPathException;
13
14 /**
15 * This class represents the tuple stream delivered as the output of a trace clause in a
16 * FLWOR expression. It does not change the values of any variables in the tuple stream,
17 * but merely notifies the TraceListener whenever a new tuple is available.
18 */
19 public class TraceClausePush extends TuplePush {
20
21 private TuplePush destination;
22 TraceClause traceClause;
23 private Clause baseClause;
24
25 public TraceClausePush(TuplePush destination, TraceClause traceClause, Clause baseClause) {
26 this.destination = destination;
27 this.traceClause = traceClause;
28 this.baseClause = baseClause;
29 }
30
31 /*
32 * Process the next tuple.
33 */
34 @Override
35 public void processTuple(XPathContext context) throws XPathException {
36 Controller controller = context.getController();
37 if (controller.isTracing()) {
38 ClauseInfo baseInfo = new ClauseInfo(baseClause);
39 baseInfo.setNamespaceResolver(traceClause.getNamespaceResolver());
40 controller.getTraceListener().enter(baseInfo, context);
41 destination.processTuple(context);
42 controller.getTraceListener().leave(baseInfo);
43 } else {
44 destination.processTuple(context);
45 }
46 }
47
48 /*
49 * Notify the end of the tuple stream
50 */
51 @Override
52 public void close() throws XPathException {
53 destination.close();
54 }
55 }
56