Package net.sf.saxon.expr.flwor
Class LocalVariableBinding
- java.lang.Object
-
- net.sf.saxon.expr.flwor.LocalVariableBinding
-
- All Implemented Interfaces:
Binding
,LocalBinding
public class LocalVariableBinding extends java.lang.Object implements LocalBinding
Represents the defining occurrence of a variable declared within a FLWOR expression, for example the $p in "for $x at $p in ...". Also used for the variables bound to the context item in a pattern that uses current()
-
-
Constructor Summary
Constructors Constructor Description LocalVariableBinding(StructuredQName name, SequenceType type)
Create a LocalVariableBinding
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addReference(VariableReference ref, boolean isLoopingReference)
Register a variable reference that refers to the variable bound in this expressionLocalVariableBinding
copy()
Make a copy of this LocalVariableBinding (except for the slot number)Sequence
evaluateVariable(XPathContext context)
Get the value of the range variableIntegerValue[]
getIntegerBoundsForVariable()
If the variable is bound to an integer, get the minimum and maximum possible values.int
getLocalSlotNumber()
If this is a local variable held on the local stack frame, return the corresponding slot number.int
getNominalReferenceCount()
Get the (nominal) count of the number of references to this variableSequenceType
getRequiredType()
Get the required type (declared type) of the variableStructuredQName
getVariableQName()
Get the name of the variableboolean
isAssignable()
Test whether it is permitted to assign to the variable using the saxon:assign extension element.boolean
isGlobal()
Indicate whether the binding is local or global.boolean
isIndexedVariable()
Ask whether the binding is to be indexedvoid
setIndexedVariable()
Indicate that the variable bound by this let expression should be indexable (because it is used in an appropriate filter expression)void
setRequiredType(SequenceType type)
Set the required or inferred type of the variablevoid
setSlotNumber(int nr)
Set the slot number for the range variablevoid
setVariableQName(StructuredQName variableName)
Set the name of the variable
-
-
-
Constructor Detail
-
LocalVariableBinding
public LocalVariableBinding(StructuredQName name, SequenceType type)
Create a LocalVariableBinding- Parameters:
name
- the name of the variabletype
- the static type of the variable
-
-
Method Detail
-
copy
public LocalVariableBinding copy()
Make a copy of this LocalVariableBinding (except for the slot number)- Returns:
- a copy of the binding
-
getVariableQName
public StructuredQName getVariableQName()
Get the name of the variable- Specified by:
getVariableQName
in interfaceBinding
- Returns:
- the name of the variable
-
setRequiredType
public void setRequiredType(SequenceType type)
Set the required or inferred type of the variable- Parameters:
type
- the required or inferred type
-
getRequiredType
public SequenceType getRequiredType()
Get the required type (declared type) of the variable- Specified by:
getRequiredType
in interfaceBinding
- Returns:
- the required type
-
getIntegerBoundsForVariable
public IntegerValue[] 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:
getIntegerBoundsForVariable
in 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
-
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.
-
addReference
public void addReference(VariableReference ref, boolean isLoopingReference)
Register a variable reference that refers to the variable bound in this expression- Specified by:
addReference
in interfaceBinding
- Parameters:
ref
- the variable referenceisLoopingReference
- - true if the reference occurs within a loop, such as the predicate of a filter expression
-
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)- Specified by:
setIndexedVariable
in interfaceLocalBinding
-
isIndexedVariable
public boolean isIndexedVariable()
Description copied from interface:LocalBinding
Ask whether the binding is to be indexed- Specified by:
isIndexedVariable
in interfaceLocalBinding
- Returns:
- true if the variable value can be indexed
-
setVariableQName
public void setVariableQName(StructuredQName variableName)
Set the name of the variable- Parameters:
variableName
- the name of the variable
-
setSlotNumber
public void setSlotNumber(int nr)
Set the slot number for the range variable- Parameters:
nr
- the slot number to be used
-
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:
getLocalSlotNumber
in interfaceLocalBinding
- Returns:
- the slot number on the local stack frame
-
evaluateVariable
public Sequence evaluateVariable(XPathContext context)
Get the value of the range variable- Specified by:
evaluateVariable
in interfaceBinding
- Parameters:
context
- the XPath dynamic evaluation context- Returns:
- the result of evaluating the variable
-
isAssignable
public 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:
isAssignable
in interfaceBinding
- Returns:
- true if the binding is assignable
-
-