net.sf.saxon.expr

Class VariableReference

public class VariableReference extends ComputedExpression implements BindingReference

Variable reference: a reference to a variable. This may be an XSLT-defined variable, a range variable defined within the XPath expression, or a variable defined in some other static context.
Field Summary
Bindingbinding
ValueconstantValue
StringdisplayName
SequenceTypestaticType
Constructor Summary
VariableReference(VariableDeclaration declaration)
Constructor
Method Summary
intcomputeCardinality()
Get the static cardinality
intcomputeSpecialProperties()
Determine the special properties of this expression
voiddisplay(int level, NamePool pool, PrintStream out)
Diagnostic print of expression structure
booleanequals(Object other)
Test if this expression is the same as another expression.
ItemevaluateItem(XPathContext c)
ValueRepresentationevaluateVariable(XPathContext c)
voidfixup(Binding binding)
Fix up this variable reference to a Binding object, which enables the value of the variable to be located at run-time.
BindinggetBinding()
Get the object bound to the variable
intgetImplementationMethod()
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().
intgetIntrinsicDependencies()
ItemTypegetItemType(TypeHierarchy th)
Determine the data type of the expression, if possible
inthashCode()
get HashCode for comparing two expressions
SequenceIteratoriterate(XPathContext c)
Get the value of this variable in a given context.
Expressionoptimize(Optimizer opt, StaticContext env, ItemType contextItemType)
Type-check the expression.
voidprocess(XPathContext c)
Expressionpromote(PromotionOffer offer)
Promote this expression if possible
voidsetStaticType(SequenceType type, Value value, int properties)
Set static type.
Expressionsimplify(StaticContext env)
Simplify the expression.
ExpressiontypeCheck(StaticContext env, ItemType contextItemType)
Type-check the expression.

Field Detail

binding

Binding binding

constantValue

Value constantValue

displayName

transient String displayName

staticType

SequenceType staticType

Constructor Detail

VariableReference

public VariableReference(VariableDeclaration declaration)
Constructor

Parameters: declaration the variable declaration to which this variable refers

Method Detail

computeCardinality

public int computeCardinality()
Get the static cardinality

computeSpecialProperties

public int computeSpecialProperties()
Determine the special properties of this expression

Returns: NON_CREATIVE (unless the variable is assignable using saxon:assign)

display

public void display(int level, NamePool pool, PrintStream out)
Diagnostic print of expression structure

equals

public boolean equals(Object other)
Test if this expression is the same as another expression. (Note, we only compare expressions that have the same static and dynamic context).

evaluateItem

public Item evaluateItem(XPathContext c)

evaluateVariable

public ValueRepresentation evaluateVariable(XPathContext c)

fixup

public void fixup(Binding binding)
Fix up this variable reference to a Binding object, which enables the value of the variable to be located at run-time.

getBinding

public Binding getBinding()
Get the object bound to the variable

getImplementationMethod

public int getImplementationMethod()
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process(). This method indicates which of these methods is provided. This implementation provides both all three methods natively.

getIntrinsicDependencies

public int getIntrinsicDependencies()

getItemType

public ItemType getItemType(TypeHierarchy th)
Determine the data type of the expression, if possible

Parameters: th

Returns: the type of the variable, if this can be determined statically; otherwise Type.ITEM (meaning not known in advance)

hashCode

public int hashCode()
get HashCode for comparing two expressions

iterate

public SequenceIterator iterate(XPathContext c)
Get the value of this variable in a given context.

Parameters: c the XPathContext which contains the relevant variable bindings

Returns: the value of the variable, if it is defined

Throws: XPathException if the variable is undefined

optimize

public Expression optimize(Optimizer opt, StaticContext env, ItemType contextItemType)
Type-check the expression. At this stage details of the static type must be known. If the variable has a compile-time value, this is substituted for the variable reference

process

public void process(XPathContext c)

promote

public Expression promote(PromotionOffer offer)
Promote this expression if possible

setStaticType

public void setStaticType(SequenceType type, Value value, int properties)
Set static type. This is a callback from the variable declaration object. As well as supplying the static type, it may also supply a compile-time value for the variable. As well as the type information, other static properties of the value are supplied: for example, whether the value is an ordered node-set.

simplify

public Expression simplify(StaticContext env)
Simplify the expression. Does nothing.

typeCheck

public Expression typeCheck(StaticContext env, ItemType contextItemType)
Type-check the expression. At this stage details of the static type must be known. If the variable has a compile-time value, this is substituted for the variable reference