org.basex.query.util
Class Var

java.lang.Object
  extended by org.basex.query.ExprInfo
      extended by org.basex.query.expr.Expr
          extended by org.basex.query.util.Var
All Implemented Interfaces:
java.lang.Cloneable

public final class Var
extends Expr
implements java.lang.Cloneable

Variable.

Author:
Workgroup DBIS, University of Konstanz 2005-09, ISC License, Christian Gruen

Field Summary
 Expr expr
          Variable expressions.
 boolean global
          Global flag.
 Item item
          Variable results.
 QNm name
          Variable name.
 Return ret
          Return type.
 SeqType type
          Data type.
 
Constructor Summary
Var(QNm n, boolean g)
          Constructor.
Var(QNm n, SeqType t, boolean g)
          Constructor.
 
Method Summary
 Var bind(Expr e, QueryContext ctx)
          Binds the specified expression to the variable.
 Var bind(Item it, QueryContext ctx)
          Binds the specified item to the variable.
 Var clone()
           
 java.lang.String color()
          Returns a string description of the expression.
 Expr comp(QueryContext ctx)
          Optimizes and compiles the expression.
 boolean eq(Var v)
          Compares the variables for name equality.
 Item item(QueryContext ctx)
          Evaluates the variable.
 Iter iter(QueryContext ctx)
          Evaluates the expression and returns an iterator on the resulting items.
 void plan(Serializer ser)
          Recursively sends the abstract syntax of this expression to the specified serializer.
 Return returned(QueryContext ctx)
          Indicates the return type of an expression.
 java.lang.String toString()
           
 boolean visible(Var v)
          Checks if the variable is not shadowed by the variable.
 
Methods inherited from class org.basex.query.expr.Expr
addText, atomic, checkCtx, checkDbl, checkItr, duplicates, e, ebv, i, indexAccessible, indexEquivalent, removable, remove, sameAs, size, test, uses
 
Methods inherited from class org.basex.query.ExprInfo
info, name
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ret

public Return ret
Return type.


global

public final boolean global
Global flag.


name

public final QNm name
Variable name.


type

public SeqType type
Data type.


expr

public Expr expr
Variable expressions.


item

public Item item
Variable results.

Constructor Detail

Var

public Var(QNm n,
           boolean g)
Constructor.

Parameters:
n - variable name
g - global flag

Var

public Var(QNm n,
           SeqType t,
           boolean g)
Constructor.

Parameters:
n - variable name
t - data type
g - global flag
Method Detail

comp

public Expr comp(QueryContext ctx)
          throws QueryException
Description copied from class: Expr
Optimizes and compiles the expression.

Specified by:
comp in class Expr
Parameters:
ctx - query context
Returns:
optimized Expression
Throws:
QueryException - evaluation exception

bind

public Var bind(Expr e,
                QueryContext ctx)
         throws QueryException
Binds the specified expression to the variable.

Parameters:
e - expression to be set
ctx - query context
Returns:
self reference
Throws:
QueryException - evaluation exception

bind

public Var bind(Item it,
                QueryContext ctx)
         throws QueryException
Binds the specified item to the variable.

Parameters:
it - item to be set
ctx - query context
Returns:
self reference
Throws:
QueryException - evaluation exception

iter

public Iter iter(QueryContext ctx)
          throws QueryException
Description copied from class: Expr
Evaluates the expression and returns an iterator on the resulting items. If this method is not overwritten, Expr.atomic(org.basex.query.QueryContext) must be implemented.

Overrides:
iter in class Expr
Parameters:
ctx - query context
Returns:
resulting item
Throws:
QueryException - evaluation exception

item

public Item item(QueryContext ctx)
          throws QueryException
Evaluates the variable.

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

eq

public boolean eq(Var v)
Compares the variables for name equality.

Parameters:
v - variable
Returns:
result of check

visible

public boolean visible(Var v)
Checks if the variable is not shadowed by the variable.

Parameters:
v - variable
Returns:
result of check

clone

public Var clone()
Overrides:
clone in class java.lang.Object

returned

public Return returned(QueryContext ctx)
Description copied from class: Expr
Indicates the return type of an expression. Called by the compiler to check if expressions can be reformulated. null is returned by default.

Overrides:
returned in class Expr
Parameters:
ctx - query context
Returns:
result of check

color

public java.lang.String color()
Description copied from class: ExprInfo
Returns a string description of the expression. Contrary to the ExprInfo.toString() method, the current expressions aren't included in the output.

Overrides:
color in class ExprInfo
Returns:
result of check

plan

public void plan(Serializer ser)
          throws java.io.IOException
Description copied from class: ExprInfo
Recursively sends the abstract syntax of this expression to the specified serializer.

Specified by:
plan in class ExprInfo
Parameters:
ser - serializer
Throws:
java.io.IOException - exception

toString

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