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.Listreferences
-
Constructor Summary
Constructors Constructor Description GlobalVariableDefinition()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description GlobalVariablecompile(StaticQueryContext env, int slot)Create a compiled representation of this global variablevoidexplain(Configuration config)Produce diagnostic output showing the compiled and optimized expression tree for a functionintgetColumnNumber()Get column numberGlobalVariablegetCompiledVariable()Get the compiled variable if the definition has been compiledintgetLineNumber()Get the line number where the declaration appearsintgetNameCode()Get the variable namejava.lang.StringgetPublicId()Get public identifierSequenceTypegetRequiredType()Get the required type of the variablejava.lang.StringgetSystemId()Get the system ID of the module containing the variable declarationjava.lang.StringgetVariableName()Get the name of the variablejava.util.IteratoriterateReferences()Iterate over the references to this variablevoidregisterReference(BindingReference ref)Register a variable reference that refers to this global variablevoidsetIsParameter(boolean b)Indicate 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 sourcevoidsetNameCode(int nameCode)Set the variable namevoidsetRequiredType(SequenceType type)Set the required type of the variablevoidsetSystemId(java.lang.String systemId)Set the system ID of the module where the variable declaration appearsvoidsetValueExpression(Expression val)Set the expression used to define the value of the variablevoidsetVariableName(java.lang.String variableName)Set the variable namestatic voidtypeCheck(StaticQueryContext env, GeneralVariable var)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
-
setNameCode
public void setNameCode(int nameCode)
Set the variable name- Parameters:
nameCode- the variable name, expressed as a NamePool name code
-
getNameCode
public int getNameCode()
Get the variable name- Specified by:
getNameCodein interfaceVariableDeclaration- Returns:
- the variable name, expressed as a NamePool name code
-
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:
getLineNumberin interfacejavax.xml.transform.SourceLocator
-
getColumnNumber
public int getColumnNumber()
Get column number- Specified by:
getColumnNumberin interfacejavax.xml.transform.SourceLocator- Returns:
- -1 always
-
getPublicId
public java.lang.String getPublicId()
Get public identifier- Specified by:
getPublicIdin 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
-
getSystemId
public java.lang.String getSystemId()
Get the system ID of the module containing the variable declaration- Specified by:
getSystemIdin interfacejavax.xml.transform.SourceLocator
-
getVariableName
public java.lang.String getVariableName()
Get the name of the variable- Specified by:
getVariableNamein interfaceVariableDeclaration- Returns:
- the variable name, as a lexical QName
-
setVariableName
public void setVariableName(java.lang.String variableName)
Set the variable name- Parameters:
variableName- the variable name, as a lexical QName
-
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:
registerReferencein interfaceVariableDeclaration- Parameters:
ref- the variable reference
-
iterateReferences
public java.util.Iterator iterateReferences()
Iterate over the references to this variable
-
compile
public GlobalVariable compile(StaticQueryContext env, int slot) throws XPathException
Create a compiled representation of this global variable- Parameters:
env- the static context for the query moduleslot- the slot number allocated to this variable- Returns:
- the compiled representation
- Throws:
XPathException- if compile-time errors are found.
-
typeCheck
public static void typeCheck(StaticQueryContext env, GeneralVariable var) throws XPathException
Type check the compiled representation of this global variable- Parameters:
env- the static context for the query module- Throws:
XPathException- if compile-time errors are found.
-
getCompiledVariable
public GlobalVariable getCompiledVariable()
Get the compiled variable if the definition has been compiled
-
explain
public void explain(Configuration config)
Produce diagnostic output showing the compiled and optimized expression tree for a function- Parameters:
config- the configuration to be used
-
-