org.basex.query.var
Class Variables

java.lang.Object
  extended by org.basex.data.ExprInfo
      extended by org.basex.query.var.Variables
All Implemented Interfaces:
java.lang.Iterable<StaticVar>

public final class Variables
extends ExprInfo
implements java.lang.Iterable<StaticVar>

Container of global variables of a module.

Author:
BaseX Team 2005-12, BSD License, Leo Woerteler

Field Summary
 java.util.HashMap<QNm,org.basex.query.var.Variables.VarEntry> vars
          The variables.
 
Constructor Summary
Variables()
           
 
Method Summary
 void bindExternal(QueryContext ctx, java.util.HashMap<QNm,Expr> bindings)
          Binds all external variables.
 void check(QueryContext ctx)
          Checks if all variables were declared and are visible to all their references.
 void checkUp()
          Checks if none of the variables contains an updating expression.
 StaticVar declare(QNm nm, SeqType t, Ann a, Expr e, boolean ext, StaticContext sctx, VarScope scp, java.lang.String xqdoc, InputInfo ii)
          Declares a new static variable.
 boolean declared(QNm nm)
          Checks if a variable with the given name was already declared.
 java.util.Iterator<StaticVar> iterator()
           
 StaticVarRef newRef(QNm nm, StaticContext sctx, InputInfo ii)
          returns a new reference to the (possibly not yet declared) variable with the given name.
 void plan(FElem plan)
          Creates an expression tree.
 java.lang.String toString()
           
 
Methods inherited from class org.basex.data.ExprInfo
addPlan, addPlan, description, info, planAttr, planElem
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

vars

public final java.util.HashMap<QNm,org.basex.query.var.Variables.VarEntry> vars
The variables.

Constructor Detail

Variables

public Variables()
Method Detail

declare

public StaticVar declare(QNm nm,
                         SeqType t,
                         Ann a,
                         Expr e,
                         boolean ext,
                         StaticContext sctx,
                         VarScope scp,
                         java.lang.String xqdoc,
                         InputInfo ii)
                  throws QueryException
Declares a new static variable.

Parameters:
nm - variable name
t - type
a - annotations
e - bound expression, possibly null
ext - external flag
sctx - static context
scp - variable scope
xqdoc - current xqdoc cache
ii - input info
Returns:
static variable reference
Throws:
QueryException - query exception

checkUp

public void checkUp()
             throws QueryException
Checks if none of the variables contains an updating expression.

Throws:
QueryException - query exception

check

public void check(QueryContext ctx)
           throws QueryException
Checks if all variables were declared and are visible to all their references.

Parameters:
ctx - query context
Throws:
QueryException - query exception

plan

public void plan(FElem plan)
Description copied from class: ExprInfo
Creates an expression tree.

Specified by:
plan in class ExprInfo
Parameters:
plan - root element

toString

public java.lang.String toString()
Specified by:
toString in class ExprInfo

declared

public boolean declared(QNm nm)
Checks if a variable with the given name was already declared.

Parameters:
nm - variable name
Returns:
result of check

newRef

public StaticVarRef newRef(QNm nm,
                           StaticContext sctx,
                           InputInfo ii)
                    throws QueryException
returns a new reference to the (possibly not yet declared) variable with the given name.

Parameters:
ii - input info
nm - variable name
sctx - static context
Returns:
reference
Throws:
QueryException - if the variable is not visible

bindExternal

public void bindExternal(QueryContext ctx,
                         java.util.HashMap<QNm,Expr> bindings)
                  throws QueryException
Binds all external variables.

Parameters:
ctx - query context
bindings - variable bindings
Throws:
QueryException - query exception

iterator

public java.util.Iterator<StaticVar> iterator()
Specified by:
iterator in interface java.lang.Iterable<StaticVar>