## org.h2.expression
Class Expression

    java.lang.Object
      org.h2.expression.Expression

Direct Known Subclasses:
  Aggregate, Alias, CompareLike, Comparison, ConditionAndOr, ConditionExists, ConditionIn, ConditionInConstantSet, ConditionInSelect, ConditionNot, ExpressionColumn, ExpressionList, Function, JavaAggregate, JavaFunction, Operation, Parameter, Rownum, SequenceValue, Subquery, ValueExpression, Variable, Wildcard

    public abstract class Expression

extends java.lang.Object

An expression is a operation, a value, or a function in a query.

Constructor Summary
`Expression()`

Method Summary
`void` `addFilterConditions(TableFilter filter, boolean outerJoin)` 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.
`java.lang.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.
`abstract int` `getDisplaySize()` Get the display size of this expression.
`Expression[]` `getExpressionColumns(Session session)` If this expression consists of column expressions it should return them.
`static Expression[]` `getExpressionColumns(Session session, java.sql.ResultSet rs)` Extracts expression columns from the given result set.
`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.
`abstract long` `getPrecision()` Get the precision of this expression.
`abstract int` `getScale()` Get the scale of this expression.
`java.lang.String` `getSchemaName()` Get the schema name, or null
`abstract java.lang.String` `getSQL()` Get the SQL statement of this expression.
`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 int` `getType()` Return the data type.
`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` `isValueSet()` Is the value of a parameter set.
`boolean` `isWildcard()` Only returns true if the expression is a wildcard.
`abstract void` `mapColumns(ColumnResolver resolver, int level)` 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)` Update an aggregate value.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### Expression

    public Expression()

Method Detail

### getValue

    public abstract Value getValue(Session session)

  Return the resulting value for the current row.

  Parameters:
    `session` - the session
  Returns:
    the result

### getType

    public abstract int getType()

  Return the data type. The data type may not be known before the optimization phase.

  Returns:
    the type

### mapColumns

    public abstract void mapColumns(ColumnResolver resolver,
                                    int level)

  Map the columns of the resolver to expression columns.

  Parameters:
    `resolver` - the column resolver
    `level` - the subquery nesting level

### optimize

    public abstract Expression optimize(Session session)

  Try to optimize the expression.

  Parameters:
    `session` - the session
  Returns:
    the optimized expression

### setEvaluatable

    public abstract void setEvaluatable(TableFilter tableFilter,
                                        boolean value)

  Tell the expression columns whether the table filter can return values now. This is used when optimizing the query.

  Parameters:
    `tableFilter` - the table filter
    `value` - true if the table filter can return value

### getScale

    public abstract int getScale()

  Get the scale of this expression.

  Returns:
    the scale

### getPrecision

    public abstract long getPrecision()

  Get the precision of this expression.

  Returns:
    the precision

### getDisplaySize

    public abstract int getDisplaySize()

  Get the display size of this expression.

  Returns:
    the display size

### getSQL

    public abstract java.lang.String getSQL()

  Get the SQL statement of this expression. This may not always be the original SQL statement, specially after optimization.

  Returns:
    the SQL statement

### updateAggregate

    public abstract void updateAggregate(Session session)

  Update an aggregate value. This method is called at statement execution time. It is usually called once for each row, but if the expression is used multiple times (for example in the column list, and as part of the HAVING expression) it is called multiple times - the row counter needs to be used to make sure the internal state is only updated once.

  Parameters:
    `session` - the session

### isEverything

    public abstract boolean isEverything(ExpressionVisitor visitor)

  Check if this expression and all sub-expressions can fulfill a criteria. If any part returns false, the result is false.

  Parameters:
    `visitor` - the visitor
  Returns:
    if the criteria can be fulfilled

### getCost

    public abstract int getCost()

  Estimate the cost to process the expression. Used when optimizing the query, to calculate the query plan with the lowest estimated cost.

  Returns:
    the estimated cost

### getNotIfPossible

    public Expression getNotIfPossible(Session session)

  If it is possible, return the negated expression. This is used to optimize NOT expressions: NOT ID>10 can be converted to ID<=10. Returns null if negating is not possible.

  Parameters:
    `session` - the session
  Returns:
    the negated expression, or null

### isConstant

    public boolean isConstant()

  Check if this expression will always return the same value.

  Returns:
    if the expression is constant

### isValueSet

    public boolean isValueSet()

  Is the value of a parameter set.

  Returns:
    true if set

### isAutoIncrement

    public boolean isAutoIncrement()

  Check if this is an auto-increment column.

  Returns:
    true if it is an auto-increment column

### getBooleanValue

    public java.lang.Boolean getBooleanValue(Session session)

  Get the value in form of a boolean expression. Returns true, false, or null. In this database, everything can be a condition.

  Parameters:
    `session` - the session
  Returns:
    the result

### createIndexConditions

    public void createIndexConditions(Session session,
                                      TableFilter filter)

  Create index conditions if possible and attach them to the table filter.

  Parameters:
    `session` - the session
    `filter` - the table filter

### getColumnName

    public java.lang.String getColumnName()

  Get the column name or alias name of this expression.

  Returns:
    the column name

### getSchemaName

    public java.lang.String getSchemaName()

  Get the schema name, or null

  Returns:
    the schema name

### getTableName

    public java.lang.String getTableName()

  Get the table name, or null

  Returns:
    the table name

### getNullable

    public int getNullable()

  Check whether this expression is a column and can store NULL.

  Returns:
    whether NULL is allowed

### getTableAlias

    public java.lang.String getTableAlias()

  Get the table alias name or null if this expression does not represent a column.

  Returns:
    the table alias name

### getAlias

    public java.lang.String getAlias()

  Get the alias name of a column or SQL expression if it is not an aliased expression.

  Returns:
    the alias name

### isWildcard

    public boolean isWildcard()

  Only returns true if the expression is a wildcard.

  Returns:
    if this expression is a wildcard

### getNonAliasExpression

    public Expression getNonAliasExpression()

  Returns the main expression, skipping aliases.

  Returns:
    the expression

### addFilterConditions

    public void addFilterConditions(TableFilter filter,
                                    boolean outerJoin)

  Add conditions to a table filter if they can be evaluated.

  Parameters:
    `filter` - the table filter
    `outerJoin` - if the expression is part of an outer join

### toString

    public java.lang.String toString()

  Convert this expression to a String.

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    the string representation

### getExpressionColumns

    public Expression[] getExpressionColumns(Session session)

  If this expression consists of column expressions it should return them.

  Parameters:
    `session` - the session
  Returns:
    array of expression columns if applicable, null otherwise

### getExpressionColumns

    public static Expression[] getExpressionColumns(Session session,
                                                    java.sql.ResultSet rs)

  Extracts expression columns from the given result set.

  Parameters:
    `session` - the session
    `rs` - the result set
  Returns:
    an array of expression columns