org.basex.query.expr
Class TypeSwitch

java.lang.Object
  extended by org.basex.query.ExprInfo
      extended by org.basex.query.expr.Expr
          extended by org.basex.query.expr.TypeSwitch

public final class TypeSwitch
extends Expr

Typeswitch expression.

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
 Case[] cs
          Expression list.
 
Constructor Summary
TypeSwitch(Expr t, Case[] c)
          Constructor.
 
Method Summary
 Expr comp(QueryContext ctx)
          Optimizes and compiles the expression.
 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.
 Expr remove(Var v)
          Removes the specified variable in a sub expression.
 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.
 
Methods inherited from class org.basex.query.expr.Expr
addText, atomic, checkCtx, checkDbl, checkItr, duplicates, e, ebv, i, indexAccessible, indexEquivalent, removable, sameAs, size, test, v
 
Methods inherited from class org.basex.query.ExprInfo
color, info, name
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

cs

public Case[] cs
Expression list.

Constructor Detail

TypeSwitch

public TypeSwitch(Expr t,
                  Case[] c)
Constructor.

Parameters:
t - typeswitch expression
c - case expressions
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 - 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

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

remove

public Expr remove(Var v)
Description copied from class: Expr
Removes the specified variable in a sub expression.

Overrides:
remove in class Expr
Parameters:
v - variable to be removed
Returns:
expression with removed variable

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

toString

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

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