/** * Evaluate the function */ public Item evaluateItem(XPathContext context) throws XPathException { Item val = argument[0].evaluateItem(context); String label = argument[1].evaluateAsString(context).toString(); if (context.getController().isTracing()) { notifyListener(label, Value.asValue(val), context); } else { traceItem(val, label); } return val; }
/** * Execute this instruction, with the possibility of returning tail calls if there are any. * This outputs the trace information via the registered TraceListener, * and invokes the instruction being traced. * @param context the dynamic execution context * @return either null, or a tail call that the caller must invoke on return * @throws net.sf.saxon.trans.XPathException */ public TailCall processLeavingTail(XPathContext context) throws XPathException { Controller controller = context.getController(); TraceListener listener = controller.getTraceListener(); if (controller.isTracing()) { listener.enter(getInstructionInfo(), context); } // Don't attempt tail call optimization when tracing, the results are too confusing child.process(context); if (controller.isTracing()) { listener.leave(getInstructionInfo()); } return null; }
/** * Execute this instruction, with the possibility of returning tail calls if there are any. * This outputs the trace information via the registered TraceListener, * and invokes the instruction being traced. * @param context the dynamic execution context * @return either null, or a tail call that the caller must invoke on return * @throws net.sf.saxon.trans.XPathException */ public TailCall processLeavingTail(XPathContext context) throws XPathException { Controller controller = context.getController(); TraceListener listener = controller.getTraceListener(); if (controller.isTracing()) { listener.enter(getInstructionInfo(), context); } // Don't attempt tail call optimization when tracing, the results are too confusing child.process(context); if (controller.isTracing()) { listener.leave(getInstructionInfo()); } return null; }
/** * Evaluate the function */ public Item evaluateItem(XPathContext context) throws XPathException { Item val = argument[0].evaluateItem(context); String label = argument[1].evaluateAsString(context).toString(); if (context.getController().isTracing()) { notifyListener(label, Value.asValue(val), context); } else { traceItem(val, label); } return val; }
/** * Iterate over the results of the function */ public SequenceIterator iterate(XPathContext context) throws XPathException { if (context.getController().isTracing()) { String label = argument[1].evaluateAsString(context).toString(); Value value = Value.asValue(ExpressionTool.eagerEvaluate(argument[0], context)); notifyListener(label, value, context); return value.iterate(); } else { return new TracingIterator(argument[0].iterate(context), argument[1].evaluateAsString(context).toString()); } }
/** * Iterate over the results of the function */ public SequenceIterator iterate(XPathContext context) throws XPathException { if (context.getController().isTracing()) { String label = argument[1].evaluateAsString(context).toString(); Value value = Value.asValue(ExpressionTool.eagerEvaluate(argument[0], context)); notifyListener(label, value, context); return value.iterate(); } else { return new TracingIterator(argument[0].iterate(context), argument[1].evaluateAsString(context).toString()); } }
/** * Evaluate an updating expression, adding the results to a Pending Update List. * The default implementation of this method, which is used for non-updating expressions, * throws an UnsupportedOperationException * * @param context the XPath dynamic evaluation context * @param pul the pending update list to which the results should be written */ public void evaluatePendingUpdates(XPathContext context, PendingUpdateList pul) throws XPathException { Controller controller = context.getController(); assert controller != null; if (controller.isTracing()) { controller.getTraceListener().enter(getInstructionInfo(), context); } getChild().evaluatePendingUpdates(context, pul); if (controller.isTracing()) { controller.getTraceListener().leave(getInstructionInfo()); } }
/** * Return an Iterator to iterate over the values of a sequence. The value of every * expression can be regarded as a sequence, so this method is supported for all * expressions. This default implementation handles iteration for expressions that * return singleton values: for non-singleton expressions, the subclass must * provide its own implementation. * * @exception net.sf.saxon.trans.XPathException if any dynamic error occurs evaluating the * expression * @param context supplies the context for evaluation * @return a SequenceIterator that can be used to iterate over the result * of the expression */ public SequenceIterator iterate(XPathContext context) throws XPathException { Controller controller = context.getController(); if (controller.isTracing()) { controller.getTraceListener().enter(getInstructionInfo(), context); } SequenceIterator result = child.iterate(context); if (controller.isTracing()) { controller.getTraceListener().leave(getInstructionInfo()); } return result; }
/** * Evaluate an updating expression, adding the results to a Pending Update List. * The default implementation of this method, which is used for non-updating expressions, * throws an UnsupportedOperationException * * @param context the XPath dynamic evaluation context * @param pul the pending update list to which the results should be written */ public void evaluatePendingUpdates(XPathContext context, PendingUpdateList pul) throws XPathException { Controller controller = context.getController(); assert controller != null; if (controller.isTracing()) { controller.getTraceListener().enter(getInstructionInfo(), context); } getChild().evaluatePendingUpdates(context, pul); if (controller.isTracing()) { controller.getTraceListener().leave(getInstructionInfo()); } }
/** * Return an Iterator to iterate over the values of a sequence. The value of every * expression can be regarded as a sequence, so this method is supported for all * expressions. This default implementation handles iteration for expressions that * return singleton values: for non-singleton expressions, the subclass must * provide its own implementation. * * @exception net.sf.saxon.trans.XPathException if any dynamic error occurs evaluating the * expression * @param context supplies the context for evaluation * @return a SequenceIterator that can be used to iterate over the result * of the expression */ public SequenceIterator iterate(XPathContext context) throws XPathException { Controller controller = context.getController(); if (controller.isTracing()) { controller.getTraceListener().enter(getInstructionInfo(), context); } SequenceIterator result = child.iterate(context); if (controller.isTracing()) { controller.getTraceListener().leave(getInstructionInfo()); } return result; }
/** * Execute this instruction, with the possibility of returning tail calls if there are any. * This outputs the trace information via the registered TraceListener, * and invokes the instruction being traced. * * @param context the dynamic execution context * @return either null, or a tail call that the caller must invoke on return * @throws net.sf.saxon.trans.XPathException * */ public TailCall processLeavingTail(XPathContext context) throws XPathException { Controller controller = context.getController(); assert controller != null; TraceListener listener = controller.getTraceListener(); if (controller.isTracing()) { assert listener != null; listener.enter(getInstructionInfo(), context); } // Don't attempt tail call optimization when tracing, the results are too confusing getChild().process(context); if (controller.isTracing()) { assert listener != null; listener.leave(getInstructionInfo()); } return null; }
/** * Evaluate the function */ public Item evaluateItem(XPathContext context) throws XPathException { Item val = argument[0].evaluateItem(context); String label = argument[1].evaluateAsString(context).toString(); Controller controller = context.getController(); if (controller.isTracing()) { notifyListener(label, Value.asValue(val), context); } else { PrintStream out = controller.getTraceFunctionDestination(); if (out != null) { traceItem(val, label, out); } } return val; }
/** * Return an Iterator to iterate over the values of a sequence. The value of every * expression can be regarded as a sequence, so this method is supported for all * expressions. This default implementation handles iteration for expressions that * return singleton values: for non-singleton expressions, the subclass must * provide its own implementation. * * @param context supplies the context for evaluation * @return a SequenceIterator that can be used to iterate over the result * of the expression * @throws net.sf.saxon.trans.XPathException * if any dynamic error occurs evaluating the * expression */ /*@NotNull*/ public SequenceIterator<?> iterate(XPathContext context) throws XPathException { Controller controller = context.getController(); assert controller != null; if (controller.isTracing()) { controller.getTraceListener().enter(getInstructionInfo(), context); } SequenceIterator result = getChild().iterate(context); if (controller.isTracing()) { controller.getTraceListener().leave(getInstructionInfo()); } return result; }
/** * Iterate over the results of the function */ public SequenceIterator iterate(XPathContext context) throws XPathException { Controller controller = context.getController(); if (controller.isTracing()) { String label = argument[1].evaluateAsString(context).toString(); Value value = Value.asValue(ExpressionTool.eagerEvaluate(argument[0], context)); notifyListener(label, value, context); return value.iterate(); } else { PrintStream out = controller.getTraceFunctionDestination(); if (out == null) { return argument[0].iterate(context); } else { return new TracingIterator(argument[0].iterate(context), argument[1].evaluateAsString(context).toString(), out); } } }
@Override public void processTuple(XPathContext context) throws XPathException { Controller controller = context.getController(); if (controller.isTracing()) { ClauseInfo baseInfo = new ClauseInfo(baseClause); baseInfo.setNamespaceResolver(traceClause.getNamespaceResolver()); controller.getTraceListener().enter(baseInfo, context); destination.processTuple(context); controller.getTraceListener().leave(baseInfo); } else { destination.processTuple(context); } }
@Override public void processTuple(XPathContext context) throws XPathException { Controller controller = context.getController(); if (controller.isTracing()) { ClauseInfo baseInfo = new ClauseInfo(baseClause); baseInfo.setNamespaceResolver(traceClause.getNamespaceResolver()); controller.getTraceListener().enter(baseInfo, context); destination.processTuple(context); controller.getTraceListener().leave(baseInfo); } else { destination.processTuple(context); } }
/** * Move on to the next tuple. Before returning, this method must set all the variables corresponding * to the "returned" tuple in the local stack frame associated with the context object * * @param context the dynamic evaluation context * @return true if another tuple has been generated; false if the tuple stream is exhausted. If the * method returns false, the values of the local variables corresponding to this tuple stream * are undefined. */ @Override public boolean nextTuple(XPathContext context) throws XPathException { Controller controller = context.getController(); if (controller.isTracing()) { ClauseInfo baseInfo = new ClauseInfo(baseClause); baseInfo.setNamespaceResolver(traceClause.getNamespaceResolver()); controller.getTraceListener().enter(baseInfo, context); boolean b = base.nextTuple(context); controller.getTraceListener().leave(baseInfo); return b; } else { return base.nextTuple(context); } }
/** * Move on to the next tuple. Before returning, this method must set all the variables corresponding * to the "returned" tuple in the local stack frame associated with the context object * * @param context the dynamic evaluation context * @return true if another tuple has been generated; false if the tuple stream is exhausted. If the * method returns false, the values of the local variables corresponding to this tuple stream * are undefined. */ @Override public boolean nextTuple(XPathContext context) throws XPathException { Controller controller = context.getController(); if (controller.isTracing()) { ClauseInfo baseInfo = new ClauseInfo(baseClause); baseInfo.setNamespaceResolver(traceClause.getNamespaceResolver()); controller.getTraceListener().enter(baseInfo, context); boolean b = base.nextTuple(context); controller.getTraceListener().leave(baseInfo); return b; } else { return base.nextTuple(context); } }
/** * Evaluate the expression * * @param context the dynamic evaluation context * @param arguments the values of the arguments, supplied as SequenceIterators * @return the result of the evaluation, in the form of a SequenceIterator * @throws net.sf.saxon.trans.XPathException * if a dynamic error occurs during the evaluation of the expression */ public Sequence<?> call(XPathContext context, Sequence[] arguments) throws XPathException { Controller controller = context.getController(); String label = arguments.length == 1 ? "*" : arguments[1].head().getStringValue(); if (controller.isTracing()) { Sequence<?> value = arguments[0].iterate().materialize(); notifyListener(label, value, location, context); return value; } else { Logger out = controller.getTraceFunctionDestination(); if (out == null) { return arguments[0]; } else { return SequenceTool.toLazySequence(new TracingIterator(arguments[0].iterate(), label, out)); } } }
public TailCall processLeavingTail(XPathContext context) throws XPathException { Controller controller = context.getController(); assert controller != null; PipelineConfiguration pipe = context.getReceiver().getPipelineConfiguration(); GroupIterator groupIterator = getGroupIterator(context); XPathContextMajor c2 = context.newContext(); c2.setOrigin(this); FocusIterator focusIterator = c2.trackFocus(groupIterator); c2.setCurrentGroupIterator(groupIterator); c2.setCurrentTemplateRule(null); pipe.setXPathContext(c2); if (controller.isTracing()) { TraceListener listener = controller.getTraceListener(); assert listener != null; Item item; while ((item = focusIterator.next()) != null) { listener.startCurrentItem(item); getActionExpression().process(c2); listener.endCurrentItem(item); } } else { while (focusIterator.next() != null) { getActionExpression().process(c2); } } pipe.setXPathContext(context); return null; }