|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.basex.data.ExprInfo
org.basex.query.expr.Expr
public abstract class Expr
Abstract class for representing XQuery expressions.
Expression are divided into ParseExpr
and Value
classes.
Nested Class Summary | |
---|---|
static class |
Expr.Flag
Flags that influence query compilation. |
Constructor Summary | |
---|---|
Expr()
|
Method Summary | |
---|---|
abstract boolean |
accept(ASTVisitor visitor)
Traverses this expression, notifying the visitor of declared and used variables, and checking the tree for other recursive properties. |
Expr |
addText(QueryContext ctx)
Optionally adds a text node to an expression for potential index rewriting. |
abstract void |
checkUp()
Checks if all updating expressions are correctly placed. |
Expr |
compEbv(QueryContext ctx)
This method is overwritten by CmpG , CmpV and FNSimple . |
abstract Expr |
compile(QueryContext ctx,
VarScope scp)
Compiles and optimizes the expression, assigns data types and cardinalities. |
Expr |
copy(QueryContext ctx,
VarScope scp)
Copies an expression. |
abstract Expr |
copy(QueryContext ctx,
VarScope scp,
IntObjMap<Var> vs)
Copies an expression. |
abstract VarUsage |
count(Var v)
Checks how often a variable is used in this expression. |
abstract Item |
ebv(QueryContext ctx,
InputInfo ii)
Checks if the iterator can be dissolved into an effective boolean value. |
abstract int |
exprSize()
Counts the number of expressions in this expression's sub-tree. |
abstract boolean |
has(Expr.Flag flag)
Indicates if an expression has the specified compiler property. |
boolean |
hasFreeVars()
Checks if this expression has free variables. |
boolean |
indexAccessible(IndexCosts ic)
Checks if an expression can be rewritten to an index access. |
Expr |
indexEquivalent(IndexCosts ic)
Returns an equivalent expression which accesses an index structure. |
abstract Expr |
inline(QueryContext ctx,
VarScope scp,
Var v,
Expr e)
Inlines an expression into this one, replacing all references to the given variable. |
protected static boolean |
inlineAll(QueryContext ctx,
VarScope scp,
Expr[] arr,
Var v,
Expr e)
Inlines the given expression into all elements of the given array. |
boolean |
isEmpty()
Tests if this is an empty sequence. |
boolean |
isFunction(Function f)
Checks if this expression is a certain function. |
boolean |
isItem()
Tests if this is an item. |
boolean |
isVacuous()
Tests if this is a vacuous expression (empty sequence or error function). |
boolean |
isValue()
Tests if this is a value. |
abstract Item |
item(QueryContext ctx,
InputInfo ii)
Evaluates the expression and returns the resulting item or a null reference, if the expression yields an empty sequence. |
abstract Iter |
iter(QueryContext ctx)
Evaluates the expression and returns an iterator on the resulting items. |
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. |
Expr |
markTailCalls()
Finds and marks tail calls, enabling TCO. |
Expr |
optimize(QueryContext ctx,
VarScope scp)
Optimizes an already compiled expression without recompiling its sub-expressions. |
abstract 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. |
abstract long |
size()
Returns the sequence size or 1. |
abstract Item |
test(QueryContext ctx,
InputInfo ii)
Performs a predicate test and returns the item if test was successful. |
abstract SeqType |
type()
Returns the static type of the evaluated value. |
boolean |
uses(Var v)
Checks if the given variable is used by this expression. |
abstract Value |
value(QueryContext ctx)
Evaluates the expression and returns the resulting value. |
protected static boolean |
visitAll(ASTVisitor visitor,
Expr... exprs)
Visit all given expressions with the given visitor. |
Methods inherited from class org.basex.data.ExprInfo |
---|
addPlan, addPlan, description, info, plan, planAttr, planElem, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Expr()
Method Detail |
---|
public abstract void checkUp() throws QueryException
QueryException
- query exceptionpublic abstract Expr compile(QueryContext ctx, VarScope scp) throws QueryException
ctx
- query contextscp
- variable scope
QueryException
- query exceptionpublic Expr optimize(QueryContext ctx, VarScope scp) throws QueryException
ctx
- query contextscp
- variable scope
QueryException
- query exceptionpublic abstract Iter iter(QueryContext ctx) throws QueryException
item(org.basex.query.QueryContext, org.basex.util.InputInfo)
must be implemented
by an expression, as it may be called by this method.
ctx
- query context
QueryException
- query exceptionpublic abstract Item item(QueryContext ctx, InputInfo ii) throws QueryException
null
reference, if the expression yields an empty sequence.
If this method is not overwritten, iter(org.basex.query.QueryContext)
must be implemented
by an expression, as it may be called by this method.
ctx
- query contextii
- input info
QueryException
- query exceptionpublic abstract Value value(QueryContext ctx) throws QueryException
ctx
- query context
QueryException
- query exceptionpublic abstract Item ebv(QueryContext ctx, InputInfo ii) throws QueryException
ctx
- query contextii
- input info
QueryException
- query exceptionpublic abstract Item test(QueryContext ctx, InputInfo ii) throws QueryException
ctx
- query contextii
- input info
QueryException
- query exceptionpublic boolean isEmpty()
Empty
class, which represents the empty sequence.
public boolean isVacuous()
public boolean isValue()
public boolean isItem()
public abstract long size()
public abstract boolean has(Expr.Flag flag)
compile(org.basex.query.QueryContext, org.basex.query.var.VarScope)
methods to test properties of sub-expressions.
It returns true
if at least one test is successful.
flag
- flag to be found
public final boolean uses(Var v)
v
- variable to be checked
true
if the variable is used, false
otherwisepublic abstract boolean removable(Var v)
Preds.removable(org.basex.query.var.Var)
, if one of the variables is used within a predicate.MixedPath.removable(org.basex.query.var.Var)
, if the variable occurs within the path.GFLWOR.compile(org.basex.query.QueryContext, org.basex.query.var.VarScope)
to rewrite where clauses
into predicates.
v
- variable to be replaced
public abstract VarUsage count(Var v)
v
- variable to look for
VarUsage
public abstract Expr inline(QueryContext ctx, VarScope scp, Var v, Expr e) throws QueryException
ctx
- query context for recompilationscp
- variable scope for recompilationv
- variable to replacee
- expression to inline
null
otherwise
QueryException
- query exceptionprotected static boolean inlineAll(QueryContext ctx, VarScope scp, Expr[] arr, Var v, Expr e) throws QueryException
ctx
- query contextscp
- variable scopearr
- arrayv
- variable to replacee
- expression to inline
true
if the array has changed, false
otherwise
QueryException
- query exceptionpublic final Expr copy(QueryContext ctx, VarScope scp)
ctx
- query contextscp
- variable scope for creating new variables
public abstract Expr copy(QueryContext ctx, VarScope scp, IntObjMap<Var> vs)
ctx
- query contextscp
- variable scope for creating new variablesvs
- mapping from old variable IDs to new variable copies
public Expr compEbv(QueryContext ctx)
This method is overwritten by CmpG
, CmpV
and FNSimple
.
It is called at compile time by expressions that perform
effective boolean value tests (e.g. If
or Preds
).
If the arguments of the called expression return a boolean anyway,
the expression will be simplified.
Example in CmpV
:
if($x eq true())
is rewritten to if($x)
, if $x
is known to return a single boolean.
ctx
- query context
public abstract SeqType type()
public boolean iterable()
AxisPath
.
public boolean indexAccessible(IndexCosts ic) throws QueryException
indexEquivalent(org.basex.query.util.IndexCosts)
must be implemented as well.
ic
- index costs analyzer
QueryException
- query exceptionpublic Expr indexEquivalent(IndexCosts ic) throws QueryException
indexAccessible(org.basex.query.util.IndexCosts)
is returns true for an expression.
ic
- index costs analyzer
QueryException
- query exceptionpublic boolean sameAs(Expr cmp)
cmp
- expression to be compared
public boolean isFunction(Function f)
f
- function definition
public Expr addText(QueryContext ctx)
ctx
- query context
public boolean hasFreeVars()
true
if there are variables which are used but not declared
in this expression, false
otherwisepublic Expr markTailCalls()
public abstract boolean accept(ASTVisitor visitor)
visitor
- visitor
protected static final boolean visitAll(ASTVisitor visitor, Expr... exprs)
visitor
- visitorexprs
- expressions to visit
public abstract int exprSize()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |