Package net.sf.saxon.expr
Class Assignation
- java.lang.Object
-
- net.sf.saxon.expr.ComputedExpression
-
- net.sf.saxon.expr.Assignation
-
- All Implemented Interfaces:
java.io.Serializable,javax.xml.transform.SourceLocator,Binding,Container,Expression,InstructionInfoProvider
- Direct Known Subclasses:
ForExpression,LetExpression,QuantifiedExpression
public abstract class Assignation extends ComputedExpression implements Binding
Assignation is an abstract superclass for the kinds of expression that declare range variables: for, some, and every.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Expressionactionprotected RangeVariableDeclarationdeclarationprotected intnameCodeprotected Expressionsequenceprotected intslotNumberprotected java.lang.StringvariableName-
Fields inherited from class net.sf.saxon.expr.ComputedExpression
locationId, staticProperties
-
Fields inherited from interface net.sf.saxon.expr.Expression
EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD
-
-
Constructor Summary
Constructors Constructor Description Assignation()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ValueRepresentationevaluateVariable(XPathContext context)Get the value of the range variableprotected Binding[]extendBindingList(Binding[] in)Extend an array of variable bindings to include the binding(s) defined in this expressionExpressiongetAction()Get the action expressionintgetLocalSlotNumber()If this is a local variable held on the local stack frame, return the corresponding slot number.intgetRequiredSlots()Get the number of slots required.ExpressiongetSequence()Get the "sequence" expression - the one to which the variable is boundRangeVariableDeclarationgetVariableDeclaration()Get the variable declarationintgetVariableFingerprint()java.lang.StringgetVariableName(NamePool pool)Get the display name of the range variable, for diagnostics onlyintgetVariableNameCode()booleanisAssignable()Test whether it is permitted to assign to the variable using the saxon:assign extension element.booleanisGlobal()Indicate whether the binding is local or global.java.util.IteratoriterateSubExpressions()Get the immediate subexpressions of this expressionExpressionpromote(PromotionOffer offer)Promote this expression if possibleprotected ExpressionpromoteWhereClause(Binding positionBinding)Promote a WHERE clause whose condition doesn't depend on the variable being bound.booleanreplaceSubExpression(Expression original, Expression replacement)Replace one subexpression by a replacement subexpressionvoidsetAction(Expression action)Add the "return" or "satisfies" expression, and fix up all references to the range variable that occur within that expressionvoidsetSequence(Expression sequence)Set the "sequence" expression - the one to which the variable is boundvoidsetSlotNumber(int nr)Set the slot number for the range variablevoidsetVariableDeclaration(RangeVariableDeclaration decl)Set the reference to the variable declarationExpressionsimplify(StaticContext env)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 net.sf.saxon.expr.ComputedExpression
adoptChildExpression, checkPermittedContents, computeCardinality, computeDependencies, computeSpecialProperties, computeStaticProperties, doPromotion, dynamicError, effectiveBooleanValue, evaluateAsString, evaluateItem, getCardinality, getColumnNumber, getConstructType, getDependencies, getExecutable, getHostLanguage, getImplementationMethod, getInstructionInfo, getIntrinsicDependencies, getLineNumber, getLocationId, getLocationProvider, getParentExpression, getPublicId, getSlotsUsed, getSpecialProperties, getSystemId, hasBadParentPointer, iterate, markTailFunctionCalls, process, resetStaticProperties, setLocationId, setParentExpression, setParentExpression, typeError
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.saxon.expr.Expression
display, getItemType, optimize, typeCheck
-
-
-
-
Field Detail
-
slotNumber
protected int slotNumber
-
sequence
protected Expression sequence
-
action
protected Expression action
-
variableName
protected java.lang.String variableName
-
nameCode
protected int nameCode
-
declaration
protected transient RangeVariableDeclaration declaration
-
-
Method Detail
-
setVariableDeclaration
public void setVariableDeclaration(RangeVariableDeclaration decl)
Set the reference to the variable declaration
-
getVariableDeclaration
public RangeVariableDeclaration getVariableDeclaration()
Get the variable declaration
-
setAction
public void setAction(Expression action)
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.This method must be called after calling setVariableDeclaration()
-
isGlobal
public final boolean isGlobal()
Indicate whether the binding is local or global. A global binding is one that has a fixed value for the life of a query or transformation; any other binding is local.
-
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
-
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
-
getAction
public Expression getAction()
Get the action expression
-
setSequence
public void setSequence(Expression sequence)
Set the "sequence" expression - the one to which the variable is bound
-
getSequence
public Expression getSequence()
Get the "sequence" expression - the one to which the variable is bound
-
setSlotNumber
public void setSlotNumber(int nr)
Set the slot number for the range variable
-
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.
-
simplify
public Expression simplify(StaticContext env) throws XPathException
Simplify the expression- Specified by:
simplifyin interfaceExpression- Overrides:
simplifyin classComputedExpression- Parameters:
env- the static context- Returns:
- the simplified expression
- Throws:
XPathException- if an error is discovered during expression rewriting
-
promote
public Expression promote(PromotionOffer offer) throws XPathException
Promote this expression if possible- Specified by:
promotein interfaceExpression- Overrides:
promotein classComputedExpression- 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 expression- 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 classComputedExpression
-
extendBindingList
protected Binding[] extendBindingList(Binding[] in)
Extend an array of variable bindings to include the binding(s) defined in this expression
-
promoteWhereClause
protected Expression promoteWhereClause(Binding positionBinding)
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 ()
-
iterateSubExpressions
public java.util.Iterator iterateSubExpressions()
Get the immediate subexpressions of this expression- Specified by:
iterateSubExpressionsin interfaceExpression- Overrides:
iterateSubExpressionsin classComputedExpression- Returns:
- an iterator containing the sub-expressions of this expression
-
replaceSubExpression
public boolean replaceSubExpression(Expression original, Expression replacement)
Replace one subexpression by a replacement subexpression- Specified by:
replaceSubExpressionin interfaceContainer- Overrides:
replaceSubExpressionin classComputedExpression- Parameters:
original- the original subexpressionreplacement- the replacement subexpression- Returns:
- true if the original subexpression is found
-
getVariableNameCode
public int getVariableNameCode()
-
getVariableFingerprint
public int getVariableFingerprint()
-
getVariableName
public java.lang.String getVariableName(NamePool pool)
Get the display name of the range variable, for diagnostics only
-
evaluateVariable
public ValueRepresentation evaluateVariable(XPathContext context) throws XPathException
Get the value of the range variable- Specified by:
evaluateVariablein interfaceBinding- Throws:
XPathException
-
-