org.basex.query.expr
Class SwitchCase

java.lang.Object
  extended by org.basex.data.ExprInfo
      extended by org.basex.query.expr.Expr
          extended by org.basex.query.expr.ParseExpr
              extended by org.basex.query.expr.Arr
                  extended by org.basex.query.expr.SwitchCase

public final class SwitchCase
extends Arr

Single case of a switch expression.

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Nested Class Summary
 
Nested classes/interfaces inherited from class org.basex.query.expr.Expr
Expr.Flag
 
Field Summary
 
Fields inherited from class org.basex.query.expr.Arr
expr
 
Fields inherited from class org.basex.query.expr.ParseExpr
info, size, type
 
Constructor Summary
SwitchCase(InputInfo ii, Expr... e)
          Constructor.
 
Method Summary
 void checkUp()
          Checks if all updating expressions are correctly placed.
 Expr compile(QueryContext ctx, VarScope scp)
          Compiles and optimizes the expression, assigns data types and cardinalities.
 Expr copy(QueryContext ctx, VarScope scp, IntObjMap<Var> vs)
          Copies an expression.
 VarUsage count(Var v)
          Checks how often a variable is used in this expression.
protected  VarUsage countCases(Var v)
          Checks how often a variable is used in this expression.
 int exprSize()
          Counts the number of expressions in this expression's sub-tree.
 Expr inline(QueryContext ctx, VarScope scp, Var v, Expr e)
          Inlines an expression into this one, replacing all references to the given variable.
 java.lang.String toString()
           
 
Methods inherited from class org.basex.query.expr.Arr
accept, allAreValues, checkNoUp, copyAll, has, indexEquivalent, plan, removable, toString
 
Methods inherited from class org.basex.query.expr.ParseExpr
checkAdmin, checkAllUp, checkBinary, checkBln, checkColl, checkCreate, checkCtx, checkDbl, checkDBNode, checkEStr, checkEStr, checkFunc, checkItem, checkItr, checkItr, checkMap, checkNode, checkNode, checkNode, checkNoEmpty, checkNoneUp, checkNoUp, checkQNm, checkStr, checkStr, checkStrBin, checkType, checkWrite, compBln, copyType, ebv, item, iter, optPre, preEval, size, test, type, value
 
Methods inherited from class org.basex.query.expr.Expr
addText, compEbv, copy, hasFreeVars, indexAccessible, inlineAll, isEmpty, isFunction, isItem, isVacuous, isValue, iterable, markTailCalls, optimize, sameAs, uses, visitAll
 
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
 

Constructor Detail

SwitchCase

public SwitchCase(InputInfo ii,
                  Expr... e)
Constructor.

Parameters:
ii - input info
e - return expression (placed first) and cases
Method Detail

checkUp

public void checkUp()
             throws QueryException
Description copied from class: Expr
Checks if all updating expressions are correctly placed. This function is only called if any updating expression was found in the query.

Overrides:
checkUp in class Arr
Throws:
QueryException - query exception

compile

public Expr compile(QueryContext ctx,
                    VarScope scp)
             throws QueryException
Description copied from class: Expr
Compiles and optimizes the expression, assigns data types and cardinalities.

Overrides:
compile in class Arr
Parameters:
ctx - query context
scp - variable scope
Returns:
optimized expression
Throws:
QueryException - query exception

copy

public Expr copy(QueryContext ctx,
                 VarScope scp,
                 IntObjMap<Var> vs)
Description copied from class: Expr
Copies an expression. Will be useful for inlining functions, or for copying static queries.

Specified by:
copy in class Expr
Parameters:
ctx - query context
scp - variable scope for creating new variables
vs - mapping from old variable IDs to new variable copies
Returns:
copied expression

inline

public Expr inline(QueryContext ctx,
                   VarScope scp,
                   Var v,
                   Expr e)
            throws QueryException
Description copied from class: Expr
Inlines an expression into this one, replacing all references to the given variable.

Overrides:
inline in class Arr
Parameters:
ctx - query context for recompilation
scp - variable scope for recompilation
v - variable to replace
e - expression to inline
Returns:
resulting expression in something changed, null otherwise
Throws:
QueryException - query exception

toString

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

count

public VarUsage count(Var v)
Checks how often a variable is used in this expression. This method counts only the occurrences in the return expression.

Overrides:
count in class Arr
Parameters:
v - variable to look for
Returns:
how often the variable is used, see VarUsage

countCases

protected VarUsage countCases(Var v)
Checks how often a variable is used in this expression. This method counts only the occurrences in the case expressions.

Parameters:
v - variable to look for
Returns:
number of occurrences

exprSize

public int exprSize()
Description copied from class: Expr
Counts the number of expressions in this expression's sub-tree.

Overrides:
exprSize in class Arr
Returns:
number of expressions