Class Assignation
- All Implemented Interfaces:
Serializable, SourceLocator, LocationProvider, SaxonLocator, Binding, InstructionInfo, Locator
- Direct Known Subclasses:
ForExpression, LetExpression, QuantifiedExpression
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Expression(package private) intprotected SequenceTypeprotected Expressionprotected intprotected StructuredQName -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddReference(boolean isLoopingReference) Register a variable reference that refers to the variable bound in this expressionaddToPathMap(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet) Add a representation of this expression to a PathMap.voidCheck to ensure that this expression does not contain any inappropriate updating subexpressions.evaluateVariable(XPathContext context) Get the value of the range variableBinding[]extendBindingList(Binding[] in) Extend an array of variable bindings to include the binding(s) defined in this expressionGet the action expressionIf the variable is bound to an integer, get the minimum and maximum possible values.intIf this is a local variable held on the local stack frame, return the corresponding slot number.intGet the (nominal) count of the number of references to this variableGet a name identifying the object of the expression, for example a function name, template name, variable name, key name, element name, etc.intGet the number of slots required.Get the declared type of the variableGet the "sequence" expression - the one to which the variable is boundGet the display name of the range variable, for diagnostics onlyGet the name of the variablebooleanhasVariableBinding(Binding binding) final booleanTest whether it is permitted to assign to the variable using the saxon:assign extension element.final booleanisGlobal()Indicate whether the binding is local or global.booleanTest whether the variable bound by this let expression should be indexablebooleanDetermine whether this is an updating expression as defined in the XQuery update specificationGet the immediate subexpressions of this expressionpromote(PromotionOffer offer, Expression parent) Promote this expression if possibleprotected ExpressionpromoteWhereClause(Binding positionBinding) Promote a WHERE clause whose condition doesn't depend on the variable being bound.voidrefineTypeInformation(ItemType type, int cardinality, Value constantValue, int properties, ExpressionVisitor visitor, Assignation currentExpression) Refine the type information associated with this variable declaration.booleanreplaceSubExpression(Expression original, Expression replacement) Replace one subexpression by a replacement subexpressionvoidreplaceVariable(Optimizer opt, Expression seq) Replace all references to the variable bound by this let expression, that occur within the action expression, with the given expressionvoidsetAction(Expression action) Add the "return" or "satisfies" expression, and fix up all references to the range variable that occur within that expressionvoidIndicate that the variable bound by this let expression should be indexable (because it is used in an appropriate filter expression)voidsetRequiredType(SequenceType requiredType) Set the required type (declared type) of the variablevoidsetSequence(Expression sequence) Set the "sequence" expression - the one to which the variable is boundvoidsetSlotNumber(int nr) Set the slot number for the range variablevoidsetVariableQName(StructuredQName variableName) Set the name of the variablesimplify(ExpressionVisitor visitor) Simplify the expressionvoidsuppressValidation(int validationMode) Suppress validation on contained element constructors, on the grounds that the parent element is already performing validation.Methods inherited from class Expression
adoptChildExpression, checkPermittedContents, computeCardinality, computeDependencies, computeSpecialProperties, computeStaticProperties, copy, doPromotion, dynamicError, effectiveBooleanValue, evaluateAsString, evaluateItem, evaluatePendingUpdates, explain, explain, getCardinality, getColumnNumber, getColumnNumber, getConstructType, getContainer, getDependencies, getEvaluationMethod, getExecutable, getExpressionName, getHostLanguage, getImplementationMethod, getIntegerBounds, getIntrinsicDependencies, getItemType, getLineNumber, getLineNumber, getLocationId, getLocationProvider, getProperties, getProperty, getPublicId, getSlotsUsed, getSpecialProperties, getSystemId, getSystemId, hasLoopingSubexpression, implementsStaticTypeCheck, isSubtreeExpression, isVacuousExpression, iterate, iterateEvents, iterateSameFocusSubExpressions, markTailFunctionCalls, optimize, process, resetLocalStaticProperties, setContainer, setEvaluationMethod, setFiltered, setFlattened, setLocationId, staticTypeCheck, toString, typeCheck, typeError
-
Field Details
-
slotNumber
protected int slotNumber -
sequence
-
action
-
variableName
-
requiredType
-
refCount
int refCount
-
-
Constructor Details
-
Assignation
public Assignation()
-
-
Method Details
-
setRequiredType
Set the required type (declared type) of the variable- Parameters:
requiredType- the required type
-
setVariableQName
Set the name of the variable- Parameters:
variableName- the name of the variable
-
getVariableQName
Get the name of the variable- Specified by:
getVariableQNamein interfaceBinding- Returns:
- the variable name, as a QName
-
getObjectName
Description copied from interface:InstructionInfoGet a name identifying the object of the expression, for example a function name, template name, variable name, key name, element name, etc. This is used only where the name is known statically.- Specified by:
getObjectNamein interfaceInstructionInfo- Overrides:
getObjectNamein classExpression- Returns:
- the QName of the object declared or manipulated by this instruction or expression
-
getRequiredType
Get the declared type of the variable- Specified by:
getRequiredTypein interfaceBinding- Returns:
- the declared type
-
getIntegerBoundsForVariable
If the variable is bound to an integer, get the minimum and maximum possible values. Return null if unknown or not applicable- Specified by:
getIntegerBoundsForVariablein interfaceBinding- Returns:
- a pair of integers containing the minimum and maximum values for the integer value; or null if the value is not an integer or the range is unknown
-
getLocalSlotNumber
public int getLocalSlotNumber()If this is a local variable held on the local stack frame, return the corresponding slot number. In other cases, return -1.- Specified by:
getLocalSlotNumberin interfaceBinding- Returns:
- the slot number on the local stack frame
-
evaluateVariable
Get the value of the range variable- Specified by:
evaluateVariablein interfaceBinding- Parameters:
context- the XPath dynamic evaluation context- Returns:
- the result of evaluating the variable
- Throws:
XPathException- if an error occurs while evaluating the variable
-
setAction
Add the "return" or "satisfies" expression, and fix up all references to the range variable that occur within that expression- Parameters:
action- the expression that occurs after the "return" keyword of a "for" expression, the "satisfies" keyword of "some/every", or the ":=" operator of a "let" expression.
-
isGlobal
-
isAssignable
public final boolean isAssignable()Test whether it is permitted to assign to the variable using the saxon:assign extension element. This will only be for an XSLT global variable where the extra attribute saxon:assignable="yes" is present.- Specified by:
isAssignablein interfaceBinding- Returns:
- true if the binding is assignable
-
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 updateing subexpression
-
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
-
getAction
Get the action expression- Returns:
- the action expression (introduced by "return" or "satisfies")
-
setSequence
Set the "sequence" expression - the one to which the variable is bound- Parameters:
sequence- the expression to which the variable is bound
-
getSequence
Get the "sequence" expression - the one to which the variable is bound- Returns:
- the expression to which the variable is bound
-
setSlotNumber
public void setSlotNumber(int nr) Set the slot number for the range variable- Parameters:
nr- the slot number to be used
-
getRequiredSlots
public int getRequiredSlots()Get the number of slots required. Normally 1, except for a FOR expression with an AT clause, where it is 2.- Returns:
- the number of slots required
-
simplify
Simplify the expression- Overrides:
simplifyin classExpression- Parameters:
visitor- an expression visitor- Returns:
- the simplified expression
- Throws:
XPathException- if an error is discovered during expression rewriting
-
hasVariableBinding
- Overrides:
hasVariableBindingin classExpression
-
promote
Promote this expression if possible- Overrides:
promotein classExpression- Parameters:
offer- details of the offer, for example the offer to move expressions that don't depend on the context to an outer level in the containing expressionparent- the containing expression in the expression tree- Returns:
- if the offer is not accepted, return this expression unchanged. Otherwise return the result of rewriting the expression to promote this subexpression
- Throws:
XPathException- if any error is detected
-
suppressValidation
public void suppressValidation(int validationMode) Suppress validation on contained element constructors, on the grounds that the parent element is already performing validation. The default implementation does nothing.- Overrides:
suppressValidationin classExpression- Parameters:
validationMode- the kind of validation being performed on the parent expression
-
extendBindingList
-
promoteWhereClause
Promote a WHERE clause whose condition doesn't depend on the variable being bound. This rewrites an expression of the formlet $i := SEQ return if (C) then R else ()
to the form:
if (C) then (let $i := SEQ return R) else ()
- Parameters:
positionBinding- the binding of the position variable if any- Returns:
- an expression in which terms from the WHERE clause that can be extracted have been extracted
-
iterateSubExpressions
Get the immediate subexpressions of this expression- Overrides:
iterateSubExpressionsin classExpression- Returns:
- an iterator containing the sub-expressions of this expression
-
replaceSubExpression
Replace one subexpression by a replacement subexpression- Overrides:
replaceSubExpressionin classExpression- Parameters:
original- the original subexpressionreplacement- the replacement subexpression- Returns:
- true if the original subexpression is found
-
addToPathMap
Add a representation of this expression to a PathMap. The PathMap captures a map of the nodes visited by an expression in a source tree.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.
- Overrides:
addToPathMapin classExpression- Parameters:
pathMap- the PathMap to which the expression should be addedpathMapNodeSet- the PathMapNodeSet to which the paths embodied in this expression should be added- Returns:
- the pathMapNodeSet representing the points in the source document that are both reachable by this expression, and that represent possible results of this expression. For an expression that does navigation, it represents the end of the arc in the path map that describes the navigation route. For other expressions, it is the same as the input pathMapNode.
-
getVariableName
Get the display name of the range variable, for diagnostics only- Returns:
- the lexical QName of the range variable
-
refineTypeInformation
public void refineTypeInformation(ItemType type, int cardinality, Value constantValue, int properties, ExpressionVisitor visitor, Assignation currentExpression) Refine the type information associated with this variable declaration. This is useful when the type of the variable has not been explicitly declared (which is common); the variable then takes a static type based on the type of the expression to which it is bound. The effect of this call is to update the static expression type for all references to this variable.- Parameters:
type- the inferred item type of the expression to which the variable is boundcardinality- the inferred cardinality of the expression to which the variable is boundconstantValue- the constant value to which the variable is bound (null if there is no constant value)properties- other static properties of the expression to which the variable is boundvisitor- an expression visitor to provide context informationcurrentExpression- the expression that binds the variable
-
addReference
public void addReference(boolean isLoopingReference) Register a variable reference that refers to the variable bound in this expression- Specified by:
addReferencein interfaceBinding- Parameters:
isLoopingReference- - true if the reference occurs within a loop, such as the predicate of a filter expression
-
getNominalReferenceCount
public int getNominalReferenceCount()Get the (nominal) count of the number of references to this variable- Returns:
- zero if there are no references, one if there is a single reference that is not in a loop, some higher number if there are multiple references (or a single reference in a loop), or the special value @link RangeVariable#FILTERED} if there are any references in filter expressions that require searching.
-
isIndexedVariable
public boolean isIndexedVariable()Test whether the variable bound by this let expression should be indexable- Returns:
- true if the variable should be indexable
-
replaceVariable
Replace all references to the variable bound by this let expression, that occur within the action expression, with the given expression- Parameters:
opt- The optimizerseq- the expression- Throws:
XPathException
-
setIndexedVariable
public void setIndexedVariable()Indicate that the variable bound by this let expression should be indexable (because it is used in an appropriate filter expression)
-