Package net.sf.saxon.query
Class GlobalVariableDefinition
java.lang.Object
net.sf.saxon.query.GlobalVariableDefinition
- All Implemented Interfaces:
SourceLocator
,VariableDeclaration
,Declaration
- Direct Known Subclasses:
UndeclaredVariable
Class to hold compile-time information about an XQuery global variable
or parameter. Also used for system-generated global variables created by the optimizer,
whether in XSLT or XQuery.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncompile
(Executable exec, int slot) Create a compiled representation of this global variablevoid
Produce diagnostic output showing the compiled and optimized expression tree for a functionint
Get column numberGet the compiled variable if the definition has been compiledint
Get the line number where the declaration appearsGet public identifierGet the required type of the variableGet the system ID of the module containing the variable declarationGet the expression used to initialize the value of the variableGet the variable nameboolean
Ask whether this global variable is a "parameter" (an external variable, in XQuery terminology)boolean
Ask whether this global variable is privateIterate over the references to this variablevoid
Register a variable reference that refers to this global variablevoid
setIsParameter
(boolean b) Say 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
setPrivate
(boolean b) Say whether this global variable is a "parameter" (an external variable, in XQuery terminology)void
setRequiredType
(SequenceType type) Set the required type of the variablevoid
setSystemId
(String systemId) Set the system ID of the module where the variable declaration appearsvoid
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
-
Field Details
-
references
-
-
Constructor Details
-
GlobalVariableDefinition
public GlobalVariableDefinition()
-
-
Method Details
-
setRequiredType
Set the required type of the variable- Parameters:
type
- the declared type, from the "as" clause if present
-
getRequiredType
Get the required type of the variable- Returns:
- the declared type, from the "as" clause if present
-
setVariableQName
Set the variable name- Parameters:
qName
- the variable name
-
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 interfaceSourceLocator
-
getColumnNumber
public int getColumnNumber()Get column number- Specified by:
getColumnNumber
in interfaceSourceLocator
- Returns:
- -1 always
-
getPublicId
Get public identifier- Specified by:
getPublicId
in interfaceSourceLocator
- Returns:
- null always
-
setSystemId
Set the system ID of the module where the variable declaration appears- Parameters:
systemId
- the System ID (base URI)
-
getSystemId
Get the system ID of the module containing the variable declaration- Specified by:
getSystemId
in interfaceSourceLocator
- Returns:
- the System ID (base URI)
-
setValueExpression
Set the expression used to define the value of the variable- Parameters:
val
- the initializing expression
-
getValueExpression
Get the expression used to initialize the value of the variable- Returns:
- the initializing expression
-
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
-
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
-
isPrivate
public boolean isPrivate()Ask whether this global variable is private- Returns:
- true if this variable is private
-
setPrivate
public void setPrivate(boolean b) Say whether this global variable is a "parameter" (an external variable, in XQuery terminology)- Parameters:
b
- true if this variable is external
-
registerReference
Register a variable reference that refers to this global variable- Specified by:
registerReference
in interfaceVariableDeclaration
- Parameters:
ref
- the variable reference
-
iterateReferences
Iterate over the references to this variable- Returns:
- an iterator over the references: returns objects of class
VariableReference
-
compile
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.
-
typeCheck
Type check the compiled representation of this global variable- Parameters:
visitor
- an expression visitor- Throws:
XPathException
- if compile-time errors are found.
-
getCompiledVariable
Get the compiled variable if the definition has been compiled- Returns:
- the compiled global variable
-
explain
Produce diagnostic output showing the compiled and optimized expression tree for a function- Parameters:
out
- the destination to be used
-