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

public final class Var
extends Expr

Variable.

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

Nested Class Summary
 
Nested classes/interfaces inherited from class org.basex.query.expr.Expr
Expr.Use
 
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)
          Constructor.
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.
 String color()
          Returns a color string for the expression.
 Var comp(QueryContext ctx)
          Optimizes and compiles the expression.
 Var copy()
          Returns a copy of the variable.
 boolean eq(Var v)
          Compares the variables for reference or name equality.
 Item item(QueryContext ctx)
          Evaluates the variable and returns the resulting item.
 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.
 String toString()
           
 boolean uses(Expr.Use u, QueryContext ctx)
          Indicates if an expression uses the specified type.
 boolean visible(Var v)
          Checks if the variable is not shadowed by the specified 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, v
 
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)
Constructor.

Parameters:
n - variable name

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 Var 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 - query 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 - query 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 - query 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 - query exception

item

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

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

eq

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

Parameters:
v - variable
Returns:
result of check

visible

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

Parameters:
v - variable
Returns:
result of check

copy

public Var copy()
Returns a copy of the variable.

Returns:
copied variable

uses

public boolean uses(Expr.Use u,
                    QueryContext ctx)
Description copied from class: Expr
Indicates if an expression uses the specified type. Called by the compiler to perform certain optimizations. true is returned by default and thus assumed as "worst-case".

Specified by:
uses in class Expr
Parameters:
u - use type to be checked
ctx - query context
Returns:
result of check

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 String color()
Description copied from class: ExprInfo
Returns a color string for the expression.

Overrides:
color in class ExprInfo
Returns:
color

plan

public void plan(Serializer ser)
          throws 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:
IOException - I/O exception

toString

public String toString()
Specified by:
toString in class ExprInfo