public final class XPathVariable extends java.lang.Object implements LocalBinding
IndependentContext
.
Note that once declared, this object is thread-safe: it does not hold the actual variable
value, which means it can be used with any number of evaluations of a given XPath expression,
in series or in parallel.
A variable can be given a value by calling
XPathDynamicContext.setVariable(XPathVariable, net.sf.saxon.om.Sequence)
.
Note that the value of the variable is not held in the XPathVariable object, but in the
XPathDynamicContext, which means that the XPathVariable itself can be used in multiple threads.
Modifier and Type | Method and Description |
---|---|
void |
addReference(VariableReference ref,
boolean isLoopingReference)
Method called by the XPath expression parser to register a reference to this variable.
|
Sequence |
evaluateVariable(XPathContext context)
Get the value of the variable.
|
Sequence |
getDefaultValue()
Get the default value of the variable
|
IntegerValue[] |
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.
|
SequenceType |
getRequiredType()
Get the required type of this variable.
|
StructuredQName |
getVariableQName()
Get the name of the variable as a QNameValue.
|
boolean |
isAssignable()
Test whether it is permitted to assign to the variable using the saxon:assign
extension element.
|
boolean |
isGlobal()
Ask whether the binding is local or global.
|
boolean |
isIndexedVariable()
Ask whether the binding is to be indexed
|
protected static XPathVariable |
make(StructuredQName name)
Factory method, for use by the declareVariable method of class IndependentContext
|
void |
setDefaultValue(Sequence defaultValue)
Set a default value for the variable, to be used if no specific value is
supplied when the expression is evaluated
|
void |
setIndexedVariable()
Say that the bound value has the potential to be indexed
|
void |
setRequiredType(SequenceType requiredType)
Set the required type of this variable.
|
void |
setSlotNumber(int slotNumber)
Set the slot number allocated to this variable.
|
protected static XPathVariable make(StructuredQName name)
name
- the name of the variable to createpublic boolean isGlobal()
public final boolean isAssignable()
isAssignable
in interface Binding
public void setRequiredType(SequenceType requiredType)
item()*
is assumed.requiredType
- the required typepublic SequenceType getRequiredType()
item()*
is returned.getRequiredType
in interface Binding
public IntegerValue[] getIntegerBoundsForVariable()
getIntegerBoundsForVariable
in interface Binding
public void setSlotNumber(int slotNumber)
slotNumber
- the slot number to be allocatedpublic int getLocalSlotNumber()
getLocalSlotNumber
in interface LocalBinding
public StructuredQName getVariableQName()
getVariableQName
in interface Binding
public void addReference(VariableReference ref, boolean isLoopingReference)
addReference
in interface Binding
ref
- the variable referenceisLoopingReference
- - true if the reference occurs within a loop, such as the predicate
of a filter expressionpublic void setDefaultValue(Sequence defaultValue)
defaultValue
- the default value for the variablepublic Sequence getDefaultValue()
public Sequence evaluateVariable(XPathContext context)
evaluateVariable
in interface Binding
context
- The dynamic evaluation contextpublic void setIndexedVariable()
setIndexedVariable
in interface LocalBinding
public boolean isIndexedVariable()
isIndexedVariable
in interface LocalBinding
Copyright (c) 2004-2018 Saxonica Limited. All rights reserved.