org.basex.query.path
Class AxisPath

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.path.Path
                  extended by org.basex.query.path.AxisPath

public abstract class AxisPath
extends Path

Abstract axis path 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.path.Path
root, steps
 
Fields inherited from class org.basex.query.expr.ParseExpr
info, size, type
 
Method Summary
 Expr addText(QueryContext ctx)
          Optionally adds a text node to an expression for potential index rewriting.
 boolean cheap()
          Guesses if the evaluation of this axis path is cheap.
protected  Expr compilePath(QueryContext ctx, VarScope scp)
          Compiles the location path.
 AxisPath invertPath(Expr r, Step curr)
          Inverts a location path.
 boolean iterable()
          Returns true if the expression is iterable, i.e., if it will not contain any duplicate nodes and if all nodes will be are sorted.
 java.util.ArrayList<PathNode> nodes(QueryContext ctx)
          Returns the path nodes that will result from this path.
 Expr optimize(QueryContext ctx, VarScope scp)
          Optimizes an already compiled expression without recompiling its sub-expressions.
 boolean removable(Var v)
          Checks if the specified variable is replaceable by a context item.
 boolean sameAs(Expr cmp)
          Compares the current and specified expression for equality.
 Step step(int i)
          Returns the specified axis step.
 
Methods inherited from class org.basex.query.path.Path
accept, addPreds, checkUp, compile, count, exprSize, get, has, inline, plan, 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
compEbv, copy, copy, hasFreeVars, indexAccessible, indexEquivalent, inlineAll, isEmpty, isFunction, isItem, isVacuous, isValue, markTailCalls, 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
 

Method Detail

compilePath

protected final Expr compilePath(QueryContext ctx,
                                 VarScope scp)
                          throws QueryException
Description copied from class: Path
Compiles the location path.

Specified by:
compilePath in class Path
Parameters:
ctx - query context
scp - variable scope
Returns:
optimized expression
Throws:
QueryException - query exception

optimize

public Expr optimize(QueryContext ctx,
                     VarScope scp)
              throws QueryException
Description copied from class: Expr
Optimizes an already compiled expression without recompiling its sub-expressions.

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

invertPath

public final AxisPath invertPath(Expr r,
                                 Step curr)
Inverts a location path.

Parameters:
r - new root node
curr - current location step
Returns:
inverted path

addText

public final Expr addText(QueryContext ctx)
Description copied from class: Expr
Optionally adds a text node to an expression for potential index rewriting.

Overrides:
addText in class Expr
Parameters:
ctx - query context
Returns:
expression

step

public final Step step(int i)
Returns the specified axis step.

Parameters:
i - index
Returns:
step

nodes

public java.util.ArrayList<PathNode> nodes(QueryContext ctx)
Returns the path nodes that will result from this path.

Parameters:
ctx - query context
Returns:
path nodes, or null if nodes cannot be evaluated

removable

public final boolean removable(Var v)
Description copied from class: Expr
Checks if the specified variable is replaceable by a context item. The following tests might return false: This method is called by GFLWOR.compile(org.basex.query.QueryContext, org.basex.query.var.VarScope) to rewrite where clauses into predicates.

Overrides:
removable in class Path
Parameters:
v - variable to be replaced
Returns:
result of check

iterable

public final boolean iterable()
Description copied from class: Expr
Returns true if the expression is iterable, i.e., if it will not contain any duplicate nodes and if all nodes will be are sorted. The return value of this method is only relevant for node sequences. It is e.g. called by AxisPath.

Overrides:
iterable in class Expr
Returns:
result of check

cheap

public boolean cheap()
Guesses if the evaluation of this axis path is cheap. This is used to determine if it can be inlined into a loop to enable index rewritings.

Returns:
guess

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