org.basex.query.path
Class Step

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.Preds
                  extended by org.basex.query.path.Step

public abstract class Step
extends Preds

Abstract axis step 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
 Test test
          Kind test.
 
Fields inherited from class org.basex.query.expr.Preds
last, pos, preds
 
Fields inherited from class org.basex.query.expr.ParseExpr
info, size, type
 
Method Summary
 boolean accept(ASTVisitor visitor)
          Traverses this expression, notifying the visitor of declared and used variables, and checking the tree for other recursive properties.
 Expr compile(QueryContext ctx, VarScope scp)
          Compiles and optimizes the expression, assigns data types and cardinalities.
abstract  Step 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.
 int exprSize()
          Counts the number of expressions in this expression's sub-tree.
static Step get(InputInfo ii, Axis a, Test t, Expr... p)
          This method creates a step instance.
 Expr inline(QueryContext ctx, VarScope scp, Var v, Expr e)
          Inlines an expression into this one, replacing all references to the given variable.
 void plan(FElem plan)
          Creates an expression tree.
 boolean sameAs(Expr cmp)
          Compares the current and specified expression for equality.
 boolean simple(Axis ax, boolean name)
          Checks if this is a simple axis without predicates.
 java.lang.String toString()
           
 
Methods inherited from class org.basex.query.expr.Preds
checkUp, copy, has, preds, removable, useIterator
 
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, indexEquivalent, inlineAll, isEmpty, isFunction, isItem, isVacuous, isValue, iterable, markTailCalls, optimize, 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
 

Field Detail

test

public Test test
Kind test.

Method Detail

get

public static Step get(InputInfo ii,
                       Axis a,
                       Test t,
                       Expr... p)
This method creates a step instance.

Parameters:
ii - input info
a - axis
t - node test
p - predicates
Returns:
step

compile

public final 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 Preds
Parameters:
ctx - query context
scp - variable scope
Returns:
optimized expression
Throws:
QueryException - query exception

copy

public abstract Step 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

simple

public final boolean simple(Axis ax,
                            boolean name)
Checks if this is a simple axis without predicates.

Parameters:
ax - axis to be checked
name - name/node test
Returns:
result of check

sameAs

public final boolean sameAs(Expr cmp)
Description copied from class: Expr
Compares the current and specified expression for equality.

Overrides:
sameAs in class Expr
Parameters:
cmp - expression to be compared
Returns:
result of check

count

public VarUsage count(Var v)
Description copied from class: Expr
Checks how often a variable is used in this expression.

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

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 Preds
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

plan

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

Overrides:
plan in class Preds
Parameters:
plan - root element

toString

public final java.lang.String toString()
Overrides:
toString in class Preds

accept

public boolean accept(ASTVisitor visitor)
Description copied from class: Expr
Traverses this expression, notifying the visitor of declared and used variables, and checking the tree for other recursive properties.

Specified by:
accept in class Expr
Parameters:
visitor - visitor
Returns:
if the walk should be continued

exprSize

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

Specified by:
exprSize in class Expr
Returns:
number of expressions