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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ParseExpr
adoptType(Expr expr)
Assigns the type from the specified expression.Value
atomValue(QueryContext qc, InputInfo ii)
Evaluates the expression and returns the atomized items.protected void
checkAllUp(Expr... exprs)
Ensures that all specified expressions are vacuous or either updating or non-updating.protected Item
checkNoEmpty(Item item)
Returns an item if it is not empty.protected Item
checkNoEmpty(Item item, Type type)
Returns an item if it is not empty.protected void
checkNoneUp(Expr... exprs)
Ensures that none of the specified expressions performs an update.protected void
checkNoUp(Expr expr)
Ensures that the specified expression performs no updates.protected Item
checkType(Expr expr, AtomType type, QueryContext qc)
Evaluates an expression and returns an item if it has the specified type.protected Item
checkType(Item item, Type type)
Returns an item if it has the specified type.protected <T extends XQFunctionExpr>
TcheckUp(T expr, boolean updating, StaticContext sc)
Ensures that the specified function expression is (not) updating.<T extends Expr>
TcopyType(T expr)
Assigns this expression's type to the specified expression.protected Value
ctxValue(QueryContext qc)
Returns the current context value or throws an exception if the context value is not set.Data
data()
Returns the data reference bound to this expression.Item
ebv(QueryContext qc, InputInfo ii)
Checks if the effective boolean value can be computed for this expression:InputInfo
info()
Returns the input info of an expression.Item
item(QueryContext qc, InputInfo ii)
Evaluates the expression and returns the resulting item, orEmpty.VALUE
if the expression yields an empty sequence.Iter
iter(QueryContext qc)
Evaluates the expression and returns an iterator on the resulting items.void
refineType(Expr expr)
Refines the expression type.SeqType
seqType()
Returns the static type of the resulting value.long
size()
Returns the result size, or-1
if the size is unknown.Item
test(QueryContext qc, InputInfo ii)
Performs a predicate test and returns the item if the test was successful.protected XQArray
toArray(Expr expr, QueryContext qc)
Evaluates an expression to an array.protected XQArray
toArray(Item item)
Converts an item to an array.protected Item
toAtomItem(Expr expr, QueryContext qc)
Evaluates an expression to an atomized item of the given type.protected B64
toB64(Expr expr, QueryContext qc, boolean empty)
Evaluates an expression to a Base64 item.protected B64
toB64(Item item, boolean empty)
Converts an item to a base64 item.protected Bin
toBin(Expr expr, QueryContext qc)
Evaluates an expression to a binary item.protected Bin
toBin(Item item)
Converts an item to a binary item.protected boolean
toBoolean(Expr expr, QueryContext qc)
Evaluates an expression to a boolean.protected boolean
toBoolean(Item item)
Converts an item to a boolean.protected byte[]
toBytes(Expr expr, QueryContext qc)
Evaluates an expression (token, binary item) to a byte array.protected byte[]
toBytes(Item item)
Converts an item (token, binary item) to a byte array.protected double
toDouble(Expr expr, QueryContext qc)
Evaluates an expression to a double number.protected double
toDouble(Item item)
Converts an item to a double number.protected ANode
toElem(Expr expr, QueryContext qc)
Evaluates an expression to an element.protected float
toFloat(Expr expr, QueryContext qc)
Evaluates an expression to a float number.protected FItem
toFunction(Expr expr, QueryContext qc)
Evaluates an expression to a function item.protected Item
toItem(Expr expr, QueryContext qc)
Evaluates an expression to an item.protected Item
toItem(Expr expr, QueryContext qc, Type type)
Evaluates an expression to an item of the given type.protected long
toLong(Expr expr, QueryContext qc)
Evaluates an expression to a long number.protected long
toLong(Item item)
Converts an item to an integer number.protected XQMap
toMap(Expr expr, QueryContext qc)
Evaluates an expression to a map.protected XQMap
toMap(Item item)
Converts an item to a map.protected ANode
toNode(Expr expr, QueryContext qc)
Converts an item to a node.protected ANode
toNode(Item item)
Converts an item to a node.protected ANode
toNodeOrNull(Expr expr, QueryContext qc)
Evaluates an expression to a node.protected ANum
toNumber(Item item)
Converts an item to a number.protected ANum
toNumberOrNull(Expr expr, QueryContext qc)
Evaluates an expression to a number.protected QNm
toQNm(Expr expr, boolean empty, QueryContext qc)
Evaluates an expression to a QName.protected QNm
toQNm(Item item, boolean empty)
Converts an item to a QName.protected String
toString(Expr expr, QueryContext qc)
Evaluates an expression to a string.protected String
toString(Item item)
Evaluates an expression to a string.protected String
toStringOrNull(Expr expr, QueryContext qc)
Evaluates an expression to a string.protected byte[]
toToken(Expr expr, QueryContext qc)
Evaluates an expression to a token.protected byte[]
toToken(Item item)
Converts an item to a token.protected byte[]
toTokenOrNull(Expr expr, QueryContext qc)
Evaluates an expression to a token.protected byte[]
toZeroToken(Expr expr, QueryContext qc)
Evaluates an expression to a token.Value
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, ddo, equals, exprSize, funcType, has, hasFreeVars, indexAccessible, inline, inlineable, isSimple, markTailCalls, mergeEbv, optimize, optimizePos, simplify, simplifyFor, typeCheck, uses, vacuous, visitAll
-
Methods inherited from class org.basex.query.expr.ExprInfo
description, toErrorString, toString, toString, toXml
-
-
-
-
Method Detail
-
iter
public Iter iter(QueryContext qc) throws QueryException
Description copied from class:Expr
Evaluates the expression and returns an iterator on the resulting items. The implementation of this method is optional.- Specified by:
iter
in classExpr
- Parameters:
qc
- query context- Returns:
- iterator
- Throws:
QueryException
- query exception
-
value
public Value value(QueryContext qc) throws QueryException
Description copied from class:Expr
Evaluates the expression and returns the resulting value. If this method is not implemented,Expr.item(QueryContext, InputInfo)
must be implemented instead.- Specified by:
value
in classExpr
- Parameters:
qc
- query context- Returns:
- value
- Throws:
QueryException
- query exception
-
item
public Item item(QueryContext qc, InputInfo ii) throws QueryException
Description copied from class:Expr
Evaluates the expression and returns the resulting item, orEmpty.VALUE
if the expression yields an empty sequence. If this method is not implemented,Expr.value(QueryContext)
must be implemented instead.- Specified by:
item
in classExpr
- Parameters:
qc
- query contextii
- input info (only required bySeq
instances, which have no input info)- Returns:
- item or
Empty.VALUE
- Throws:
QueryException
- query exception
-
atomValue
public final Value atomValue(QueryContext qc, InputInfo ii) throws QueryException
Description copied from class:Expr
Evaluates the expression and returns the atomized items.- Specified by:
atomValue
in classExpr
- Parameters:
qc
- query contextii
- input info (only required bySeq
instances, which have no input info)- Returns:
- atomized item
- Throws:
QueryException
- query exception
-
ebv
public final Item ebv(QueryContext qc, InputInfo ii) throws QueryException
Description copied from class:Expr
Checks if the effective boolean value can be computed for this expression:
- If it yields an empty sequence,
Bln.FALSE
will 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:
ebv
in classExpr
- Parameters:
qc
- query contextii
- input info (required forSeq
instances, which have no input info)- Returns:
- item
- Throws:
QueryException
- query exception
- If it yields an empty sequence,
-
test
public final Item test(QueryContext qc, InputInfo ii) throws QueryException
Description copied from class:Expr
Performs a predicate test and returns the item if the test was successful. The returned item is required for full-text scoring.- Specified by:
test
in classExpr
- Parameters:
qc
- query contextii
- input info (required forSeq
instances, which have no input info)- Returns:
- item or
null
- Throws:
QueryException
- query exception
-
seqType
public final SeqType seqType()
Description copied from class:Expr
Returns the static type of the resulting value.
-
size
public final long size()
Description copied from class:Expr
Returns the result size, or-1
if the size is unknown.
-
refineType
public final void refineType(Expr expr)
Description copied from class:Expr
Refines the expression type.- Specified by:
refineType
in classExpr
- Parameters:
expr
- original expression
-
info
public InputInfo info()
Description copied from class:ExprInfo
Returns the input info of an expression.
-
copyType
public final <T extends Expr> T copyType(T expr)
Assigns this expression's type to the specified expression.- Type Parameters:
T
- expression type- Parameters:
expr
- expression to be modified- Returns:
- specified expression
-
adoptType
public final ParseExpr adoptType(Expr expr)
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
protected final void checkNoUp(Expr expr) throws QueryException
Ensures that the specified expression performs no updates. Otherwise, throws an exception.- Parameters:
expr
- expression (may benull
)- Throws:
QueryException
- query exception
-
checkNoneUp
protected final void checkNoneUp(Expr... exprs) throws QueryException
Ensures that none of the specified expressions performs an update. Otherwise, throws an exception.- Parameters:
exprs
- expressions (may benull
)- Throws:
QueryException
- query exception
-
checkAllUp
protected final void checkAllUp(Expr... exprs) throws QueryException
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
protected final Value ctxValue(QueryContext qc) throws QueryException
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
protected final byte[] toToken(Expr expr, QueryContext qc) throws QueryException
Evaluates an expression to a token.- Parameters:
expr
- expressionqc
- query context- Returns:
- token
- Throws:
QueryException
- query exception
-
toZeroToken
protected final byte[] toZeroToken(Expr expr, QueryContext qc) throws QueryException
Evaluates an expression to a token.- Parameters:
expr
- expressionqc
- query context- Returns:
- token (zero-length if result is an empty sequence)
- Throws:
QueryException
- query exception
-
toTokenOrNull
protected final byte[] toTokenOrNull(Expr expr, QueryContext qc) throws QueryException
Evaluates an expression to a token.- Parameters:
expr
- expressionqc
- query context- Returns:
- token, or
null
if the expression yields an empty sequence - Throws:
QueryException
- query exception
-
toToken
protected final byte[] toToken(Item item) throws QueryException
Converts an item to a token.- Parameters:
item
- item to be converted- Returns:
- token
- Throws:
QueryException
- query exception
-
toString
protected final String toString(Expr expr, QueryContext qc) throws QueryException
Evaluates an expression to a string.- Parameters:
expr
- expressionqc
- query context- Returns:
- string
- Throws:
QueryException
- query exception
-
toString
protected final String toString(Item item) throws QueryException
Evaluates an expression to a string.- Parameters:
item
- item to be converted- Returns:
- string
- Throws:
QueryException
- query exception
-
toStringOrNull
protected final String toStringOrNull(Expr expr, QueryContext qc) throws QueryException
Evaluates an expression to a string.- Parameters:
expr
- expressionqc
- query context- Returns:
- string, or
null
if the expression yields an empty sequence - Throws:
QueryException
- query exception
-
toBoolean
protected final boolean toBoolean(Expr expr, QueryContext qc) throws QueryException
Evaluates an expression to a boolean.- Parameters:
expr
- expressionqc
- query context- Returns:
- boolean
- Throws:
QueryException
- query exception
-
toBoolean
protected final boolean toBoolean(Item item) throws QueryException
Converts an item to a boolean.- Parameters:
item
- item to be converted- Returns:
- boolean
- Throws:
QueryException
- query exception
-
toDouble
protected final double toDouble(Expr expr, QueryContext qc) throws QueryException
Evaluates an expression to a double number.- Parameters:
expr
- expressionqc
- query context- Returns:
- double
- Throws:
QueryException
- query exception
-
toDouble
protected final double toDouble(Item item) throws QueryException
Converts an item to a double number.- Parameters:
item
- item- Returns:
- double
- Throws:
QueryException
- query exception
-
toNumberOrNull
protected final ANum toNumberOrNull(Expr expr, QueryContext qc) throws QueryException
Evaluates an expression to a number.- Parameters:
expr
- expressionqc
- query context- Returns:
- number, or
null
if the expression yields an empty sequence - Throws:
QueryException
- query exception
-
toNumber
protected final ANum toNumber(Item item) throws QueryException
Converts an item to a number.- Parameters:
item
- item to be converted- Returns:
- number
- Throws:
QueryException
- query exception
-
toFloat
protected final float toFloat(Expr expr, QueryContext qc) throws QueryException
Evaluates an expression to a float number.- Parameters:
expr
- expressionqc
- query context- Returns:
- float
- Throws:
QueryException
- query exception
-
toLong
protected final long toLong(Expr expr, QueryContext qc) throws QueryException
Evaluates an expression to a long number.- Parameters:
expr
- expressionqc
- query context- Returns:
- integer value
- Throws:
QueryException
- query exception
-
toLong
protected final long toLong(Item item) throws QueryException
Converts an item to an integer number.- Parameters:
item
- item to be converted- Returns:
- number
- Throws:
QueryException
- query exception
-
toNode
protected final ANode toNode(Expr expr, QueryContext qc) throws QueryException
Converts an item to a node.- Parameters:
expr
- expressionqc
- query context- Returns:
- node
- Throws:
QueryException
- query exception
-
toNodeOrNull
protected final ANode toNodeOrNull(Expr expr, QueryContext qc) throws QueryException
Evaluates an expression to a node.- Parameters:
expr
- expressionqc
- query context- Returns:
- node, or
null
if the expression yields an empty sequence - Throws:
QueryException
- query exception
-
toNode
protected final ANode toNode(Item item) throws QueryException
Converts an item to a node.- Parameters:
item
- item to be converted- Returns:
- node
- Throws:
QueryException
- query exception
-
toItem
protected final Item toItem(Expr expr, QueryContext qc) throws QueryException
Evaluates an expression to an item.- Parameters:
expr
- expressionqc
- query context- Returns:
- item
- Throws:
QueryException
- query exception
-
toItem
protected final Item toItem(Expr expr, QueryContext qc, Type type) throws QueryException
Evaluates an expression to an item of the given type.- Parameters:
expr
- expressionqc
- query contexttype
- expected type- Returns:
- item
- Throws:
QueryException
- query exception
-
toAtomItem
protected final Item toAtomItem(Expr expr, QueryContext qc) throws QueryException
Evaluates an expression to an atomized item of the given type.- Parameters:
expr
- expressionqc
- query context- Returns:
- atomized item
- Throws:
QueryException
- query exception
-
toElem
protected final ANode toElem(Expr expr, QueryContext qc) throws QueryException
Evaluates an expression to an element.- Parameters:
expr
- expressionqc
- query context- Returns:
- element
- Throws:
QueryException
- query exception
-
toBin
protected final Bin toBin(Expr expr, QueryContext qc) throws QueryException
Evaluates an expression to a binary item.- Parameters:
expr
- expressionqc
- query context- Returns:
- binary item
- Throws:
QueryException
- query exception
-
toBin
protected final Bin toBin(Item item) throws QueryException
Converts an item to a binary item.- Parameters:
item
- item to be converted- Returns:
- binary item
- Throws:
QueryException
- query exception
-
toBytes
protected final byte[] toBytes(Expr expr, QueryContext qc) throws QueryException
Evaluates an expression (token, binary item) to a byte array.- Parameters:
expr
- expressionqc
- query context- Returns:
- byte array
- Throws:
QueryException
- query exception
-
toB64
protected final B64 toB64(Expr expr, QueryContext qc, boolean empty) throws QueryException
Evaluates an expression to a Base64 item.- Parameters:
empty
- allow empty resultexpr
- expressionqc
- query context- Returns:
- Base64 item
- Throws:
QueryException
- query exception
-
toB64
protected final B64 toB64(Item item, boolean empty) throws QueryException
Converts an item to a base64 item.- Parameters:
empty
- returnnull
if the given item is emptyitem
- item- Returns:
- Base64 item or
null
- Throws:
QueryException
- query exception
-
toBytes
protected final byte[] toBytes(Item item) throws QueryException
Converts an item (token, binary item) to a byte array.- Parameters:
item
- item to be converted- Returns:
- byte array
- Throws:
QueryException
- query exception
-
toQNm
protected final QNm toQNm(Expr expr, boolean empty, QueryContext qc) throws QueryException
Evaluates an expression to a QName.- Parameters:
expr
- expressionempty
- returnnull
if the given item is emptyqc
- query context- Returns:
- QName or
null
- Throws:
QueryException
- query exception
-
toQNm
protected final QNm toQNm(Item item, boolean empty) throws QueryException
Converts an item to a QName.- Parameters:
item
- itemempty
- returnnull
if the given item is empty- Returns:
- QName or
null
- Throws:
QueryException
- query exception
-
toFunction
protected final FItem toFunction(Expr expr, QueryContext qc) throws QueryException
Evaluates an expression to a function item.- Parameters:
expr
- expressionqc
- query context- Returns:
- function item
- Throws:
QueryException
- query exception
-
toMap
protected final XQMap toMap(Expr expr, QueryContext qc) throws QueryException
Evaluates an expression to a map.- Parameters:
expr
- expressionqc
- query context- Returns:
- map
- Throws:
QueryException
- query exception
-
toMap
protected final XQMap toMap(Item item) throws QueryException
Converts an item to a map.- Parameters:
item
- item to check- Returns:
- map
- Throws:
QueryException
- query exception
-
toArray
protected final XQArray toArray(Expr expr, QueryContext qc) throws QueryException
Evaluates an expression to an array.- Parameters:
expr
- expressionqc
- query context- Returns:
- array
- Throws:
QueryException
- query exception
-
toArray
protected final XQArray toArray(Item item) throws QueryException
Converts an item to an array.- Parameters:
item
- item to check- Returns:
- the array
- Throws:
QueryException
- if the item is not an array
-
checkType
protected final Item checkType(Expr expr, AtomType type, QueryContext qc) throws QueryException
Evaluates an expression and returns an item if it has the specified type.- Parameters:
expr
- expressiontype
- expected typeqc
- query context- Returns:
- item
- Throws:
QueryException
- query exception
-
checkType
protected final Item checkType(Item item, Type type) throws QueryException
Returns an item if it has the specified type.- Parameters:
item
- itemtype
- expected type- Returns:
- item
- Throws:
QueryException
- query exception
-
checkNoEmpty
protected final Item checkNoEmpty(Item item) throws QueryException
Returns an item if it is not empty.- Parameters:
item
- item- Returns:
- specified item
- Throws:
QueryException
- query exception
-
checkNoEmpty
protected final Item checkNoEmpty(Item item, Type type) throws QueryException
Returns an item if it is not empty.- Parameters:
item
- itemtype
- expected type- Returns:
- specified item
- Throws:
QueryException
- query exception
-
-