public abstract class Expression
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
MAP_IN_AGGREGATE
State for expressions inside an aggregate for
mapColumns(ColumnResolver, int, int). |
static int |
MAP_IN_WINDOW
State for expressions inside a window function for
mapColumns(ColumnResolver, int, int). |
static int |
MAP_INITIAL
Initial state for
mapColumns(ColumnResolver, int, int). |
| Constructor and Description |
|---|
Expression() |
| Modifier and Type | Method and Description |
|---|---|
void |
addFilterConditions(TableFilter filter)
Add conditions to a table filter if they can be evaluated.
|
void |
createIndexConditions(Session session,
TableFilter filter)
Create index conditions if possible and attach them to the table filter.
|
java.lang.String |
getAlias()
Get the alias name of a column or SQL expression
if it is not an aliased expression.
|
boolean |
getBooleanValue(Session session)
Get the value in form of a boolean expression.
|
java.lang.String |
getColumnName()
Get the column name or alias name of this expression.
|
abstract int |
getCost()
Estimate the cost to process the expression.
|
Expression[] |
getExpressionColumns(Session session)
If this expression consists of column expressions it should return them.
|
static Expression[] |
getExpressionColumns(Session session,
ResultInterface result)
Extracts expression columns from the given result set.
|
protected static Expression[] |
getExpressionColumns(Session session,
ValueCollectionBase value)
Extracts expression columns from ValueArray
|
Expression |
getNonAliasExpression()
Returns the main expression, skipping aliases.
|
Expression |
getNotIfPossible(Session session)
If it is possible, return the negated expression.
|
int |
getNullable()
Check whether this expression is a column and can store NULL.
|
java.lang.String |
getSchemaName()
Get the schema name, or null
|
java.lang.String |
getSQL(boolean alwaysQuote)
Get the SQL statement of this expression.
|
abstract java.lang.StringBuilder |
getSQL(java.lang.StringBuilder builder,
boolean alwaysQuote)
Appends the SQL statement of this expression to the specified builder.
|
Expression |
getSubexpression(int index)
Returns subexpression with specified index.
|
int |
getSubexpressionCount()
Returns count of subexpressions.
|
java.lang.String |
getTableAlias()
Get the table alias name or null
if this expression does not represent a column.
|
java.lang.String |
getTableName()
Get the table name, or null
|
abstract TypeInfo |
getType()
Returns the data type.
|
java.lang.StringBuilder |
getUnenclosedSQL(java.lang.StringBuilder builder,
boolean alwaysQuote)
Appends the SQL statement of this expression to the specified builder.
|
abstract Value |
getValue(Session session)
Return the resulting value for the current row.
|
boolean |
isAutoIncrement()
Check if this is an auto-increment column.
|
boolean |
isConstant()
Check if this expression will always return the same value.
|
abstract boolean |
isEverything(ExpressionVisitor visitor)
Check if this expression and all sub-expressions can fulfill a criteria.
|
boolean |
isNullConstant()
Check if this expression will always return the NULL value.
|
boolean |
isValueSet()
Is the value of a parameter set.
|
abstract void |
mapColumns(ColumnResolver resolver,
int level,
int state)
Map the columns of the resolver to expression columns.
|
abstract Expression |
optimize(Session session)
Try to optimize the expression.
|
abstract void |
setEvaluatable(TableFilter tableFilter,
boolean value)
Tell the expression columns whether the table filter can return values
now.
|
java.lang.String |
toString()
Convert this expression to a String.
|
abstract void |
updateAggregate(Session session,
int stage)
Update an aggregate value.
|
static void |
writeExpressions(java.lang.StringBuilder builder,
Expression[] expressions,
boolean alwaysQuote)
Get the SQL snippet for an array of expressions.
|
static void |
writeExpressions(java.lang.StringBuilder builder,
java.util.List<? extends Expression> expressions,
boolean alwaysQuote)
Get the SQL snippet for a list of expressions.
|
public static final int MAP_INITIAL
mapColumns(ColumnResolver, int, int).public static final int MAP_IN_WINDOW
mapColumns(ColumnResolver, int, int).public static final int MAP_IN_AGGREGATE
mapColumns(ColumnResolver, int, int).public static void writeExpressions(java.lang.StringBuilder builder,
java.util.List<? extends Expression> expressions,
boolean alwaysQuote)
builder - the builder to append the SQL toexpressions - the list of expressionsalwaysQuote - quote all identifierspublic static void writeExpressions(java.lang.StringBuilder builder,
Expression[] expressions,
boolean alwaysQuote)
builder - the builder to append the SQL toexpressions - the list of expressionsalwaysQuote - quote all identifierspublic abstract Value getValue(Session session)
session - the sessionpublic abstract TypeInfo getType()
public abstract void mapColumns(ColumnResolver resolver, int level, int state)
resolver - the column resolverlevel - the subquery nesting levelstate - current state for nesting checks, initial value is
MAP_INITIALpublic abstract Expression optimize(Session session)
session - the sessionpublic abstract void setEvaluatable(TableFilter tableFilter, boolean value)
tableFilter - the table filtervalue - true if the table filter can return valuepublic java.lang.String getSQL(boolean alwaysQuote)
alwaysQuote - quote all identifierspublic abstract java.lang.StringBuilder getSQL(java.lang.StringBuilder builder,
boolean alwaysQuote)
builder - string builderalwaysQuote - quote all identifierspublic java.lang.StringBuilder getUnenclosedSQL(java.lang.StringBuilder builder,
boolean alwaysQuote)
builder - string builderalwaysQuote - quote all identifierspublic abstract void updateAggregate(Session session, int stage)
session - the sessionstage - select stagepublic abstract boolean isEverything(ExpressionVisitor visitor)
visitor - the visitorpublic abstract int getCost()
public Expression getNotIfPossible(Session session)
session - the sessionpublic boolean isConstant()
public boolean isNullConstant()
public boolean isValueSet()
public boolean isAutoIncrement()
public boolean getBooleanValue(Session session)
session - the sessionpublic void createIndexConditions(Session session, TableFilter filter)
session - the sessionfilter - the table filterpublic java.lang.String getColumnName()
public java.lang.String getSchemaName()
public java.lang.String getTableName()
public int getNullable()
public java.lang.String getTableAlias()
public java.lang.String getAlias()
public Expression getNonAliasExpression()
public void addFilterConditions(TableFilter filter)
filter - the table filterpublic java.lang.String toString()
toString in class java.lang.Objectpublic Expression[] getExpressionColumns(Session session)
session - the sessionprotected static Expression[] getExpressionColumns(Session session, ValueCollectionBase value)
session - the current sessionvalue - the value to extract columns frompublic static Expression[] getExpressionColumns(Session session, ResultInterface result)
session - the sessionresult - the resultpublic int getSubexpressionCount()
public Expression getSubexpression(int index)
index - 0-based indexjava.lang.IndexOutOfBoundsException - if specified index is not valid