org.d2rq.db.expr
Class Expression

java.lang.Object
  extended by org.d2rq.db.expr.Expression
Direct Known Subclasses:
BinaryOperator, BooleanToIntegerCaseExpression, ColumnExpr, ColumnListEquality, Concatenation, Conjunction, Constant, Disjunction, Negation, NotNull, SQLExpression, UnaryMinus

public abstract class Expression
extends Object

A SQL expression. TODO: Should introduce an ExpressionVisitor and replace most methods with implementations of that

Author:
Richard Cyganiak (richard@cyganiak.de)

Field Summary
static Expression FALSE
           
static Expression TRUE
           
 
Constructor Summary
Expression()
           
 
Method Summary
 Expression and(Expression other)
           
abstract  Set<ColumnName> getColumns()
           
abstract  DataType getDataType(DatabaseOp table, Vendor vendor)
           
abstract  boolean isConstant()
           
abstract  boolean isConstantColumn(ColumnName column, boolean constIfTrue, boolean constIfFalse, boolean constIfConstantValue)
          Checks whether this expression forces a given column to be a constant, that is, have the same value everywhere.
abstract  boolean isFalse()
           
abstract  boolean isTrue()
           
 Expression or(Expression other)
           
abstract  Expression rename(Renamer columnRenamer)
           
abstract  String toSQL(DatabaseOp table, Vendor vendor)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRUE

public static final Expression TRUE

FALSE

public static final Expression FALSE
Constructor Detail

Expression

public Expression()
Method Detail

isTrue

public abstract boolean isTrue()

isFalse

public abstract boolean isFalse()

isConstant

public abstract boolean isConstant()

isConstantColumn

public abstract boolean isConstantColumn(ColumnName column,
                                         boolean constIfTrue,
                                         boolean constIfFalse,
                                         boolean constIfConstantValue)
Checks whether this expression forces a given column to be a constant, that is, have the same value everywhere. For example, T.COL1=5 forces T.COL1 to be constant if the expression is assumed to be true; T.COL1+1 forces it to be constant if the expression is assumed to evaluate to a constant value. Exactly one of the three constXXX arguments must be true, the other two must be false.

Parameters:
column - The column to be checked
constIfTrue - Is the column constant assuming the expression evaluates to true?
constIfFalse - Is the column constant assuming the expression evaluates to false?
constIfConstantValue - Is column constant assuming the expression evaluates to a value equal to some constant?

getColumns

public abstract Set<ColumnName> getColumns()

rename

public abstract Expression rename(Renamer columnRenamer)

getDataType

public abstract DataType getDataType(DatabaseOp table,
                                     Vendor vendor)

toSQL

public abstract String toSQL(DatabaseOp table,
                             Vendor vendor)

and

public Expression and(Expression other)

or

public Expression or(Expression other)