public abstract class Expression extends java.lang.Object implements HasSQL, Typed
| Modifier and Type | Field and Description |
|---|---|
static int |
AUTO_PARENTHESES
Wrap expression in parentheses only if it can't be safely included into
other expressions without them.
|
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). |
static int |
WITH_PARENTHESES
Wrap expression in parentheses unconditionally.
|
static int |
WITHOUT_PARENTHESES
Do not wrap expression in parentheses.
|
ADD_PLAN_INFORMATION, DEFAULT_SQL_FLAGS, NO_CASTS, QUOTE_ONLY_WHEN_REQUIRED, REPLACE_LOBS_FOR_TRACE, TRACE_SQL_FLAGS| 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(SessionLocal session,
TableFilter filter)
Create index conditions if possible and attach them to the table filter.
|
java.lang.String |
getAlias(SessionLocal session,
int columnIndex)
Get the alias name of a column or SQL expression
if it is not an aliased expression.
|
boolean |
getBooleanValue(SessionLocal session)
Get the value in form of a boolean expression.
|
java.lang.String |
getColumnName(SessionLocal session,
int columnIndex)
Get the column name or alias name of this expression.
|
java.lang.String |
getColumnNameForView(SessionLocal session,
int columnIndex)
Get the column name of this expression for a view.
|
abstract int |
getCost()
Estimate the cost to process the expression.
|
java.lang.StringBuilder |
getEnclosedSQL(java.lang.StringBuilder builder,
int sqlFlags)
Get the SQL statement of this expression.
|
Expression |
getNonAliasExpression()
Returns the main expression, skipping aliases.
|
Expression |
getNotIfPossible(SessionLocal 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(int sqlFlags)
Get the SQL statement of this expression.
|
java.lang.String |
getSQL(int sqlFlags,
int parentheses)
Get the SQL statement of this expression.
|
java.lang.StringBuilder |
getSQL(java.lang.StringBuilder builder,
int sqlFlags)
Appends the SQL statement of this object to the specified builder.
|
java.lang.StringBuilder |
getSQL(java.lang.StringBuilder builder,
int sqlFlags,
int parentheses)
Get the SQL statement of this expression.
|
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.
|
abstract java.lang.StringBuilder |
getUnenclosedSQL(java.lang.StringBuilder builder,
int sqlFlags)
Get the SQL statement of this expression.
|
abstract Value |
getValue(SessionLocal session)
Return the resulting value for the current row.
|
java.lang.StringBuilder |
getWhenSQL(java.lang.StringBuilder builder,
int sqlFlags)
Appends the SQL statement of this when operand to the specified builder.
|
boolean |
getWhenValue(SessionLocal session,
Value left)
Return the resulting value of when operand for the current row.
|
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 |
isIdentity()
Check if this is an identity column.
|
boolean |
isNullConstant()
Check if this expression will always return the NULL value.
|
boolean |
isValueSet()
Is the value of a parameter set.
|
boolean |
isWhenConditionOperand()
Returns whether this expression is a right side of condition in a when
operand.
|
abstract void |
mapColumns(ColumnResolver resolver,
int level,
int state)
Map the columns of the resolver to expression columns.
|
boolean |
needParentheses()
Returns whether this expressions needs to be wrapped in parentheses when
it is used as an argument of other expressions.
|
abstract Expression |
optimize(SessionLocal session)
Try to optimize the expression.
|
Expression |
optimizeCondition(SessionLocal session)
Try to optimize or remove the condition.
|
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(SessionLocal session,
int stage)
Update an aggregate value.
|
static java.lang.StringBuilder |
writeExpressions(java.lang.StringBuilder builder,
Expression[] expressions,
int sqlFlags)
Get the SQL snippet for an array of expressions.
|
static java.lang.StringBuilder |
writeExpressions(java.lang.StringBuilder builder,
java.util.List<? extends Expression> expressions,
int sqlFlags)
Get the SQL snippet for a list of expressions.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetTraceSQLpublic 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 final int AUTO_PARENTHESES
public static final int WITH_PARENTHESES
public static final int WITHOUT_PARENTHESES
public static java.lang.StringBuilder writeExpressions(java.lang.StringBuilder builder,
java.util.List<? extends Expression> expressions,
int sqlFlags)
builder - the builder to append the SQL toexpressions - the list of expressionssqlFlags - formatting flagspublic static java.lang.StringBuilder writeExpressions(java.lang.StringBuilder builder,
Expression[] expressions,
int sqlFlags)
builder - the builder to append the SQL toexpressions - the list of expressionssqlFlags - formatting flagspublic abstract Value getValue(SessionLocal 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(SessionLocal session)
session - the sessionpublic final Expression optimizeCondition(SessionLocal session)
session - the sessionnullpublic abstract void setEvaluatable(TableFilter tableFilter, boolean value)
tableFilter - the table filtervalue - true if the table filter can return valuepublic final java.lang.String getSQL(int sqlFlags)
HasSQLpublic final java.lang.StringBuilder getSQL(java.lang.StringBuilder builder,
int sqlFlags)
HasSQLpublic final java.lang.String getSQL(int sqlFlags,
int parentheses)
sqlFlags - formatting flagsparentheses - parentheses modepublic final java.lang.StringBuilder getSQL(java.lang.StringBuilder builder,
int sqlFlags,
int parentheses)
builder - string buildersqlFlags - formatting flagsparentheses - parentheses modepublic boolean needParentheses()
true if it ispublic final java.lang.StringBuilder getEnclosedSQL(java.lang.StringBuilder builder,
int sqlFlags)
builder - string buildersqlFlags - formatting flagspublic abstract java.lang.StringBuilder getUnenclosedSQL(java.lang.StringBuilder builder,
int sqlFlags)
builder - string buildersqlFlags - formatting flagspublic abstract void updateAggregate(SessionLocal session, int stage)
session - the sessionstage - select stagepublic abstract boolean isEverything(ExpressionVisitor visitor)
visitor - the visitorpublic abstract int getCost()
public Expression getNotIfPossible(SessionLocal session)
session - the sessionpublic boolean isConstant()
public boolean isNullConstant()
public boolean isValueSet()
public boolean isIdentity()
public boolean getBooleanValue(SessionLocal session)
session - the sessionpublic void createIndexConditions(SessionLocal session, TableFilter filter)
session - the sessionfilter - the table filterpublic java.lang.String getColumnName(SessionLocal session, int columnIndex)
session - the sessioncolumnIndex - 0-based column indexpublic java.lang.String getSchemaName()
public java.lang.String getTableName()
public int getNullable()
public java.lang.String getTableAlias()
public java.lang.String getAlias(SessionLocal session, int columnIndex)
session - the sessioncolumnIndex - 0-based column indexpublic java.lang.String getColumnNameForView(SessionLocal session, int columnIndex)
session - the sessioncolumnIndex - 0-based column indexpublic Expression getNonAliasExpression()
public void addFilterConditions(TableFilter filter)
filter - the table filterpublic java.lang.String toString()
toString in class java.lang.Objectpublic int getSubexpressionCount()
public Expression getSubexpression(int index)
index - 0-based indexjava.lang.IndexOutOfBoundsException - if specified index is not validpublic boolean getWhenValue(SessionLocal session, Value left)
session - the sessionleft - value on the left sidepublic java.lang.StringBuilder getWhenSQL(java.lang.StringBuilder builder,
int sqlFlags)
builder - string buildersqlFlags - formatting flagspublic boolean isWhenConditionOperand()
true if it is, false otherwise