public abstract class VariableReference extends Expression implements BindingReference
Modifier and Type | Field and Description |
---|---|
protected Binding |
binding |
protected GroundedValue |
constantValue |
protected SequenceType |
staticType |
EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, ITEM_FEED_METHOD, ITERATE_METHOD, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, UPDATE_METHOD, WATCH_METHOD
Constructor and Description |
---|
VariableReference(Binding binding)
Create a Variable Reference
|
VariableReference(StructuredQName name)
Create a Variable Reference
|
Modifier and Type | Method and Description |
---|---|
PathMap.PathMapNodeSet |
addToPathMap(PathMap pathMap,
PathMap.PathMapNodeSet pathMapNodeSet)
Add a representation of this expression to a PathMap.
|
int |
computeCardinality()
Get the static cardinality
|
int |
computeHashCode()
get HashCode for comparing two expressions
|
int |
computeSpecialProperties()
Determine the special properties of this expression
|
abstract Expression |
copy(RebindingMap rebindings)
Create a clone copy of this VariableReference
|
protected void |
copyFrom(VariableReference ref) |
boolean |
equals(java.lang.Object other)
Test if this expression is the same as another expression.
|
Item |
evaluateItem(XPathContext c)
Evaluate an expression as a single item.
|
Sequence |
evaluateVariable(XPathContext c)
Evaluate this variable
|
void |
export(ExpressionPresenter destination)
Diagnostic print of expression structure.
|
void |
fixup(Binding newBinding)
Fix up this variable reference to a Binding object, which enables the value of the variable
to be located at run-time.
|
Binding |
getBinding()
Get the object bound to the variable
|
java.lang.String |
getDisplayName()
Get the display name of the variable.
|
java.lang.String |
getEQName()
Get the EQName of the variable.
|
java.lang.String |
getExpressionName()
Get a name identifying the kind of expression, in terms meaningful to a user.
|
int |
getImplementationMethod()
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().
|
IntegerValue[] |
getIntegerBounds()
For an expression that returns an integer or a sequence of integers, get
a lower and upper bound on the values of the integers that may be returned, from
static analysis.
|
int |
getIntrinsicDependencies()
Determine the intrinsic dependencies of an expression, that is, those which are not derived
from the dependencies of its subexpressions.
|
ItemType |
getItemType()
Determine the data type of the expression, if possible
|
int |
getNetCost()
Return the net cost of evaluating this expression, excluding the cost of evaluating
its operands.
|
Expression |
getScopingExpression()
Get the innermost scoping expression of this expression, for expressions that directly
depend on something in the dynamic context.
|
UType |
getStaticUType(UType contextItemType)
Get the static type of the expression as a UType, following precisely the type
inference rules defined in the XSLT 3.0 specification.
|
java.lang.String |
getStreamerName()
Get the (partial) name of a class that supports streaming of this kind of expression
|
StructuredQName |
getVariableName()
Get the variable name
|
boolean |
isFiltered()
Determine whether this variable reference is filtered
|
boolean |
isFlattened()
Test whether this variable reference is flattened - that is, whether it is atomized etc
|
boolean |
isInLoop()
Determine whether this variable reference appears in a loop relative to its declaration.
|
SequenceIterator |
iterate(XPathContext c)
Get the value of this variable in a given context.
|
Expression |
optimize(ExpressionVisitor visitor,
ContextItemStaticInfo contextItemType)
Optimize the expression.
|
void |
process(XPathContext c)
Process the instruction, without returning any tail calls
|
void |
recomputeInLoop() |
void |
refineVariableType(ItemType type,
int cardinality,
GroundedValue constantValue,
int properties)
Provide additional information about the type of the variable, typically derived by analyzing
the initializer of the variable binding
|
void |
setFiltered(boolean filtered)
Mark an expression as filtered: that is, it appears as the base expression in a filter expression.
|
void |
setFlattened(boolean flattened)
Mark an expression as being "flattened".
|
void |
setStaticType(SequenceType type,
GroundedValue value,
int properties)
Set static type.
|
void |
setVariableName(StructuredQName name)
Set the variable name
|
java.lang.String |
toShortString()
Produce a short string identifying the expression for use in error messages
|
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.
|
Expression |
typeCheck(ExpressionVisitor visitor,
ContextItemStaticInfo contextInfo)
Type-check the expression.
|
adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, dynamicError, effectiveBooleanValue, evaluateAsString, evaluatePendingUpdates, explain, getCardinality, getConfiguration, getConstructType, getCost, getDependencies, getEvaluationMethod, getExtraProperty, getInterpretedExpression, getLocalRetainedStaticContext, getLocation, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, hasCompatibleStaticContext, hashCode, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isCallOnSystemFunction, isIdentical, isInstruction, isLiftable, isMultiThreaded, isSameExpression, isStaticPropertiesKnown, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, markTailFunctionCalls, operandList, operands, operandSparseList, optimizeChildren, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, suppressValidation, toPattern, typeCheckChildren, typeError, unordered, verifyParentPointers, verifyParentPointers
protected Binding binding
protected SequenceType staticType
protected GroundedValue constantValue
public VariableReference(StructuredQName name)
public VariableReference(Binding binding)
binding
- the variable binding to which this variable referspublic void setVariableName(StructuredQName name)
name
- the name of the variablepublic StructuredQName getVariableName()
public abstract Expression copy(RebindingMap rebindings)
copy
in class Expression
rebindings
- variables that need to switch to new bindingspublic int getNetCost()
Expression
getNetCost
in class Expression
protected void copyFrom(VariableReference ref)
public void setStaticType(SequenceType type, GroundedValue value, int properties)
setStaticType
in interface BindingReference
type
- the static type of the variablevalue
- the value of the variable if this is a compile-time constant, or null otherwiseproperties
- static properties of the expression to which the variable is boundpublic void setFlattened(boolean flattened)
setFlattened
in class Expression
flattened
- set to true if the result of the expression is atomized or otherwise turned into
an atomic valuepublic boolean isFlattened()
public void setFiltered(boolean filtered)
setFiltered
in class Expression
filtered
- if true, marks this expression as the base of a filter expressionpublic boolean isFiltered()
public boolean isInLoop()
public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
typeCheck
in class Expression
visitor
- an expression visitorcontextInfo
- Information available statically about the context item: whether it is (possibly)
absent; its static type; its streaming posture.XPathException
- if an error is discovered during this phase
(typically a type error)public void recomputeInLoop()
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException
optimize
in class Expression
visitor
- an expression visitorcontextItemType
- 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 to
Type.ITEM_TYPE
XPathException
- if an error is discovered during this phase
(typically a type error)public void fixup(Binding newBinding)
fixup
in interface BindingReference
newBinding
- the Binding to which the variable referspublic void refineVariableType(ItemType type, int cardinality, GroundedValue constantValue, int properties)
type
- the item type of the variablecardinality
- the cardinality of the variableconstantValue
- the actual value of the variable, if this is known statically, otherwise nullproperties
- additional static properties of the variable's initializerpublic ItemType getItemType()
getItemType
in class Expression
public UType getStaticUType(UType contextItemType)
getStaticUType
in class Expression
contextItemType
- the static context item typepublic IntegerValue[] getIntegerBounds()
getIntegerBounds
in class Expression
public int computeCardinality()
computeCardinality
in class Expression
StaticProperty.ALLOWS_ZERO_OR_ONE
,
StaticProperty.EXACTLY_ONE
, StaticProperty.ALLOWS_ONE_OR_MORE
,
StaticProperty.ALLOWS_ZERO_OR_MORE
public int computeSpecialProperties()
computeSpecialProperties
in class Expression
StaticProperty.NON_CREATIVE
(unless the variable is assignable using saxon:assign)public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int computeHashCode()
computeHashCode
in class Expression
public int getIntrinsicDependencies()
Expression
getIntrinsicDependencies
in class Expression
public int getImplementationMethod()
getImplementationMethod
in class Expression
Expression.ITERATE_METHOD
or Expression.EVALUATE_METHOD
or
Expression.PROCESS_METHOD
public Expression getScopingExpression()
getScopingExpression
in class Expression
public PathMap.PathMapNodeSet addToPathMap(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet)
The default implementation of this method assumes that an expression does no navigation other than the navigation done by evaluating its subexpressions, and that the subexpressions are evaluated in the same context as the containing expression. The method must be overridden for any expression where these assumptions do not hold. For example, implementations exist for AxisExpression, ParentExpression, and RootExpression (because they perform navigation), and for the doc(), document(), and collection() functions because they create a new navigation root. Implementations also exist for PathExpression and FilterExpression because they have subexpressions that are evaluated in a different context from the calling expression.
addToPathMap
in class Expression
pathMap
- the PathMap to which the expression should be addedpathMapNodeSet
- the PathMapNodeSet to which the paths embodied in this expression should be addedpublic SequenceIterator iterate(XPathContext c) throws XPathException
iterate
in class Expression
c
- the XPathContext which contains the relevant variable bindingsXPathException
- if the variable is undefinedpublic Item evaluateItem(XPathContext c) throws XPathException
Expression
evaluateItem
in class Expression
c
- The context in which the expression is to be evaluatedXPathException
- if any dynamic error occurs evaluating the
expressionpublic void process(XPathContext c) throws XPathException
Expression
process
in class Expression
c
- The dynamic context, giving access to the current node,
the current variables, etc.XPathException
- if a dynamic error occurspublic Sequence evaluateVariable(XPathContext c) throws XPathException
c
- the XPath dynamic contextXPathException
- if any error occurspublic Binding getBinding()
public java.lang.String getDisplayName()
public java.lang.String getEQName()
public java.lang.String toString()
toString
in class Expression
public java.lang.String toShortString()
toShortString
in class Expression
public java.lang.String getExpressionName()
getExpressionName
in class Expression
public void export(ExpressionPresenter destination) throws XPathException
export
in interface ExportAgent
export
in class Expression
destination
- the expression presenter used to display the structureXPathException
- if the export fails, for example if an expression is found that won't work
in the target environment.public java.lang.String getStreamerName()
getStreamerName
in class Expression
Copyright (c) 2004-2018 Saxonica Limited. All rights reserved.