Package net.sf.saxon.expr
Class ConsumingOperand
- java.lang.Object
-
- net.sf.saxon.expr.Expression
-
- net.sf.saxon.expr.UnaryExpression
-
- net.sf.saxon.expr.ConsumingOperand
-
- All Implemented Interfaces:
ExportAgent,Locatable,IdentityComparable,Traceable
public class ConsumingOperand extends UnaryExpression
This expression is used as a proxy for the consuming operand of an expression such as an arithmetic expression for which there is no explicit streaming support. The actual subexpression is retained, so that it is accessible to compile time operations that walk the expression tree; but at evaluation time, the subexpression is not evaluated in the conventional (pull) way, rather its value is pushed up the tree as a consequence of template inversion. Previously (until 9.6) a SuppliedParameterReference was used for the purpose; but this caused problems with allocation of local variable slots: see bug 2320.
-
-
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
Constructors Constructor Description ConsumingOperand(Expression subExpression)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcomputeCardinality()Get the static cardinalityExpressioncopy(RebindingMap rebindings)Copy an expression.Sequenceevaluate(XPathContext c)Get the value of this expression in a given context.ItemevaluateItem(XPathContext context)Evaluate an expression as a single item.voidexport(ExpressionPresenter destination)Diagnostic print of expression structure.java.lang.StringgetExpressionName()Get a name identifying the kind of expression, in terms meaningful to a user.intgetImplementationMethod()An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().intgetIntrinsicDependencies()Determine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions.ItemTypegetItemType()Determine the data type of the expression, if possible.protected OperandRolegetOperandRole()Get the usage (in terms of streamability analysis) of the single operandSequenceIteratoriterate(XPathContext context)Get the value of this expression in a given context.java.lang.StringtoShortString()Produce a short string identifying the expression for use in error messagesjava.lang.StringtoString()The toString() method for an expression attempts to give a representation of the expression in an XPath-like form, but there is no guarantee that the syntax will actually be true XPath.-
Methods inherited from class net.sf.saxon.expr.UnaryExpression
computeHashCode, computeSpecialProperties, displayOperator, emitExtraAttributes, equals, getBaseExpression, getOperand, operands, optimize, setBaseExpression, typeCheck
-
Methods inherited from class net.sf.saxon.expr.Expression
addToPathMap, adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, dynamicError, effectiveBooleanValue, evaluateAsString, evaluatePendingUpdates, explain, getCardinality, getConfiguration, getCost, getDependencies, getEvaluationMethod, getExtraProperty, getIntegerBounds, getInterpretedExpression, getLocalRetainedStaticContext, getLocation, getNetCost, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getStaticUType, getStreamerName, getTracingTag, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isInstruction, isLiftable, isMultiThreaded, isStaticPropertiesKnown, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, markTailFunctionCalls, operandList, operandSparseList, optimizeChildren, prepareForStreaming, process, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, suppressValidation, toPattern, typeCheckChildren, typeError, unordered, verifyParentPointers
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.saxon.trace.Traceable
gatherProperties
-
-
-
-
Constructor Detail
-
ConsumingOperand
public ConsumingOperand(Expression subExpression)
Constructor- Parameters:
subExpression- identifies the expression for which this is a proxy.
-
-
Method Detail
-
getOperandRole
protected OperandRole getOperandRole()
Get the usage (in terms of streamability analysis) of the single operand- Specified by:
getOperandRolein classUnaryExpression- Returns:
- the operand usage
-
getItemType
public ItemType getItemType()
Determine the data type of the expression, if possible.- Overrides:
getItemTypein classUnaryExpression- Returns:
- Type.ITEM, because we don't know the type of the supplied value in advance.
-
getIntrinsicDependencies
public int getIntrinsicDependencies()
Determine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions. For example, position() has an intrinsic dependency on the context position, while (position()+1) does not. The default implementation of the method returns 0, indicating "no dependencies".- Overrides:
getIntrinsicDependenciesin classExpression- Returns:
- a set of bit-significant flags identifying the "intrinsic" dependencies. The flags are documented in class net.sf.saxon.value.StaticProperty
-
computeCardinality
public int computeCardinality()
Get the static cardinality- Overrides:
computeCardinalityin classUnaryExpression- Returns:
- ZERO_OR_MORE, unless we know the type of the supplied value in advance.
-
copy
public Expression copy(RebindingMap rebindings)
Copy an expression. This makes a deep copy.- Specified by:
copyin classExpression- Parameters:
rebindings-- Returns:
- the copy of the original expression
-
getImplementationMethod
public int getImplementationMethod()
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process(). This method indicates which of these methods is provided directly. The other methods will always be available indirectly, using an implementation that relies on one of the other methods.- Specified by:
getImplementationMethodin classExpression- Returns:
- the implementation method, for example
Expression.ITERATE_METHODorExpression.EVALUATE_METHODorExpression.PROCESS_METHOD
-
evaluate
public Sequence evaluate(XPathContext c) throws XPathException
Get the value of this expression in a given context.- Parameters:
c- the XPathContext which contains the relevant variable bindings- Returns:
- the value of the variable, if it is defined
- Throws:
XPathException- if the variable is undefined
-
iterate
public SequenceIterator iterate(XPathContext context) throws XPathException
Get the value of this expression in a given context.- Overrides:
iteratein classExpression- Parameters:
context- the XPathContext which contains the relevant variable bindings- Returns:
- the value of the variable, if it is defined
- Throws:
XPathException- if the variable is undefined
-
evaluateItem
public Item evaluateItem(XPathContext context) throws XPathException
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 classExpression- 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
-
getExpressionName
public java.lang.String getExpressionName()
Get a name identifying the kind of expression, in terms meaningful to a user.- Overrides:
getExpressionNamein classExpression- 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 export() output displaying the expression.
-
export
public void export(ExpressionPresenter destination) throws XPathException
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.- Specified by:
exportin interfaceExportAgent- Overrides:
exportin classUnaryExpression- Parameters:
destination- 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.
-
toString
public java.lang.String toString()
The toString() method for an expression attempts to give a representation of the expression in an XPath-like form, but there is no guarantee that the syntax will actually be true XPath. In the case of XSLT instructions, the toString() method gives an abstracted view of the syntax- Overrides:
toStringin classUnaryExpression- Returns:
- a representation of the expression as a string
-
toShortString
public java.lang.String toShortString()
Description copied from class:ExpressionProduce a short string identifying the expression for use in error messages- Overrides:
toShortStringin classUnaryExpression- Returns:
- a short string, sufficient to identify the expression
-
-