## net.sf.saxon.query
Class GlobalVariableDefinition

    java.lang.Object
      net.sf.saxon.query.GlobalVariableDefinition

All Implemented Interfaces:
  VariableDeclaration

public class GlobalVariableDefinition
extends java.lang.Object
implements VariableDeclaration

Class to hold compile-time information about an XQuery global variable or parameter

Constructor Summary
`GlobalVariableDefinition()`

Method Summary
`GeneralVariable` `compile(StaticQueryContext env, int slot)` Create a compiled representation of this global variable
`void` `explain(NamePool pool)` Produce diagnostic output showing the compiled and optimized expression tree for a function
`int` `getNameCode()` Get the variable name
`SequenceType` `getRequiredType()` Get the required type of the variable
`java.lang.String` `getVariableName()` Get the name of the variable
`void` `registerReference(BindingReference ref)` Register a variable reference that refers to this global variable
`void` `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 source
`void` `setNameCode(int nameCode)` Set the variable name
`void` `setRequiredType(SequenceType type)` Set the required type of the variable
`void` `setValueExpression(Expression val)` Set the expression used to define the value of the variable
`void` `setVariableName(java.lang.String variableName)` Set the variable name

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### GlobalVariableDefinition

    public GlobalVariableDefinition()

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:
    `getNameCode` in interface `VariableDeclaration`
  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

### getVariableName

    public java.lang.String getVariableName()

  Get the name of the variable

  Specified by:
    `getVariableName` in interface `VariableDeclaration`
  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:
    `registerReference` in interface `VariableDeclaration`
  Parameters:
    `ref` - the variable reference

### compile

    public GeneralVariable compile(StaticQueryContext env,
                                   int slot)
                            throws XPathException

  Create a compiled representation of this global variable

  Parameters:
    `env` - the static context for the query module
    `slot` - the slot number allocated to this variable
  Returns:
    the compiled representation
  Throws:
    `XPathException` - if compile-time errors are found.

### explain

    public void explain(NamePool pool)

  Produce diagnostic output showing the compiled and optimized expression tree for a function

  Parameters:
    `pool` - the namepool to be used