net.sf.saxon.expr

Class RangeVariableDeclaration

public class RangeVariableDeclaration extends Object implements VariableDeclaration

Represents the defining occurrence of a variable declared for local use within an expression, for example the $x in "for $x in ...". This object is used only at compile-time. In XQuery (but not in XSLT) this class is also used to represent the formal arguments of a function.
Field Summary
static intFILTERED
Method Summary
voidfixupReferences(Binding binding)
intgetNameCode()
Get the name of the variable, as a namepool name code
intgetReferenceCount(Binding binding, StaticContext env)
Determine how often the range variable is referenced.
static intgetReferenceCount(List references, Binding binding, StaticContext env, boolean removeUnbound)
Determine how often a variable is referenced.
ListgetReferenceList()
SequenceTypegetRequiredType()
Get the required type (declared type) of the variable
StringgetVariableName()
voidrefineTypeInformation(ItemType type, int cardinality, Value constantValue, int properties, StaticContext env)
voidregisterReference(BindingReference ref)
voidsetNameCode(int nameCode)
Set the name of the variable, as a namepool name code
voidsetReferenceList(List references)
voidsetRequiredType(SequenceType requiredType)
Set the required type (declared type) of the variable
voidsetVariableName(String variableName)

Field Detail

FILTERED

public static final int FILTERED

Method Detail

fixupReferences

public void fixupReferences(Binding binding)

getNameCode

public int getNameCode()
Get the name of the variable, as a namepool name code

Returns: the nameCode

getReferenceCount

public int getReferenceCount(Binding binding, StaticContext env)
Determine how often the range variable is referenced. This is the number of times it is referenced at run-time: so a reference in a loop counts as "many".

Parameters: binding the variable binding env

Returns: the number of references. The only interesting values are 0, 1, and "many" (represented by any value >1).

getReferenceCount

public static int getReferenceCount(List references, Binding binding, StaticContext env, boolean removeUnbound)
Determine how often a variable is referenced. This is the number of times it is referenced at run-time: so a reference in a loop counts as "many". This code currently handles local variables (Let expressions) and function parameters. It is not currently used for XSLT template parameters. It's not the end of the world if the answer is wrong (unless it's wrongly given as zero), but if wrongly returned as 1 then the variable will be repeatedly evaluated.

Parameters: references a list of references to a variable binding: each item in this list must be a VariableReference object binding the variable binding removeUnbound

Returns: the number of references. The interesting values are 0, 1, "many" (represented by any value >1), and the special value FILTERED, which indicates that there are multiple references and one or more of them is of the form $x[....] indicating that an index might be useful.

getReferenceList

public List getReferenceList()

getRequiredType

public SequenceType getRequiredType()
Get the required type (declared type) of the variable

Returns: the required type

getVariableName

public String getVariableName()

refineTypeInformation

public void refineTypeInformation(ItemType type, int cardinality, Value constantValue, int properties, StaticContext env)

registerReference

public void registerReference(BindingReference ref)

setNameCode

public void setNameCode(int nameCode)
Set the name of the variable, as a namepool name code

Parameters: nameCode

setReferenceList

public void setReferenceList(List references)

setRequiredType

public void setRequiredType(SequenceType requiredType)
Set the required type (declared type) of the variable

Parameters: requiredType the required type

setVariableName

public void setVariableName(String variableName)