net.sf.saxon.query

Class GlobalVariableDefinition

public class GlobalVariableDefinition extends Object implements VariableDeclaration, Declaration

Class to hold compile-time information about an XQuery global variable or parameter
Field Summary
protected Listreferences
Method Summary
GlobalVariablecompile(Executable exec, int slot)
Create a compiled representation of this global variable
voidexplain(ExpressionPresenter out)
Produce diagnostic output showing the compiled and optimized expression tree for a function
intgetColumnNumber()
Get column number
GlobalVariablegetCompiledVariable()
Get the compiled variable if the definition has been compiled
intgetLineNumber()
Get the line number where the declaration appears
StringgetPublicId()
Get public identifier
SequenceTypegetRequiredType()
Get the required type of the variable
StringgetSystemId()
Get the system ID of the module containing the variable declaration
ExpressiongetValueExpression()
Get the expression used to initialize the value of the variable
StructuredQNamegetVariableQName()
Get the variable name
booleanisParameter()
Ask whether this global variable is a "parameter" (an external variable, in XQuery terminology)
IteratoriterateReferences()
Iterate over the references to this variable
voidregisterReference(BindingReference ref)
Register a variable reference that refers to this global variable
voidsetIsParameter(boolean b)
Say whether this global variable is a "parameter" (an external variable, in XQuery terminology)
voidsetLineNumber(int lineNumber)
Set the line number where the variable declaration appears in the source
voidsetRequiredType(SequenceType type)
Set the required type of the variable
voidsetSystemId(String systemId)
Set the system ID of the module where the variable declaration appears
voidsetValueExpression(Expression val)
Set the expression used to define the value of the variable
voidsetVariableQName(StructuredQName qName)
Set the variable name
voidtypeCheck(ExpressionVisitor visitor)
Type check the compiled representation of this global variable

Field Detail

references

protected List references

Method Detail

compile

public GlobalVariable compile(Executable exec, int slot)
Create a compiled representation of this global variable

Parameters: exec the executable slot the slot number allocated to this variable

Returns: the compiled representation

Throws: XPathException if compile-time errors are found.

explain

public void explain(ExpressionPresenter out)
Produce diagnostic output showing the compiled and optimized expression tree for a function

Parameters: out the destination to be used

getColumnNumber

public int getColumnNumber()
Get column number

Returns: -1 always

getCompiledVariable

public GlobalVariable getCompiledVariable()
Get the compiled variable if the definition has been compiled

Returns: the compiled global variable

getLineNumber

public int getLineNumber()
Get the line number where the declaration appears

getPublicId

public String getPublicId()
Get public identifier

Returns: null always

getRequiredType

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

Returns: the declared type, from the "as" clause if present

getSystemId

public String getSystemId()
Get the system ID of the module containing the variable declaration

Returns: the System ID (base URI)

getValueExpression

public Expression getValueExpression()
Get the expression used to initialize the value of the variable

Returns: the initializing expression

getVariableQName

public StructuredQName getVariableQName()
Get the variable name

Returns: the variable name

isParameter

public boolean isParameter()
Ask whether this global variable is a "parameter" (an external variable, in XQuery terminology)

Returns: true if this variable is an external variable

iterateReferences

public Iterator iterateReferences()
Iterate over the references to this variable

Returns: an iterator over the references: returns objects of class VariableReference

registerReference

public void registerReference(BindingReference ref)
Register a variable reference that refers to this global variable

Parameters: ref the variable reference

setIsParameter

public void setIsParameter(boolean b)
Say whether this global variable is a "parameter" (an external variable, in XQuery terminology)

Parameters: b true if this variable is external

setLineNumber

public void setLineNumber(int lineNumber)
Set the line number where the variable declaration appears in the source

Parameters: lineNumber the line number

setRequiredType

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

Parameters: type the declared type, from the "as" clause if present

setSystemId

public void setSystemId(String systemId)
Set the system ID of the module where the variable declaration appears

Parameters: systemId the System ID (base URI)

setValueExpression

public void setValueExpression(Expression val)
Set the expression used to define the value of the variable

Parameters: val the initializing expression

setVariableQName

public void setVariableQName(StructuredQName qName)
Set the variable name

Parameters: qName the variable name

typeCheck

public void typeCheck(ExpressionVisitor visitor)
Type check the compiled representation of this global variable

Parameters: visitor an expression visitor

Throws: XPathException if compile-time errors are found.