Package net.sf.saxon.expr.instruct
Class TraceExpression
java.lang.Object
net.sf.saxon.expr.Expression
net.sf.saxon.expr.instruct.Instruction
net.sf.saxon.expr.instruct.TraceExpression
- All Implemented Interfaces:
ExportAgent,Locatable,IdentityComparable,Traceable
A wrapper expression used to trace expressions in XSLT and XQuery.
-
Field Summary
Fields inherited from class net.sf.saxon.expr.Expression
EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, ITEM_FEED_METHOD, ITERATE_METHOD, MAX_COST, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, UPDATE_METHOD, WATCH_METHOD -
Constructor Summary
ConstructorsConstructorDescriptionTraceExpression(Expression child) Create a trace expression that traces execution of a given child expression -
Method Summary
Modifier and TypeMethodDescriptionvoidCheck to ensure that this expression does not contain any inappropriate updating subexpressions.protected intCompute a hash code, which will then be cached for later usecopy(RebindingMap rebindings) Copy an expression.booleanThe equals() test for expressions returns true if it can be determined that two expressions (given their static context) will return the same result in all circumstances.evaluateItem(XPathContext context) Evaluate an expression as a single item.voidExport the expression structure.getBody()intDetermine the static cardinality of the expression.getChild()intDetermine which aspects of the context the expression depends on.Make an elaborator for this expressionGet a name identifying the kind of expression, in terms meaningful to a user.intAn implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().intGet the namecode of the instruction for use in diagnosticsGet the item type of the items returned by evaluating this instructionintReturn the estimated cost of evaluating an expression.Get an iterator over all the properties available.getProperty(String name) Get a named property of the instruction/expressionGet the (partial) name of a class that supports streaming of this kind of expressionbooleanDetermine whether this is an updating expression as defined in the XQuery update specificationbooleanDetermine whether this is a vacuous expression as defined in the XQuery update specificationiterate(XPathContext context) Return an Iterator to iterate over the values of a sequence.final booleanDetermine whether this instruction potentially creates new nodes.operands()Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression.optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) Perform optimisation of an expression and its subexpressions.voidsetProperty(String name, Object value) Set a named property of the instruction/expressionProduce a short string identifying the expression for use in error messagesMethods inherited from class net.sf.saxon.expr.instruct.Instruction
alwaysCreatesNewNodes, assembleParams, assembleTunnelParams, computeCardinality, computeSpecialProperties, dynamicError, evaluateAsString, getSourceLocator, isInstruction, isXSLT, process, someOperandCreatesNewNodesMethods inherited from class net.sf.saxon.expr.Expression
addToPathMap, adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkPermittedContents, computeDependencies, computeStaticProperties, dispatchTailCall, dynamicError, effectiveBooleanValue, explain, getConfiguration, getCost, getEvaluationMethod, getExtraProperty, getIntegerBounds, getIntrinsicDependencies, getLocalRetainedStaticContext, getLocation, getObjectName, getPackageData, getParentExpression, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getStaticUType, getTracingTag, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isLiftable, isMultiThreaded, isStaticPropertiesKnown, isSubtreeExpression, makeElaborator, markTailFunctionCalls, operandList, operandSparseList, optimizeChildren, prepareForStreaming, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, supportsLazyEvaluation, suppressValidation, toPattern, toString, typeCheck, typeCheckChildren, typeError, unordered, verifyParentPointers, withLocationMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.sf.saxon.trace.Traceable
gatherProperties
-
Constructor Details
-
TraceExpression
Create a trace expression that traces execution of a given child expression- Parameters:
child- the expression to be traced. This will be available to the TraceListener as the value of the "expression" property of the InstructionInfo.
-
-
Method Details
-
getChild
-
getBody
-
operands
Description copied from class:ExpressionGet the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression.If the expression is a Callable, then it is required that the order of the operands returned by this function is the same as the order of arguments supplied to the corresponding call() method.
- Specified by:
operandsin classInstruction- Returns:
- an iterator containing the sub-expressions of this expression
-
setProperty
Set a named property of the instruction/expression- Parameters:
name- the name of the propertyvalue- the value of the property
-
getProperty
Get a named property of the instruction/expression- Overrides:
getPropertyin classExpression- Parameters:
name- the name of the property- Returns:
- the value of the property
-
getProperties
Get an iterator over all the properties available. The values returned by the iterator will be of type String, and each string can be supplied as input to the getProperty() method to retrieve the value of the property.- Overrides:
getPropertiesin classExpression- Returns:
- an iterator over the properties
-
getExpressionName
Get a name identifying the kind of expression, in terms meaningful to a user.- Overrides:
getExpressionNamein classInstruction- Returns:
- a name identifying the kind of expression, in terms meaningful to a user. The name will always be in the form of a lexical XML QName, and should match the name used in explain() output displaying the expression.
-
getStreamerName
Get the (partial) name of a class that supports streaming of this kind of expression- Overrides:
getStreamerNamein classExpression- Returns:
- the partial name of a class that can be instantiated to provide streaming support in Saxon-EE, or null if there is no such class
-
copy
Description copied from class:ExpressionCopy an expression. This makes a deep copy.- Specified by:
copyin classExpression- Parameters:
rebindings- a mutable list of (old binding, new binding) pairs that is used to update the bindings held in any local variable references that are copied.- Returns:
- the copy of the original expression
-
isUpdatingExpression
public boolean isUpdatingExpression()Determine whether this is an updating expression as defined in the XQuery update specification- Overrides:
isUpdatingExpressionin classExpression- Returns:
- true if this is an updating expression
-
isVacuousExpression
public boolean isVacuousExpression()Determine whether this is a vacuous expression as defined in the XQuery update specification- Overrides:
isVacuousExpressionin classExpression- Returns:
- true if this expression is vacuous
-
checkForUpdatingSubexpressions
Check to ensure that this expression does not contain any inappropriate updating subexpressions. This check is overridden for those expressions that permit updating subexpressions.- Overrides:
checkForUpdatingSubexpressionsin classExpression- Throws:
XPathException- if the expression has a non-permitted updating subexpression
-
getImplementationMethod
public int getImplementationMethod()Description copied from class:InstructionAn implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process(). This method indicates which of these methods is preferred. For instructions this is the process() method.- Overrides:
getImplementationMethodin classInstruction- Returns:
- the implementation method, for example
Expression.ITERATE_METHODorExpression.EVALUATE_METHODorExpression.PROCESS_METHOD
-
getItemType
Get the item type of the items returned by evaluating this instruction- Overrides:
getItemTypein classInstruction- Returns:
- the static item type of the instruction
-
getCardinality
public int getCardinality()Determine the static cardinality of the expression. This establishes how many items there will be in the result of the expression, at compile time (i.e., without actually evaluating the result.- Overrides:
getCardinalityin classExpression- Returns:
- one of the values Cardinality.ONE_OR_MORE, Cardinality.ZERO_OR_MORE, Cardinality.EXACTLY_ONE, Cardinality.ZERO_OR_ONE, Cardinality.EMPTY. This default implementation returns ZERO_OR_MORE (which effectively gives no information).
-
getDependencies
public int getDependencies()Determine which aspects of the context the expression depends on. The result is a bitwise-or'ed value composed from constants such asStaticProperty.DEPENDS_ON_CONTEXT_ITEMandStaticProperty.DEPENDS_ON_CURRENT_ITEM. The default implementation combines the intrinsic dependencies of this expression with the dependencies of the subexpressions, computed recursively. This is overridden for expressions such as FilterExpression where a subexpression's dependencies are not necessarily inherited by the parent expression.- Overrides:
getDependenciesin classExpression- Returns:
- a set of bit-significant flags identifying the dependencies of the expression
-
mayCreateNewNodes
public final boolean mayCreateNewNodes()Determine whether this instruction potentially creates new nodes.- Overrides:
mayCreateNewNodesin classInstruction- Returns:
- true if the instruction creates new nodes under some input conditions (or if it can't be proved that it doesn't)
-
equals
Description copied from class:ExpressionThe equals() test for expressions returns true if it can be determined that two expressions (given their static context) will return the same result in all circumstances. The value false is returned if this is not the case or if it cannot be determined to be the case.During the various phases of compilation, expression objects are mutable. Changing an expression may change its hashCode, and may change the result of equals() comparisons. Expressions should therefore not be held in data structures such as maps and sets that depend on equality comparison unless they are no longer subject to such mutation.
- Overrides:
equalsin classExpression- Parameters:
other- the other operand; the result is false if this is not an Expression- Returns:
- true if the other operand is an expression and if it can be determined that the two expressions are equivalent, in the sense that they will always return the same result.
-
computeHashCode
protected int computeHashCode()Compute a hash code, which will then be cached for later use- Overrides:
computeHashCodein classExpression- Returns:
- a computed hash code
-
getNetCost
public int getNetCost()Return the estimated cost of evaluating an expression. For a TraceExpression we return zero, because ideally we don't want trace expressions to affect optimization decisions.- Overrides:
getNetCostin classInstruction- Returns:
- zero
-
evaluateItem
Evaluate an expression as a single item. This always returns either a single Item or null (denoting the empty sequence). No conversion is done. This method should not be used unless the static type of the expression is a subtype of "item" or "item?": that is, it should not be called if the expression may return a sequence. There is no guarantee that this condition will be detected.- Overrides:
evaluateItemin classInstruction- Parameters:
context- The context in which the expression is to be evaluated- Returns:
- the node or atomic value that results from evaluating the expression; or null to indicate that the result is an empty sequence
- Throws:
XPathException- if any dynamic error occurs evaluating the expression
-
iterate
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.- Overrides:
iteratein classInstruction- Parameters:
context- supplies the context for evaluation- Returns:
- a SequenceIterator that can be used to iterate over the result of the expression
- Throws:
XPathException- if any dynamic error occurs evaluating the expression
-
getInstructionNameCode
public int getInstructionNameCode()Description copied from class:InstructionGet the namecode of the instruction for use in diagnostics- Overrides:
getInstructionNameCodein classInstruction- Returns:
- a code identifying the instruction: typically but not always the fingerprint of a name in the XSLT namespace
-
optimize
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException Perform optimisation of an expression and its subexpressions. This is the third and final phase of static optimization.This method is called after all references to functions and variables have been resolved to the declaration of the function or variable, and after all type checking has been done.
- Overrides:
optimizein classExpression- Parameters:
visitor- an expression visitorcontextInfo- the static type of "." at the point where this expression is invoked. The parameter is set to null if it is known statically that the context item will be undefined. If the type of the context item is not known statically, the argument is set toType.ITEM_TYPE- Returns:
- the original expression, rewritten if appropriate to optimize execution
- Throws:
XPathException- if an error is discovered during this phase (typically a type error)
-
export
Export the expression structure. The abstract expression tree is written to the supplied output destination. Note: trace expressions are omitted from the generated SEF file.- Specified by:
exportin interfaceExportAgent- Specified by:
exportin classExpression- Parameters:
out- the expression presenter used to display the structure- Throws:
XPathException- if the export fails, for example if an expression is found that won't work in the target environment.
-
toShortString
Produce a short string identifying the expression for use in error messages- Overrides:
toShortStringin classExpression- Returns:
- a short string, sufficient to identify the expression
-
getElaborator
Description copied from class:ExpressionMake an elaborator for this expression- Overrides:
getElaboratorin classExpression- Returns:
- an appropriate
Elaborator
-