Package net.sf.saxon.query
Class GlobalVariableDefinition
- java.lang.Object
-
- net.sf.saxon.query.GlobalVariableDefinition
-
- All Implemented Interfaces:
javax.xml.transform.SourceLocator
,VariableDeclaration
,Declaration
- Direct Known Subclasses:
UndeclaredVariable
public class GlobalVariableDefinition extends java.lang.Object implements VariableDeclaration, Declaration
Class to hold compile-time information about an XQuery global variable or parameter
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List
references
-
Constructor Summary
Constructors Constructor Description GlobalVariableDefinition()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GlobalVariable
compile(Executable exec, int slot)
Create a compiled representation of this global variablevoid
explain(ExpressionPresenter out)
Produce diagnostic output showing the compiled and optimized expression tree for a functionvoid
fixupReference(BindingReference ref, TypeHierarchy th)
Notify a reference to this variable of the data typeint
getColumnNumber()
Get column numberGlobalVariable
getCompiledVariable()
Get the compiled variable if the definition has been compiledint
getLineNumber()
Get the line number where the declaration appearsjava.lang.String
getPublicId()
Get public identifierSequenceType
getRequiredType()
Get the required type of the variablejava.lang.String
getSystemId()
Get the system ID of the module containing the variable declarationStructuredQName
getVariableQName()
Get the variable namejava.util.Iterator
iterateReferences()
Iterate over the references to this variablevoid
registerReference(BindingReference ref)
Register a variable reference that refers to this global variablevoid
setIsParameter(boolean b)
Indicate whether this global variable is a "parameter" (an external variable, in XQuery terminology)void
setLineNumber(int lineNumber)
Set the line number where the variable declaration appears in the sourcevoid
setRequiredType(SequenceType type)
Set the required type of the variablevoid
setSystemId(java.lang.String systemId)
Set the system ID of the module where the variable declaration appearsvoid
setValueExpression(Expression val)
Set the expression used to define the value of the variablevoid
setVariableQName(StructuredQName qName)
Set the variable namevoid
typeCheck(ExpressionVisitor visitor)
Type check the compiled representation of this global variable
-
-
-
Method Detail
-
setRequiredType
public void setRequiredType(SequenceType type)
Set the required type of the variable- Parameters:
type
- the declared type, from the "as" clause if present
-
getRequiredType
public SequenceType getRequiredType()
Get the required type of the variable- Returns:
- the declared type, from the "as" clause if present
-
setVariableQName
public void setVariableQName(StructuredQName qName)
Set the variable name- Parameters:
qName
- the variable name
-
getVariableQName
public StructuredQName getVariableQName()
Get the variable name- Specified by:
getVariableQName
in interfaceVariableDeclaration
- Returns:
- the variable name
-
setLineNumber
public void setLineNumber(int lineNumber)
Set the line number where the variable declaration appears in the source- Parameters:
lineNumber
- the line number
-
getLineNumber
public int getLineNumber()
Get the line number where the declaration appears- Specified by:
getLineNumber
in interfacejavax.xml.transform.SourceLocator
-
getColumnNumber
public int getColumnNumber()
Get column number- Specified by:
getColumnNumber
in interfacejavax.xml.transform.SourceLocator
- Returns:
- -1 always
-
getPublicId
public java.lang.String getPublicId()
Get public identifier- Specified by:
getPublicId
in interfacejavax.xml.transform.SourceLocator
- Returns:
- null always
-
setSystemId
public void setSystemId(java.lang.String systemId)
Set the system ID of the module where the variable declaration appears- Parameters:
systemId
- the System ID (base URI)
-
getSystemId
public java.lang.String getSystemId()
Get the system ID of the module containing the variable declaration- Specified by:
getSystemId
in interfacejavax.xml.transform.SourceLocator
- Returns:
- 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
-
setIsParameter
public void setIsParameter(boolean b)
Indicate whether this global variable is a "parameter" (an external variable, in XQuery terminology)- Parameters:
b
- true if this variable is external
-
registerReference
public void registerReference(BindingReference ref)
Register a variable reference that refers to this global variable- Specified by:
registerReference
in interfaceVariableDeclaration
- Parameters:
ref
- the variable reference
-
iterateReferences
public java.util.Iterator iterateReferences()
Iterate over the references to this variable- Returns:
- an iterator over the references: returns objects of class
VariableReference
-
compile
public GlobalVariable compile(Executable exec, int slot) throws XPathException
Create a compiled representation of this global variable- Parameters:
exec
- the executableslot
- the slot number allocated to this variable- Returns:
- the compiled representation
- Throws:
XPathException
- if compile-time errors are found.
-
fixupReference
public void fixupReference(BindingReference ref, TypeHierarchy th) throws XPathException
Notify a reference to this variable of the data type- Parameters:
ref
- the variable referenceth
- the type hierarchy cache- Throws:
XPathException
-
typeCheck
public void typeCheck(ExpressionVisitor visitor) throws XPathException
Type check the compiled representation of this global variable- Parameters:
visitor
- an expression visitor- Throws:
XPathException
- if compile-time errors are found.
-
getCompiledVariable
public GlobalVariable getCompiledVariable()
Get the compiled variable if the definition has been compiled- Returns:
- the compiled global variable
-
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
-
-