Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.basex.query.expr
Class Expr

    java.lang.Object
      org.basex.query.ExprInfo
          org.basex.query.expr.Expr

Direct Known Subclasses:
  Arr, FLWOR, FTContains, FTExpr, Group, Grp, Item, Ord, Order, Path, Preds, Satisfy, Simple, Single, TypeSwitch, Var, VarCall

    public abstract class Expr

extends ExprInfo

Abstract expression.

Author:
  Workgroup DBIS, University of Konstanz 2005-10, ISC License, Christian Gruen

Nested Class Summary
`static class` | `Expr.Use` Usage flags.

Constructor Summary
`Expr()`

Method Summary
`Expr` | `addText(QueryContext ctx)` Optionally adds a text node to an expression for potential index rewriting.
`Item` | `atomic(QueryContext ctx)` Evaluates the expression and returns the resulting item or a `null` reference.
`Item` | `checkCtx(QueryContext ctx)` Throws an exception if the context item is not set.
`double` | `checkDbl(Expr e, QueryContext ctx)` Checks if the specified expression yields a string.
`long` | `checkItr(Expr e, QueryContext ctx)` Checks if the specified expression is an integer.
`abstract Expr` | `comp(QueryContext ctx)` Optimizes and compiles the expression.
`boolean` | `duplicates(QueryContext ctx)` Returns true if the expression might yield duplicates and unsorted results.
`boolean` | `e()` Returns if this is an empty sequence.
`Item` | `ebv(QueryContext ctx)` Checks if the iterator can be dissolved into an effective boolean value.
`boolean` | `i()` Checks if this is an item.
`boolean` | `indexAccessible(IndexContext ic)` Checks if an index can be used for query evaluation.
`Expr` | `indexEquivalent(IndexContext ic)` Returns an equivalent expression which accesses an index structure.
`Iter` | `iter(QueryContext ctx)` Evaluates the expression and returns an iterator on the resulting items.
`boolean` | `removable(Var v, QueryContext ctx)` Checks if the specified variable is removable.
`Expr` | `remove(Var v)` Removes the specified variable in a sub expression.
`Return` | `returned(QueryContext ctx)` Indicates the return type of an expression.
`boolean` | `sameAs(Expr cmp)` Checks the current and specified expression for equality.
`long` | `size(QueryContext ctx)` Returns the sequence size or 1.
`Item` | `test(QueryContext ctx)` Performs a predicate test and returns the item if test was successful.
`abstract boolean` | `uses(Expr.Use u, QueryContext ctx)` Indicates if an expression uses the specified type.
`boolean` | `v()` Returns if this is a vacuous expression (empty sequence or error function).

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(QueryContext ctx)
                       throws QueryException

  Optimizes and compiles the expression.

  Parameters:
    `ctx` - query context
  Returns:
    optimized Expression
  Throws:
    `QueryException` - query exception

### iter

    public Iter iter(QueryContext ctx)
              throws QueryException

  Evaluates the expression and returns an iterator on the resulting items. If this method is not overwritten, `atomic(org.basex.query.QueryContext)` must be implemented.

  Parameters:
    `ctx` - query context
  Returns:
    resulting item
  Throws:
    `QueryException` - query exception

### atomic

    public Item atomic(QueryContext ctx)
                throws QueryException

  Evaluates the expression and returns the resulting item or a `null` reference. If this method is not overwritten, `iter(org.basex.query.QueryContext)` must be implemented.

  Parameters:
    `ctx` - query context
  Returns:
    iterator
  Throws:
    `QueryException` - query exception

### ebv

    public Item ebv(QueryContext ctx)
             throws QueryException

  Checks if the iterator can be dissolved into an effective boolean value. If not, returns an error. If yes, returns the first value - which can be also be e.g. an integer, which is later evaluated as position predicate.

  Parameters:
    `ctx` - query context
  Returns:
    item
  Throws:
    `QueryException` - query exception

### test

    public Item test(QueryContext ctx)
              throws QueryException

  Performs a predicate test and returns the item if test was successful.

  Parameters:
    `ctx` - query context
  Returns:
    item
  Throws:
    `QueryException` - query exception

### i

    public boolean i()

  Checks if this is an item.

  Returns:
    result of check

### e

    public boolean e()

  Returns if this is an empty sequence.

  Returns:
    result of check

### v

    public boolean v()

  Returns if this is a vacuous expression (empty sequence or error function).

  Returns:
    result of check

### size

    public long size(QueryContext ctx)
              throws QueryException

  Returns the sequence size or 1.

  Parameters:
    `ctx` - query context
  Returns:
    result of check
  Throws:
    `QueryException` - query exception

### uses

    public abstract boolean uses(Expr.Use u,
                                 QueryContext ctx)

  Indicates if an expression uses the specified type. Called by the compiler to perform certain optimizations. `true` is returned by default and thus assumed as "worst-case".

  Parameters:
    `u` - use type to be checked
    `ctx` - query context
  Returns:
    result of check

### removable

    public boolean removable(Var v,
                             QueryContext ctx)

  Checks if the specified variable is removable.

  Parameters:
    `v` - variable to be removed
    `ctx` - query context
  Returns:
    result of check

### remove

    public Expr remove(Var v)

  Removes the specified variable in a sub expression.

  Parameters:
    `v` - variable to be removed
  Returns:
    expression with removed variable

### returned

    public Return returned(QueryContext ctx)

  Indicates the return type of an expression. Called by the compiler to check if expressions can be reformulated. null is returned by default.

  Parameters:
    `ctx` - query context
  Returns:
    result of check

### duplicates

    public boolean duplicates(QueryContext ctx)

  Returns true if the expression might yield duplicates and unsorted results.

  Parameters:
    `ctx` - query context
  Returns:
    result of check

### indexAccessible

    public boolean indexAccessible(IndexContext ic)
                            throws QueryException

  Checks if an index can be used for query evaluation.

  Parameters:
    `ic` - index context
  Returns:
    true if an index can be used
  Throws:
    `QueryException` - query exception

### indexEquivalent

    public Expr indexEquivalent(IndexContext ic)
                         throws QueryException

  Returns an equivalent expression which accesses an index structure. Must be called if `indexAccessible(org.basex.query.IndexContext)` is implemented for an expression.

  Parameters:
    `ic` - index context
  Returns:
    Equivalent index-expression or null
  Throws:
    `QueryException` - query exception

### sameAs

    public boolean sameAs(Expr cmp)

  Checks the current and specified expression for equality.

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

### checkDbl

    public final double checkDbl(Expr e,
                                 QueryContext ctx)
                          throws QueryException

  Checks if the specified expression yields a string. Returns a token representation or an exception.

  Parameters:
    `e` - expression to be checked
    `ctx` - query context
  Returns:
    item
  Throws:
    `QueryException` - query exception

### checkItr

    public final long checkItr(Expr e,
                               QueryContext ctx)
                        throws QueryException

  Checks if the specified expression is an integer. Returns a token representation or an exception.

  Parameters:
    `e` - expression to be checked
    `ctx` - query context
  Returns:
    item
  Throws:
    `QueryException` - query exception

### checkCtx

    public final Item checkCtx(QueryContext ctx)
                        throws QueryException

  Throws an exception if the context item is not set.

  Parameters:
    `ctx` - query context
  Returns:
    item if everything is ok
  Throws:
    `QueryException` - query exception

### addText

    public Expr addText(QueryContext ctx)
                 throws QueryException

  Optionally adds a text node to an expression for potential index rewriting.

  Parameters:
    `ctx` - query context
  Returns:
    expression
  Throws:
    `QueryException` - query exception

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD