org.basex.query.xpath.expr
Class Expr

java.lang.Object
  extended by org.basex.query.ExprInfo
      extended by org.basex.query.xpath.expr.Expr
Direct Known Subclasses:
Arr, Filter, FTArrayExpr, Func, InternalExpr, Item, LocPath, Pos, Unary

public abstract class Expr
extends ExprInfo

Common interface for all expressions.

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

Constructor Summary
Expr()
           
 
Method Summary
abstract  Expr comp(XPContext ctx)
          Optimizes the expression.
abstract  Item eval(XPContext ctx)
          Evaluates the expression with the specified context set.
 Expr indexEquivalent(XPContext ctx, Step step, boolean seq)
          Returns an equivalent expression which accesses an index structure.
 int indexSizes(XPContext ctx, Step step, int min)
          Returns the number of results if this query is evaluated by an index.
 java.lang.Class<?> returnedValue()
          Gets the expected return type.
 boolean sameAs(Expr cmp)
          Checks current and specified expression for equivalence.
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 org.basex.query.ExprInfo
color, info, name, plan, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Expr

public Expr()
Method Detail

comp

public abstract Expr comp(XPContext ctx)
                   throws QueryException
Optimizes the expression.

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

eval

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

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

returnedValue

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

Returns:
the expected class returned by the eval(org.basex.query.xpath.XPContext) method

sameAs

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

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

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

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

indexEquivalent

public Expr indexEquivalent(XPContext ctx,
                            Step step,
                            boolean seq)
                     throws QueryException
Returns an equivalent expression which accesses an index structure.

Parameters:
ctx - root
step - location step
seq - flag for sequential evaluation
Returns:
Equivalent index-expression or null
Throws:
QueryException - evaluation exception

indexSizes

public int indexSizes(XPContext ctx,
                      Step step,
                      int min)
Returns the number of results if this query is evaluated by an index. If Integer.MAX_VALUE is returned, no index access is possible.

Parameters:
ctx - root
step - the current location step
min - current minimum index hits
Returns:
number of expected results