Package org.basex.query.expr
Class ParseExpr
java.lang.Object
org.basex.query.expr.ExprInfo
org.basex.query.expr.Expr
org.basex.query.expr.ParseExpr
- Direct Known Subclasses:
Arr,Clause,FTExpr,GFLWOR,IndexDb,Path,Simple,Single,Switch,Typeswitch,VarRef
Abstract parse expression. All non-value expressions are derived from this class.
- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal ParseExprAssigns the type from the specified expression.final ValueatomValue(QueryContext qc, InputInfo ii) Evaluates the expression and returns the atomized items.protected final voidcheckAllUp(Expr... exprs) Ensures that all specified expressions are vacuous or either updating or non-updating.protected final ItemcheckNoEmpty(Item item) Checks if the specified item is no empty sequence.protected final ItemcheckNoEmpty(Item item, Type type) Checks if the specified item is no empty sequence.protected final voidcheckNoneUp(Expr... exprs) Ensures that none of the specified expressions performs an update.protected final voidEnsures that the specified expression performs no updates.protected final ItemcheckType(Expr expr, QueryContext qc, AtomType type) Checks if the specified expression yields an item of the specified atomic type.protected final ItemChecks if the specified expression is an empty sequence; if yes, throws an exception.protected final <T extends XQFunctionExpr>
TcheckUp(T expr, boolean updating, StaticContext sc) Ensures that the specified function expression is (not) updating.final <T extends Expr>
TcopyType(T expr) Copies this expression's type to the specified expression.protected final ValuectxValue(QueryContext qc) Returns the current context value or throws an exception if the context value is not set.final Itemebv(QueryContext qc, InputInfo ii) Checks if the effective boolean value can be computed for this expression:item(QueryContext qc, InputInfo ii) Evaluates the expression and returns the resulting item, orEmpty.VALUEif the expression yields an empty sequence.iter(QueryContext qc) Evaluates the expression and returns an iterator on the resulting items.final voidrefineType(Expr expr) Refines the expression type.final SeqTypeseqType()Returns the static type of the resulting value.final longsize()Returns the result size, or-1if the size is unknown.final Itemtest(QueryContext qc, InputInfo ii) Performs a predicate test and returns the item if the test was successful.protected final XQArraytoArray(Expr expr, QueryContext qc) Checks if the specified expression yields an array.protected final XQArrayAssures that the specified item item is an array.protected final ItemtoAtomItem(Expr expr, QueryContext qc) Checks if the evaluated expression yields a non-empty item.protected final B64toB64(Expr expr, QueryContext qc, boolean empty) Checks if the specified expression yields a Base64 item.protected final B64Checks if the specified item is a Base64 item.protected final BintoBin(Expr expr, QueryContext qc) Checks if the specified expression yields a binary item.protected final BinChecks if the specified item is a binary item.protected final booleantoBoolean(Expr expr, QueryContext qc) Checks if the specified expression yields a boolean.protected final booleanChecks if the specified item is a boolean.protected final byte[]toBytes(Expr expr, QueryContext qc) Checks if the specified expression yields a string or binary item.protected final byte[]Checks if the specified item is a string or binary item.protected final doubletoDouble(Expr expr, QueryContext qc) Checks if the specified expression yields a double.protected final doubleChecks if the specified item is a double.protected final ANodetoElem(Expr expr, QueryContext qc) Checks if the specified expression yields an element.protected final floattoFloat(Expr expr, QueryContext qc) Checks if the specified expression yields a float.protected final FItemtoFunc(Expr expr, QueryContext qc) Checks if the specified expression yields a function.protected final ItemtoItem(Expr expr, QueryContext qc) Checks if the evaluated expression yields a non-empty item.protected final ItemtoItem(Expr expr, QueryContext qc, Type type) Checks if the specified expression yields a non-empty item.protected final longtoLong(Expr expr, QueryContext qc) Checks if the specified expression yields an integer.protected final longChecks if the specified item is an integer.protected final XQMaptoMap(Expr expr, QueryContext qc) Checks if the specified expression yields a map.protected final XQMapChecks if the specified item is a map.protected final ANodetoNode(Expr expr, QueryContext qc) Checks if the specified expression yields a node.protected final ANodeChecks if the specified non-empty item is a node.protected final ANodetoNodeOrNull(Expr expr, QueryContext qc) Checks if the specified expression yields a node ornull.protected final ANumChecks if the specified, non-empty item is a double.protected final ANumtoNumberOrNull(Expr expr, QueryContext qc) Checks if the specified expression yields a number ornull.protected final QNmtoQNm(Expr expr, QueryContext qc, boolean empty) Checks if the specified expression yields a QName.protected final QNmChecks if the specified item is a QName.protected final byte[]toToken(Expr expr, QueryContext qc) Checks if the specified expression yields a string.protected final byte[]Checks if the specified non-empty item is a string.protected final byte[]toTokenOrNull(Expr expr, QueryContext qc) Checks if the specified expression yields a string or an empty sequence.protected final byte[]toZeroToken(Expr expr, QueryContext qc) Checks if the specified expression yields a string or an empty sequence.value(QueryContext qc) Evaluates the expression and returns the resulting value.Methods inherited from class org.basex.query.expr.Expr
accept, arg, args, atomItem, atomIter, checkUp, compile, copy, count, data, data, ddo, equals, exprSize, funcType, has, hasFreeVars, indexAccessible, inline, inlineable, isSimple, markTailCalls, mergeEbv, optimize, simplifyFor, typeCheck, uses, vacuous, visitAllMethods inherited from class org.basex.query.expr.ExprInfo
description, plan, plan, toErrorString, toString
-
Field Details
-
exprType
Expression type. -
info
Input information.
-
-
Constructor Details
-
ParseExpr
Constructor.- Parameters:
info- input info (can benullseqType- sequence type
-
-
Method Details
-
iter
Description copied from class:ExprEvaluates the expression and returns an iterator on the resulting items. The implementation of this method is optional.- Specified by:
iterin classExpr- Parameters:
qc- query context- Returns:
- iterator
- Throws:
QueryException- query exception
-
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.- Specified by:
valuein classExpr- Parameters:
qc- query context- Returns:
- value
- Throws:
QueryException- query exception
-
item
Description copied from class:ExprEvaluates the expression and returns the resulting item, orEmpty.VALUEif the expression yields an empty sequence. If this method is not implemented,Expr.value(QueryContext)must be implemented instead.- Specified by:
itemin classExpr- Parameters:
qc- query contextii- input info (only required bySeqinstances, which have no input info)- Returns:
- item or
Empty.VALUE - Throws:
QueryException- query exception
-
atomValue
Description copied from class:ExprEvaluates the expression and returns the atomized items.- Specified by:
atomValuein classExpr- Parameters:
qc- query contextii- input info (only required bySeqinstances, which have no input info)- Returns:
- atomized item
- Throws:
QueryException- query exception
-
ebv
Description copied from class:ExprChecks if the effective boolean value can be computed for this expression:
- If it yields an empty sequence,
Bln.FALSEwill be returned. - If it yields a single item, this item will be returned.
- If it yields nodes, the first node will be returned.
- Otherwise, an error will be raised.
A single numeric item may later be evaluated as positional predicate.
- Specified by:
ebvin classExpr- Parameters:
qc- query contextii- input info (required forSeqinstances, which have no input info)- Returns:
- item
- Throws:
QueryException- query exception
- If it yields an empty sequence,
-
test
Description copied from class:ExprPerforms a predicate test and returns the item if the test was successful. The returned item is required for full-text scoring.- Specified by:
testin classExpr- Parameters:
qc- query contextii- input info (required forSeqinstances, which have no input info)- Returns:
- item or
null - Throws:
QueryException- query exception
-
seqType
Description copied from class:ExprReturns the static type of the resulting value. -
size
public final long size()Description copied from class:ExprReturns the result size, or-1if the size is unknown. -
refineType
Description copied from class:ExprRefines the expression type.- Specified by:
refineTypein classExpr- Parameters:
expr- original expression
-
copyType
Copies this expression's type to the specified expression.- Type Parameters:
T- expression type- Parameters:
expr- expression to be modified- Returns:
- specified expression
-
adoptType
Assigns the type from the specified expression.- Parameters:
expr- expression- Returns:
- self reference
-
checkUp
protected final <T extends XQFunctionExpr> T checkUp(T expr, boolean updating, StaticContext sc) throws QueryException Ensures that the specified function expression is (not) updating. Otherwise, throws an exception.- Type Parameters:
T- expression type- Parameters:
expr- expression (may benull)updating- indicates if expression is expected to be updatingsc- static context- Returns:
- specified expression
- Throws:
QueryException- query exception
-
checkNoUp
Ensures that the specified expression performs no updates. Otherwise, throws an exception.- Parameters:
expr- expression (may benull)- Throws:
QueryException- query exception
-
checkNoneUp
Ensures that none of the specified expressions performs an update. Otherwise, throws an exception.- Parameters:
exprs- expressions (may benull)- Throws:
QueryException- query exception
-
checkAllUp
Ensures that all specified expressions are vacuous or either updating or non-updating. Otherwise, throws an exception.- Parameters:
exprs- expressions to be checked- Throws:
QueryException- query exception
-
ctxValue
Returns the current context value or throws an exception if the context value is not set.- Parameters:
qc- query context- Returns:
- context value
- Throws:
QueryException- query exception
-
toToken
Checks if the specified expression yields a string.- Parameters:
expr- expression to be evaluatedqc- query context- Returns:
- token
- Throws:
QueryException- query exception
-
toZeroToken
Checks if the specified expression yields a string or an empty sequence.- Parameters:
expr- expression to be evaluatedqc- query context- Returns:
- token (zero-length if result is an empty sequence)
- Throws:
QueryException- query exception
-
toTokenOrNull
Checks if the specified expression yields a string or an empty sequence.- Parameters:
expr- expression to be evaluatedqc- query context- Returns:
- token, or
nullif result is an empty sequence - Throws:
QueryException- query exception
-
toToken
Checks if the specified non-empty item is a string.- Parameters:
item- item to be checked- Returns:
- token
- Throws:
QueryException- query exception
-
toBoolean
Checks if the specified expression yields a boolean.- Parameters:
expr- expression to be evaluatedqc- query context- Returns:
- boolean
- Throws:
QueryException- query exception
-
toBoolean
Checks if the specified item is a boolean.- Parameters:
item- item be checked- Returns:
- boolean
- Throws:
QueryException- query exception
-
toDouble
Checks if the specified expression yields a double.- Parameters:
expr- expression to be evaluatedqc- query context- Returns:
- double
- Throws:
QueryException- query exception
-
toDouble
Checks if the specified item is a double.- Parameters:
item- item- Returns:
- double
- Throws:
QueryException- query exception
-
toNumberOrNull
Checks if the specified expression yields a number ornull.- Parameters:
expr- expression to be evaluatedqc- query context- Returns:
- double or
null - Throws:
QueryException- query exception
-
toNumber
Checks if the specified, non-empty item is a double.- Parameters:
item- item to be checked- Returns:
- number
- Throws:
QueryException- query exception
-
toFloat
Checks if the specified expression yields a float.- Parameters:
expr- expression to be evaluatedqc- query context- Returns:
- float
- Throws:
QueryException- query exception
-
toLong
Checks if the specified expression yields an integer.- Parameters:
expr- expression to be evaluatedqc- query context- Returns:
- integer value
- Throws:
QueryException- query exception
-
toLong
Checks if the specified item is an integer.- Parameters:
item- item to be checked- Returns:
- number
- Throws:
QueryException- query exception
-
toNode
Checks if the specified expression yields a node.- Parameters:
expr- expression to be evaluatedqc- query context- Returns:
- node
- Throws:
QueryException- query exception
-
toNodeOrNull
Checks if the specified expression yields a node ornull.- Parameters:
expr- expression to be evaluatedqc- query context- Returns:
- node or
null - Throws:
QueryException- query exception
-
toNode
Checks if the specified non-empty item is a node.- Parameters:
item- item to be checked- Returns:
- node
- Throws:
QueryException- query exception
-
toItem
Checks if the evaluated expression yields a non-empty item.- Parameters:
expr- expression to be evaluatedqc- query context- Returns:
- item
- Throws:
QueryException- query exception
-
toItem
Checks if the specified expression yields a non-empty item.- Parameters:
expr- expression to be evaluatedqc- query contexttype- expected type- Returns:
- item
- Throws:
QueryException- query exception
-
toAtomItem
Checks if the evaluated expression yields a non-empty item.- Parameters:
expr- expression to be evaluatedqc- query context- Returns:
- atomized item
- Throws:
QueryException- query exception
-
toElem
Checks if the specified expression yields an element.- Parameters:
expr- expression to be evaluatedqc- query context- Returns:
- element
- Throws:
QueryException- query exception
-
toBin
Checks if the specified expression yields a binary item.- Parameters:
expr- expression to be evaluatedqc- query context- Returns:
- binary item
- Throws:
QueryException- query exception
-
toBin
Checks if the specified item is a binary item.- Parameters:
item- item to be checked- Returns:
- binary item
- Throws:
QueryException- query exception
-
toBytes
Checks if the specified expression yields a string or binary item.- Parameters:
expr- expression to be evaluatedqc- query context- Returns:
- byte array
- Throws:
QueryException- query exception
-
toB64
Checks if the specified expression yields a Base64 item.- Parameters:
empty- allow empty resultexpr- expression to be evaluatedqc- query context- Returns:
- Base64 item
- Throws:
QueryException- query exception
-
toB64
Checks if the specified item is a Base64 item.- Parameters:
empty- allow empty resultitem- item- Returns:
- Base64 item, or
nullif the argument is an empty sequence and ifemptyis true - Throws:
QueryException- query exception
-
toBytes
Checks if the specified item is a string or binary item.- Parameters:
item- item to be checked- Returns:
- byte array
- Throws:
QueryException- query exception
-
toQNm
Checks if the specified expression yields a QName.- Parameters:
expr- expression to be evaluatedqc- query contextempty- allow empty result- Returns:
- QName
- Throws:
QueryException- query exception
-
toQNm
Checks if the specified item is a QName.- Parameters:
item- itemempty- allow empty result- Returns:
- QName, or
nullif the item isnullandemptyis true - Throws:
QueryException- query exception
-
toFunc
Checks if the specified expression yields a function.- Parameters:
expr- expression to be evaluatedqc- query context- Returns:
- function item
- Throws:
QueryException- query exception
-
toMap
Checks if the specified expression yields a map.- Parameters:
expr- expressionqc- query context- Returns:
- map
- Throws:
QueryException- query exception
-
toMap
Checks if the specified item is a map.- Parameters:
item- item to check- Returns:
- map
- Throws:
QueryException- if the item is not a map
-
toArray
Checks if the specified expression yields an array.- Parameters:
expr- expressionqc- query context- Returns:
- array
- Throws:
QueryException- query exception
-
toArray
Assures that the specified item item is an array.- Parameters:
item- item to check- Returns:
- the array
- Throws:
QueryException- if the item is not an array
-
checkType
Checks if the specified expression yields an item of the specified atomic type.- Parameters:
expr- expression to be evaluatedqc- query contexttype- type to be checked- Returns:
- item
- Throws:
QueryException- query exception
-
checkType
Checks if the specified expression is an empty sequence; if yes, throws an exception.- Parameters:
item- item to be checkedtype- type to be checked- Returns:
- specified item
- Throws:
QueryException- query exception
-
checkNoEmpty
Checks if the specified item is no empty sequence.- Parameters:
item- item to be checked- Returns:
- specified item
- Throws:
QueryException- query exception
-
checkNoEmpty
Checks if the specified item is no empty sequence.- Parameters:
item- item to be checkedtype- expected type- Returns:
- specified item
- Throws:
QueryException- query exception
-