org.basex.query.xpath.expr
Class Expr

java.lang.Object
  extended by org.basex.query.xpath.expr.Expr
Direct Known Subclasses:
ArrayExpr, DualExpr, Filter, Func, InternalExpr, Item, LocPath, Path, Unary

public abstract class Expr
extends java.lang.Object

Common interface for all expressions.

Author:
Workgroup DBIS, University of Konstanz 2005-07, ISC License, Tim Petrowsky

Constructor Summary
Expr()
           
 
Method Summary
abstract  Expr compile(XPContext ctx)
          Tries to optimize the Expression.
abstract  Item eval(XPContext ctx)
          Evaluates the expression with the specified context set.
 Expr indexEquivalent(XPContext ctx, Step step)
          For predicate optimization.
 int indexSizes(XPContext ctx, Step step, int min)
          For predicate optimization.
 java.lang.Class<?> returnedValue()
          Gets the expected return type.
 boolean sameAs(Expr cmp)
          Checks current and specified expression for equivalence.
abstract  java.lang.String toString()
           
abstract  boolean usesPos()
          Checks whether this Expression (or its children) make use of the position parameter.
abstract  boolean usesSize()
          Checks whether this Expression (or its children) make use of the setsize parameter.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Expr

public Expr()
Method Detail

compile

public abstract Expr compile(XPContext ctx)
                      throws EvalException
Tries to optimize the Expression.

Parameters:
ctx - expression context
Returns:
optimized Expression
Throws:
EvalException - evaluation exception

eval

public abstract Item eval(XPContext ctx)
                   throws EvalException
Evaluates the expression with the specified context set. Additionally provides a context

Parameters:
ctx - query context
Returns:
resulting XPathValue
Throws:
EvalException - evaluation exception

indexEquivalent

public Expr indexEquivalent(XPContext ctx,
                            Step step)
                     throws EvalException
For predicate optimization. If possible return an expression yielding the same results using the index. This may not do any changes to the current expression.

Parameters:
ctx - root
step - the LocationStep this Expression is a predicate of
Returns:
Equivalent index-expression or null
Throws:
EvalException - evaluation exception

indexSizes

public int indexSizes(XPContext ctx,
                      Step step,
                      int min)
For predicate optimization. If possible return the number of entries an index returns. This may not do any changes to the current expression.

Parameters:
ctx - root
step - the LocationStep this Expression is a predicate of
min - current minimum size
Returns:
Equivalent index-expression or null

returnedValue

public final java.lang.Class<?> returnedValue()
Gets the expected return type. This may be XPathValue itself.

Returns:
the expected class returned by the eval() method

sameAs

public boolean sameAs(Expr cmp)
Checks current and specified expression for equivalence.

Parameters:
cmp - expression to be compared
Returns:
result of check

toString

public abstract java.lang.String toString()
Overrides:
toString in class java.lang.Object

usesPos

public abstract boolean usesPos()
Checks whether this Expression (or its children) make use of the position parameter. If not this allows some nice optimizations.

Returns:
whether position is used

usesSize

public abstract boolean usesSize()
Checks whether this Expression (or its children) make use of the setsize parameter. If not this allows early predicate evaluation.

Returns:
whether setsize is used