public abstract class Value extends Expr implements Iterable<Item>
Iterable
interface, which is why all of its
values can also be retrieved via enhanced for(for-each) loops. The default
iter()
method will provide better performance.Modifier | Constructor and Description |
---|---|
protected |
Value(Type type)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(ASTVisitor visitor)
Traverses this expression, notifying the visitor of declared and used variables,
and checking the tree for other recursive properties.
|
abstract long |
atomSize()
Computes the number of atomized items.
|
abstract Value |
atomValue(InputInfo ii)
Evaluates the expression and returns the atomized items.
|
Value |
atomValue(QueryContext qc,
InputInfo ii)
Evaluates the expression and returns the atomized items.
|
ValueBuilder |
cache()
Creates an
ValueBuilder , containing all items of this value. |
void |
checkUp()
Checks if all updating expressions are correctly placed.
|
Value |
compile(QueryContext qc,
VarScope scp)
Compiles and optimizes the expression, assigns types and cardinalities.
|
Value |
copy(QueryContext qc,
VarScope scp,
IntObjMap<Var> vs)
Copies an expression.
|
VarUsage |
count(Var var)
Checks how often a variable is used in this expression.
|
String |
description()
Returns a string description of the expression.
|
int |
exprSize()
Counts the number of expressions in this expression's sub-tree.
|
boolean |
has(Expr.Flag flag)
Indicates if an expression has the specified compiler property.
|
abstract int |
hash(InputInfo ii)
Returns a hash code for this value.
|
abstract boolean |
homogeneous()
Checks if all items of this value share the same type.
|
Expr |
inline(QueryContext qc,
VarScope scp,
Var var,
Expr ex)
Inlines an expression into this one, replacing all references to the given variable.
|
boolean |
isValue()
Tests if this is a value.
|
abstract Item |
itemAt(long pos)
Gets the item at the given position in the value.
|
abstract ValueIter |
iter()
Returns an iterator.
|
ValueIter |
iter(QueryContext qc)
Evaluates the expression and returns an iterator on the resulting items.
|
Iterator<Item> |
iterator() |
abstract Value |
materialize(InputInfo ii)
Materializes streamable values, or returns a self reference.
|
boolean |
removable(Var var)
Checks if the specified variable is replaceable by a context value.
|
ArrayOutput |
serialize()
Serializes the value, using the standard XML serializer,
and returns the cached result.
|
ArrayOutput |
serialize(SerializerOptions options)
Serializes the value with the specified serialization parameters and returns the cached result.
|
abstract Object |
toJava()
Returns a Java representation of the value.
|
Value |
value(QueryContext qc)
Evaluates the expression and returns the resulting value.
|
abstract int |
writeTo(Item[] arr,
int index)
Writes this value's items out to the given array.
|
atomItem, atomIter, data, ebv, hasFreeVars, indexAccessible, inlineAll, isEmpty, isFunction, isVacuous, item, iterable, markTailCalls, optimize, optimizeEbv, sameAs, seqType, size, test, typeCheck, uses, visitAll
public Type type
protected Value(Type type)
type
- item typepublic final void checkUp()
Expr
public final Value compile(QueryContext qc, VarScope scp)
Expr
QueryContext.compile()
.public final ValueIter iter(QueryContext qc)
Expr
Expr.item(QueryContext, InputInfo)
must be implemented
by an expression, as it may be called by this method.public abstract ValueIter iter()
public final Value value(QueryContext qc)
Expr
public abstract Value materialize(InputInfo ii) throws QueryException
ii
- input infoQueryException
- query exceptionpublic abstract Value atomValue(InputInfo ii) throws QueryException
ii
- input infoQueryException
- query exceptionpublic final Value atomValue(QueryContext qc, InputInfo ii) throws QueryException
Expr
atomValue
in class Expr
qc
- query contextii
- input infoQueryException
- query exceptionpublic abstract long atomSize()
public final boolean isValue()
Expr
public abstract Object toJava() throws QueryException
QueryException
- query exceptionpublic boolean has(Expr.Flag flag)
Expr
true
if at least one test is successful.public final boolean removable(Var var)
Expr
Preds.removable(org.basex.query.var.Var)
if one of the variables is used within a predicate.Path.removable(org.basex.query.var.Var)
if the variable occurs within the path.GFLWOR.compile(QueryContext, VarScope)
to rewrite where
clauses into predicates.public final VarUsage count(Var var)
Expr
SwitchCase.countCases(org.basex.query.var.Var)
or (indirectly)
GFLWOR.inlineLets(org.basex.query.QueryContext, org.basex.query.var.VarScope)
.public Expr inline(QueryContext qc, VarScope scp, Var var, Expr ex) throws QueryException
Expr
GFLWOR.inlineLets(org.basex.query.QueryContext, org.basex.query.var.VarScope)
and For.toPredicate(org.basex.query.QueryContext, org.basex.query.var.VarScope, org.basex.query.expr.Expr)
,
and the variable reference is replaced in VarRef.inline(org.basex.query.QueryContext, org.basex.query.var.VarScope, org.basex.query.var.Var, org.basex.query.expr.Expr)
.inline
in class Expr
qc
- query context for reoptimizationscp
- variable scope for reoptimizationvar
- variable to replaceex
- expression to inlinenull
otherwiseQueryException
- query exceptionpublic Value copy(QueryContext qc, VarScope scp, IntObjMap<Var> vs)
Expr
public String description()
ExprInfo
ExprInfo.toString()
method,
arguments are not included in the output.description
in class ExprInfo
public abstract int hash(InputInfo ii) throws QueryException
ii
- input infoQueryException
- if atomization can't be applied (e.g. function item)public abstract int writeTo(Item[] arr, int index)
arr
- array to write toindex
- start positionpublic final ValueBuilder cache()
ValueBuilder
, containing all items of this value.
Use with care, as compressed Values are expanded, creating many objects.public final ArrayOutput serialize() throws QueryIOException
QueryIOException
- query I/O exceptionpublic final ArrayOutput serialize(SerializerOptions options) throws QueryIOException
options
- serialization parameters (may be null
)QueryIOException
- query I/O exceptionpublic abstract Item itemAt(long pos)
pos
- positionpublic abstract boolean homogeneous()
public boolean accept(ASTVisitor visitor)
Expr
public final int exprSize()
Expr
StaticFunc.inline(org.basex.query.QueryContext, org.basex.query.util.list.AnnList, org.basex.query.expr.Expr)
to check if an expression
is small enough to be inlined.Copyright © 2005–2015 BaseX Team. All rights reserved.