Package net.sf.saxon.expr
Class RangeVariableDeclaration
- java.lang.Object
-
- net.sf.saxon.expr.RangeVariableDeclaration
-
- All Implemented Interfaces:
VariableDeclaration
public class RangeVariableDeclaration extends java.lang.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
Fields Modifier and Type Field Description static int
FILTERED
-
Constructor Summary
Constructors Constructor Description RangeVariableDeclaration()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
allReferencesAreStrings()
Determine whether all references to this variable are using the value as a stringvoid
fixupReferences(Binding binding)
int
getNameCode()
Get the name of the variable, as a namepool name codestatic int
getReferenceCount(java.util.List references, Binding binding, StaticContext env, boolean removeUnbound)
Determine how often a variable is referenced.int
getReferenceCount(Binding binding, StaticContext env)
Determine how often the range variable is referenced.java.util.List
getReferenceList()
SequenceType
getRequiredType()
Get the required type (declared type) of the variablejava.lang.String
getVariableName()
Get the name of the variable for use in diagnostics - a lexical QNamevoid
refineTypeInformation(ItemType type, int cardinality, Value constantValue, int properties, StaticContext env)
void
registerReference(BindingReference ref)
Method called by a BindingReference to register the variable reference for subsequent fixup.void
setNameCode(int nameCode)
Set the name of the variable, as a namepool name codevoid
setReferenceList(java.util.List references)
void
setRequiredType(SequenceType requiredType)
Set the required type (declared type) of the variablevoid
setVariableName(java.lang.String variableName)
-
-
-
Field Detail
-
FILTERED
public static final int FILTERED
- See Also:
- Constant Field Values
-
-
Method Detail
-
setNameCode
public void setNameCode(int nameCode)
Set the name of the variable, as a namepool name code- Parameters:
nameCode
-
-
getNameCode
public int getNameCode()
Get the name of the variable, as a namepool name code- Specified by:
getNameCode
in interfaceVariableDeclaration
- Returns:
- the nameCode
-
getRequiredType
public SequenceType getRequiredType()
Get the required type (declared type) of the variable- Returns:
- the required type
-
setRequiredType
public void setRequiredType(SequenceType requiredType)
Set the required type (declared type) of the variable- Parameters:
requiredType
- the required type
-
setVariableName
public void setVariableName(java.lang.String variableName)
-
getVariableName
public java.lang.String getVariableName()
Description copied from interface:VariableDeclaration
Get the name of the variable for use in diagnostics - a lexical QName- Specified by:
getVariableName
in interfaceVariableDeclaration
-
registerReference
public void registerReference(BindingReference ref)
Description copied from interface:VariableDeclaration
Method called by a BindingReference to register the variable reference for subsequent fixup. This method is called by the XPath parser when each reference to the variable is encountered. At some time after parsing and before execution of the expression, the VariableDeclaration is responsible for calling the two methods setStaticType() and fixup() on each BindingReference that has been registered with it.- Specified by:
registerReference
in interfaceVariableDeclaration
-
setReferenceList
public void setReferenceList(java.util.List references)
-
getReferenceList
public java.util.List getReferenceList()
-
allReferencesAreStrings
public boolean allReferencesAreStrings()
Determine whether all references to this variable are using the value as a string
-
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 bindingenv
-- Returns:
- the number of references. The only interesting values are 0, 1, and "many" (represented by any value >1).
-
getReferenceCount
public static int getReferenceCount(java.util.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 objectbinding
- the variable bindingremoveUnbound
-- 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.
-
fixupReferences
public void fixupReferences(Binding binding)
-
refineTypeInformation
public void refineTypeInformation(ItemType type, int cardinality, Value constantValue, int properties, StaticContext env)
-
-