Package org.basex.query.var
Class Var
java.lang.Object
org.basex.query.expr.ExprInfo
org.basex.query.var.Var
Variable expression.
- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen, Leo Woerteler
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionVar(QNm name, SeqType declType, boolean param, int slot, QueryContext qc, StaticContext sc, InputInfo info) Constructor for a variable with an already known stack slot.Var(QNm name, SeqType declType, boolean param, QueryContext qc, StaticContext sc, InputInfo info) Constructor.Var(Var var, QueryContext qc, StaticContext sc) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanadoptCheck(SeqType st, boolean prom) Tries to adopt the given type check.checked(Expr expr, CompileContext cc) Returns an equivalent to the given expression that checks this variable's type.booleanDetermines if this variable checks the type of the expression bound to it.voidChecks if the type of the specified expression could be converted to the sequence type of this variable.checkType(Value value, QueryContext qc, boolean opt) Checks the type of this value and casts/promotes it when necessary.data()Returns the data reference bound to this variable.booleanddo()Returns the distinct document order flag.Declared type of this variable.booleanvoidAttaches an input expression.inthashCode()byte[]id()Returns a unique representation of the variable.booleanChecks whether the given variable is identical to this one, i.e.voidCreates a query plan.voidplan(QueryString qs) Creates a query string.booleanpromotes()Checks if this variable performs function conversion on its bound values.voidrefineType(SeqType st, long size, CompileContext cc) Tries to refine the type of this variable through the type of the bound expression.voidrefineType(SeqType st, CompileContext cc) Tries to refine the type of this variable through the type of the bound expression.seqType()Sequence type of values bound to this variable.longsize()Returns the result size.Returns a string representation of the expression that can be embedded in error messages.Methods inherited from class org.basex.query.expr.ExprInfo
description, toString
-
Field Details
-
name
Variable name. -
id
public final int idVariable ID. -
info
Input info. -
declType
Declared type,nullif not specified. -
promote
public boolean promoteFlag for function conversion.
-
-
Constructor Details
-
Var
public Var(QNm name, SeqType declType, boolean param, int slot, QueryContext qc, StaticContext sc, InputInfo info) Constructor for a variable with an already known stack slot.- Parameters:
name- variable namedeclType- declared type,nullfor no checkparam- function parameter flagslot- stack slotqc- query context, used for generating a variable IDsc- static contextinfo- input info
-
Var
public Var(QNm name, SeqType declType, boolean param, QueryContext qc, StaticContext sc, InputInfo info) Constructor.- Parameters:
name- variable namedeclType- declared sequence type,nullfor no checkparam- function parameter flagqc- query context, used for generating a variable IDsc- static contextinfo- input info
-
Var
Copy constructor.- Parameters:
var- variable to copyqc- query contextsc- static context
-
-
Method Details
-
seqType
Sequence type of values bound to this variable.- Returns:
- sequence type
-
expr
Attaches an input expression.- Parameters:
expr- input expression
-
size
public long size()Returns the result size.- Returns:
- result size
-
ddo
public boolean ddo()Returns the distinct document order flag. SeeExpr.ddo()for details.- Returns:
- result of check
-
data
Returns the data reference bound to this variable. SeeExpr.data()for details.- Returns:
- data reference (can be
null)
-
declaredType
Declared type of this variable.- Returns:
- declared type
-
refineType
Tries to refine the type of this variable through the type of the bound expression.- Parameters:
st- sequence type of the bound expressioncc- compilation context (can benull)- Throws:
QueryException- query exception
-
refineType
Tries to refine the type of this variable through the type of the bound expression.- Parameters:
st- sequence type of the bound expressionsize- size (can be-1)cc- compilation context (can benull)- Throws:
QueryException- query exception
-
checksType
public boolean checksType()Determines if this variable checks the type of the expression bound to it.- Returns:
trueif the type is checked or promoted,falseotherwise
-
checked
Returns an equivalent to the given expression that checks this variable's type.- Parameters:
expr- expressioncc- compilation context- Returns:
- checked expression
- Throws:
QueryException- query exception
-
checkType
Checks the type of this value and casts/promotes it when necessary.- Parameters:
value- value to be checkedqc- query contextopt- if the result should be optimized- Returns:
- checked and possibly cast value
- Throws:
QueryException- if the check failed
-
checkType
Checks if the type of the specified expression could be converted to the sequence type of this variable. Due to insufficient typing, the check will only be performed if:- The variable type is an instance of the specified type. This way, expressions with super types like item() will not be rejected.
- The expression is to be promoted, and it is not of type node (eg: function-declaration-016)
- Parameters:
expr- expression- Throws:
QueryException- query exception
-
is
Checks whether the given variable is identical to this one, i.e. has the same id.- Parameters:
var- variable to check- Returns:
trueif the IDs are equal,falseotherwise
-
promotes
public boolean promotes()Checks if this variable performs function conversion on its bound values.- Returns:
- result of check
-
hashCode
public int hashCode() -
adoptCheck
Tries to adopt the given type check.- Parameters:
st- type to checkprom- if function conversion should be applied- Returns:
trueif the check could be adopted,falseotherwise
-
equals
-
plan
Description copied from class:ExprInfoCreates a query plan. -
id
public byte[] id()Returns a unique representation of the variable.- Returns:
- variable id
-
plan
Description copied from class:ExprInfoCreates a query string. -
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
-