Package org.basex.query.value.item
Class FuncItem
java.lang.Object
org.basex.query.expr.ExprInfo
org.basex.query.expr.Expr
org.basex.query.value.Value
org.basex.query.value.item.Item
org.basex.query.value.item.FItem
org.basex.query.value.item.FuncItem
- All Implemented Interfaces:
Iterable<Item>,XQFunction,XQFunctionExpr,Scope
Function item.
- Author:
- BaseX Team 2005-21, BSD License, Leo Woerteler
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFuncItem(StaticContext sc, AnnList anns, QNm name, Var[] params, FuncType type, Expr expr, int stackSize, InputInfo info) Constructor.FuncItem(StaticContext sc, AnnList anns, QNm name, Var[] params, FuncType type, Expr expr, QueryFocus focus, int stackSize, InputInfo info) Constructor. -
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.intarity()Number of arguments this function takes.atomItem(QueryContext qc, InputInfo ii) Evaluates the expression and returns the resulting, atomized item, orEmpty.VALUEif the expression yields an empty sequence.atomValue(QueryContext qc, InputInfo ii) Evaluates the expression and returns the atomized items.coerceTo(FuncType ft, QueryContext qc, InputInfo ii, boolean optimize) Coerces this function item to the given function type.voidcomp(CompileContext cc) Compiles the expression contained in this scope.booleancompiled()Checks if this scope has already been compiled.booleanPerforms a deep comparison of two items.Returns a string description of the expression.booleanThis function is e.g.funcName()Name of this function,nullmeans anonymous function.inline(Expr[] exprs, CompileContext cc) Tries to inline this function with the given arguments.invokeInternal(QueryContext qc, InputInfo ii, Value[] args) Internally invokes this function with the given arguments.materialize(QueryContext qc, boolean copy) Returns a materialized, context-independent version of this item.paramName(int ps) Name of the parameter at the given position.voidCreates a query plan.voidplan(QueryString qs) Creates a query string.intSize of this function's stack frame.Returns a string representation of the expression that can be embedded in error messages.toJava()Returns a Java representation of the value.booleanChecks if this function returns vacuous results (seeExpr.vacuous()).booleanvisit(ASTVisitor visitor) Traverses this scope with the givenASTVisitor.Methods inherited from class org.basex.query.value.item.FItem
annotations, eq, funcType, refineType, sameKey, stringMethods inherited from class org.basex.query.value.item.Item
atomSize, bool, cache, comparable, dbl, ddo, dec, diff, ebv, equiv, flt, hash, input, instanceOf, item, itemAt, iter, itr, persistent, reverse, score, seqType, size, subsequence, test, typeId, xdmInfoMethods inherited from class org.basex.query.value.Value
checkUp, compile, copy, count, exprSize, has, inline, inlineable, isEmpty, isItem, iter, iterator, materialize, serialize, serialize, serialize, valueMethods inherited from class org.basex.query.expr.Expr
arg, args, atomIter, data, data, hasFreeVars, indexAccessible, isSimple, markTailCalls, mergeEbv, optimize, simplifyFor, typeCheck, uses, vacuous, visitAllMethods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.basex.query.func.XQFunction
invoke, invokeTail
-
Field Details
-
sc
Static context.
-
-
Constructor Details
-
FuncItem
public FuncItem(StaticContext sc, AnnList anns, QNm name, Var[] params, FuncType type, Expr expr, int stackSize, InputInfo info) Constructor.- Parameters:
sc- static contextanns- function annotationsname- function name (may benull)params- formal parameterstype- function typeexpr- function bodystackSize- stack-frame sizeinfo- input info
-
FuncItem
public FuncItem(StaticContext sc, AnnList anns, QNm name, Var[] params, FuncType type, Expr expr, QueryFocus focus, int stackSize, InputInfo info) Constructor.- Parameters:
sc- static contextanns- function annotationsname- function name (may benull)params- formal parameterstype- function typeexpr- function bodyfocus- query focus (may benull)stackSize- stack-frame sizeinfo- input info
-
-
Method Details
-
arity
public int arity()Description copied from interface:XQFunctionExprNumber of arguments this function takes.- Specified by:
arityin interfaceXQFunctionExpr- Returns:
- function arity
-
funcName
Description copied from interface:XQFunctionExprName of this function,nullmeans anonymous function.- Specified by:
funcNamein interfaceXQFunctionExpr- Returns:
- name or
null
-
paramName
Description copied from interface:XQFunctionExprName of the parameter at the given position.- Specified by:
paramNamein interfaceXQFunctionExpr- Parameters:
ps- position of the parameter- Returns:
- name of the parameter
-
invokeInternal
Description copied from interface:XQFunctionInternally invokes this function with the given arguments.- Specified by:
invokeInternalin interfaceXQFunction- Parameters:
qc- query contextii- input infoargs- arguments- Returns:
- resulting value
- Throws:
QueryException- query exception
-
stackFrameSize
public int stackFrameSize()Description copied from interface:XQFunctionSize of this function's stack frame.- Specified by:
stackFrameSizein interfaceXQFunction- Returns:
- stack frame size
-
coerceTo
public FuncItem coerceTo(FuncType ft, QueryContext qc, InputInfo ii, boolean optimize) throws QueryException Description copied from class:FItemCoerces this function item to the given function type.- Specified by:
coerceToin classFItem- Parameters:
ft- function typeqc- query contextii- input infooptimize- optimize resulting item- Returns:
- coerced item
- Throws:
QueryException- query exception
-
accept
Description copied from class:ExprTraverses this expression, notifying the visitor of declared and used variables, and checking the tree for other recursive properties. -
visit
Description copied from interface:ScopeTraverses this scope with the givenASTVisitor. -
comp
Description copied from interface:ScopeCompiles the expression contained in this scope. -
compiled
public boolean compiled()Description copied from interface:ScopeChecks if this scope has already been compiled. -
toJava
Description copied from class:ValueReturns a Java representation of the value. -
inline
Description copied from interface:XQFunctionExprTries to inline this function with the given arguments.- Specified by:
inlinein interfaceXQFunctionExpr- Parameters:
exprs- argumentscc- compilation context- Returns:
- the expression to inline if successful,
nullotherwise - Throws:
QueryException- query exception
-
atomValue
Description copied from class:ItemEvaluates the expression and returns the atomized items. Overwritten byXQArray,FuncItemandANode.- Overrides:
atomValuein classItem- Parameters:
qc- query contextii- input info (only required bySeqinstances, which have no input info)- Returns:
- atomized item
- Throws:
QueryException- query exception
-
atomItem
Description copied from class:ItemEvaluates the expression and returns the resulting, atomized item, orEmpty.VALUEif the expression yields an empty sequence. Overwritten byXQArray,FuncItemandANode.- Overrides:
atomItemin classItem- Parameters:
qc- query contextii- input info (only required bySeqinstances, which have no input info)- Returns:
- item or
Empty.VALUE - Throws:
QueryException- query exception
-
materialize
Description copied from class:ItemReturns a materialized, context-independent version of this item.- Overrides:
materializein classItem- Parameters:
qc- query context (ifnull, process cannot be interrupted)copy- create full copy- Returns:
- item copy, or
null) if the item cannot be materialized
-
deep
Description copied from class:FItemPerforms a deep comparison of two items.- Specified by:
deepin classFItem- Parameters:
item- item to be comparedcoll- collation (can benull)ii- input info- Returns:
- result of check
- Throws:
QueryException- query exception
-
vacuousBody
public boolean vacuousBody()Description copied from interface:XQFunctionExprChecks if this function returns vacuous results (seeExpr.vacuous()).- Specified by:
vacuousBodyin interfaceXQFunctionExpr- Returns:
- result of check
-
equals
Description copied from class:ExprThis function is e.g. called by:If.optimize(CompileContext),Switch.optimize(CompileContext),Typeswitch.optimize(CompileContext), in order to discard identical expressions.CmpR.mergeEbv(Expr, boolean, CompileContext)orCmpSR.mergeEbv(Expr, boolean, CompileContext), in order to merge expressions with identical input.CmpG.optimize(CompileContext)orCmpV.optimize(CompileContext), in order to pre-evaluate equality tests.CmpG.optimize(CompileContext)orPos.get(Expr, CmpV.OpV, InputInfo, CompileContext), in order to compare the start and end value.PathCache, in order to find identical root values at runtime.
-
description
Description copied from class:ExprInfoReturns a string description of the expression. This method is only called by error messages. Contrary to theExprInfo.toString()method, arguments are not included in the output.- Overrides:
descriptionin classItem- Returns:
- result of check
-
plan
Description copied from class:ExprInfoCreates a query plan. -
toErrorString
Description copied from class:ExprInfoReturns a string representation of the expression that can be embedded in error messages. Defaults toExprInfo.toString().- Overrides:
toErrorStringin classExprInfo- Returns:
- class name
-
plan
Description copied from class:ExprInfoCreates a query string.
-