Package org.basex.query.value
Class Value
java.lang.Object
org.basex.query.expr.ExprInfo
org.basex.query.expr.Expr
org.basex.query.value.Value
Abstract value.
This class also implements the
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.- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaccept(ASTVisitor visitor) Traverses this expression, notifying the visitor of declared and used variables, and checking the tree for other recursive properties.abstract longatomSize()Computes the number of atomized items.abstract voidCaches lazy values.final voidcheckUp()Checks if the updating semantics are satisfied.final ValueCompiles and optimizes the expression, assigns types and cardinalities.copy(CompileContext cc, IntObjMap<Var> vm) Copies an expression.final VarUsageChecks how often a variable or context reference is used in this expression.final intexprSize()Counts the number of expressions in this expression's sub-tree.final booleanIndicates if an expression has one of the specified compiler properties.abstract intReturns a hash code for this value.final Exprinline(InlineContext ic) Inlines an expression into this one, replacing all variable or context references.final booleanChecks if inlining is possible.final booleanisEmpty()Tests if this is an empty sequence.final booleanisItem()Tests if this is an item.abstract ItemitemAt(long pos) Returns the item at the given position in the value.iter()Returns an iterator.iter(QueryContext qc) Evaluates the expression and returns an iterator on the resulting items.iterator()materialize(QueryContext qc, QueryError error, InputInfo info) Returns a materialized, context-independent version of this value.abstract Valuereverse(QueryContext qc) Returns all items of this value in reverse order.final ArrayOutputSerializes the value, using the standard XML serializer, and returns the cached result.final voidserialize(Serializer ser) Serializes the value with the specified serializer.final ArrayOutputserialize(SerializerOptions options) Serializes the value with the specified serialization parameters and returns the cached result.abstract Valuesubsequence(long start, long length, QueryContext qc) Returns a subsequence of this value with the given start and length.abstract ObjecttoJava()Returns a Java representation of the value.final Valuevalue(QueryContext qc) Evaluates the expression and returns the resulting value.Methods inherited from class org.basex.query.expr.Expr
arg, args, atomItem, atomIter, atomValue, data, data, ddo, ebv, equals, funcType, hasFreeVars, indexAccessible, isSimple, item, markTailCalls, mergeEbv, optimize, refineType, seqType, simplifyFor, size, test, typeCheck, uses, vacuous, visitAllMethods inherited from class org.basex.query.expr.ExprInfo
description, plan, plan, toErrorString, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
type
Item type.
-
-
Constructor Details
-
Value
Constructor.- Parameters:
type- item type
-
-
Method Details
-
checkUp
public final void checkUp()Description copied from class:ExprChecks if the updating semantics are satisfied. This function is only called if any updating expression was found in the query. -
compile
Description copied from class:ExprCompiles and optimizes the expression, assigns types and cardinalities. -
iter
Description copied from class:ExprEvaluates the expression and returns an iterator on the resulting items. The implementation of this method is optional. -
iterator
-
iter
Returns an iterator.- Returns:
- iterator
-
value
Description copied from class:ExprEvaluates the expression and returns the resulting value. If this method is not implemented,Expr.item(QueryContext, InputInfo)must be implemented instead. -
materialize
Returns a materialized, context-independent version of this value.- Parameters:
qc- query context (ifnull, process cannot be interrupted)error- query errorinfo- input info- Returns:
- item copy, or
null) if the value cannot be materialized - Throws:
QueryException- query exception
-
isEmpty
public final boolean isEmpty()Tests if this is an empty sequence.- Returns:
- result of check
-
isItem
public final boolean isItem()Tests if this is an item.- Returns:
- result of check
-
subsequence
Returns a subsequence of this value with the given start and length. The following properties must hold:start >= 0,length >= 0,length <= size() - start
- Parameters:
start- starting positionlength- number of itemsqc- query context- Returns:
- sub sequence
-
cache
Caches lazy values.- Parameters:
lazy- lazy cachingii- input info- Throws:
QueryException- query exception
-
atomSize
public abstract long atomSize()Computes the number of atomized items.- Returns:
- atomized item
-
toJava
Returns a Java representation of the value.- Returns:
- Java object
- Throws:
QueryException- query exception
-
has
Description copied from class:ExprIndicates if an expression has one of the specified compiler properties. This method must only be called at compile time. It is invoked to test properties of sub-expressions. It returnstrueif at least flag matches an expression. -
inlineable
Description copied from class:ExprChecks if inlining is possible. This function is called byInlineContext.inlineable(org.basex.query.expr.Expr...)and:CNode.inlineable(org.basex.query.InlineContext)returns false if the new expression construct new nodes. The following tests might reject inlining if the expression is a context reference:- Specified by:
inlineablein classExpr- Parameters:
ic- inlining context- Returns:
- result of check
-
count
Description copied from class:ExprChecks how often a variable or context reference is used in this expression. This function is called by:-
Closure.optimize(org.basex.query.CompileContext) -
GFLWOR.inlineForLet(org.basex.query.CompileContext) -
GFLWOR.optimizePos(org.basex.query.CompileContext) -
GFLWOR.simplify(org.basex.query.CompileContext) -
GFLWOR.unusedVars(org.basex.query.CompileContext) -
SimpleMap.optimize(org.basex.query.CompileContext) -
TypeswitchGroup.optimize(org.basex.query.CompileContext)
-
-
inline
Description copied from class:ExprInlines an expression into this one, replacing all variable or context references. This function is called byInlineContext.inline(Expr)(see invocations of this functions for further inlinings). The variable reference is replaced in: The context is replaced in: -
copy
Description copied from class:ExprCopies an expression. Used for inlining functions, or for copying static queries. It is utilized byVarRef.inline(org.basex.query.InlineContext),FuncItem.inline(org.basex.query.expr.Expr[], org.basex.query.CompileContext),Closure.inline(org.basex.query.InlineContext)andStaticFunc.inline(org.basex.query.expr.Expr[], org.basex.query.CompileContext).- Specified by:
copyin classExpr- Parameters:
cc- compilation contextvm- mapping from old variable IDs to new variable copies. Required byClosure.copy(org.basex.query.CompileContext, org.basex.util.hash.IntObjMap<org.basex.query.var.Var>)andVarRef.copy(org.basex.query.CompileContext, org.basex.util.hash.IntObjMap<org.basex.query.var.Var>)- Returns:
- copied expression
-
hash
Returns a hash code for this value.- Parameters:
ii- input info- Returns:
- hash code
- Throws:
QueryException- if atomization can't be applied (e.g. function item)
-
serialize
Serializes the value, using the standard XML serializer, and returns the cached result.- Returns:
- serialized value
- Throws:
QueryIOException- query I/O exception
-
serialize
Serializes the value with the specified serialization parameters and returns the cached result.- Parameters:
options- serialization parameters (may benull)- Returns:
- serialized value
- Throws:
QueryIOException- query I/O exception
-
serialize
Serializes the value with the specified serializer.- Parameters:
ser- serializer- Throws:
IOException- I/O exception
-
itemAt
Returns the item at the given position in the value. The specified value must be lie within the valid bounds.- Parameters:
pos- position- Returns:
- item
-
reverse
Returns all items of this value in reverse order.- Parameters:
qc- query context- Returns:
- items in reverse order
-
accept
Description copied from class:ExprTraverses this expression, notifying the visitor of declared and used variables, and checking the tree for other recursive properties. -
exprSize
public final int exprSize()Description copied from class:ExprCounts the number of expressions in this expression's sub-tree. This method is e.g. called byStaticFunc.inline(org.basex.query.expr.Expr[], org.basex.query.CompileContext)to check if an expression is small enough to be inlined.
-