de.mguennewig.pobjects
Class EvalContext

java.lang.Object
  extended by de.mguennewig.pobjects.EvalContext
Direct Known Subclasses:
SQLEvalContext

public abstract class EvalContext
extends java.lang.Object

Internal class to convert the internal term expressions into SQL statements.

Author:
Michael Günnewig
See Also:
Query, Term

Field Summary
static java.lang.String TABLE_PREFIX
           
 
Constructor Summary
EvalContext(int numColumns, int dbCapabilities, java.lang.String schema)
          Creates a new evaluation context.
 
Method Summary
abstract  void addOrderBy(de.mguennewig.pobjects.Query.OrderByExpr orderBy)
           
abstract  void addResult(TableRef tr, Column col)
           
 TableRef addTableExpr(TableExpr table)
           
 void addTableExprColumns(TableRef tr, TableExpr te)
           
abstract  void addWhereConj(Term term)
           
 TableRef deref(TableRef tr, ClassDecl cd, boolean isExtension)
           
abstract  TableRef deref(TableRef tr, ClassDecl te, Column c, boolean join)
           
 TableRef deref(TableRef tr, Column column)
           
 CommandDecl getCommand()
           
 boolean getForCount()
           
 int getLimit()
          Returns the current result set limit.
 int getNumColumns()
           
 int getOffset()
          Returns the current offset within the result set.
abstract  java.util.List<?> getOrderBy()
           
 java.lang.String getSchema()
           
 java.lang.String getSqlType(Type type)
          Returns the SQL type name for the given type.
 int getSupportedJoins()
          Returns the supported outer joins.
 TableRef getTableExpr(int index)
           
abstract  java.util.List<?> getWhereList()
           
 boolean isDistinct()
           
static boolean requiresOuterJoin(Column column)
          Returns whether an outer join is required for the reference column.
 ColumnReference resolveSelector(int baseColumn, Column... selector)
           
abstract  java.lang.String restoreState(EvalState s, Term conj)
           
 void setCommand(CommandDecl cmd)
           
 void setDistinct(boolean distinct)
           
 void setForCount(boolean forCount)
           
 void setLimit(int limit)
          Sets an upper limit of rows returned by the result set.
 void setOffset(int offset)
          Sets the number of results that should be skipped for the result set.
 EvalState storeState()
           
 boolean supportsBoolean()
          Tests whether the database supports booleans natively.
 boolean supportsInherits()
          Tests whether the INHERITS concept is supported.
 boolean supportsLimitOffset()
          Tests whether the keywords LIMIT and OFFSET are supported by the database to limit the result set.
 boolean supportsOracleJoin()
          Tests whether the Oracle join style is supported.
 boolean supportsSQL99Join()
          Tests whether joins after SQL99 are supported.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TABLE_PREFIX

public static final java.lang.String TABLE_PREFIX
See Also:
Constant Field Values
Constructor Detail

EvalContext

public EvalContext(int numColumns,
                   int dbCapabilities,
                   java.lang.String schema)
Creates a new evaluation context.

Method Detail

supportsBoolean

public final boolean supportsBoolean()
Tests whether the database supports booleans natively.

See Also:
Container.SUPPORTS_BOOLEAN

supportsInherits

public final boolean supportsInherits()
Tests whether the INHERITS concept is supported.

See Also:
Container.SUPPORTS_INHERITS

supportsLimitOffset

public final boolean supportsLimitOffset()
Tests whether the keywords LIMIT and OFFSET are supported by the database to limit the result set.


supportsOracleJoin

public final boolean supportsOracleJoin()
Tests whether the Oracle join style is supported.

See Also:
Container.SUPPORTS_ORACLE_JOIN

supportsSQL99Join

public final boolean supportsSQL99Join()
Tests whether joins after SQL99 are supported.

See Also:
Container.SUPPORTS_SQL99_JOIN

getSupportedJoins

public final int getSupportedJoins()
Returns the supported outer joins.

See Also:
Container.SUPPORTS_JOIN

getSchema

public final java.lang.String getSchema()

getNumColumns

public final int getNumColumns()

getOrderBy

public abstract java.util.List<?> getOrderBy()

getWhereList

public abstract java.util.List<?> getWhereList()

isDistinct

public final boolean isDistinct()

setDistinct

public void setDistinct(boolean distinct)

getCommand

public final CommandDecl getCommand()

setCommand

public void setCommand(CommandDecl cmd)

getTableExpr

public final TableRef getTableExpr(int index)

addTableExpr

public TableRef addTableExpr(TableExpr table)

addResult

public abstract void addResult(TableRef tr,
                               Column col)

addTableExprColumns

public void addTableExprColumns(TableRef tr,
                                TableExpr te)

addWhereConj

public abstract void addWhereConj(Term term)

addOrderBy

public abstract void addOrderBy(de.mguennewig.pobjects.Query.OrderByExpr orderBy)

getLimit

public final int getLimit()
Returns the current result set limit.

A limit of a result set can be used together with an offset to implement paging.

A limit of 1 can be used for existence tests.

Returns:
A value of zero or less specifies no limit, otherwise the number of rows to be returned.

setLimit

public void setLimit(int limit)
Sets an upper limit of rows returned by the result set.

Throws:
java.lang.IllegalStateException - if an offset is to be set but no limit is set or no predictable order is specified.
See Also:
addOrderBy(Query.OrderByExpr), getOffset()

getOffset

public final int getOffset()
Returns the current offset within the result set.

Returns:
A value of zero or less specifies no offset, otherwise the number of rows to be skipped.
See Also:
getLimit()

setOffset

public void setOffset(int offset)
Sets the number of results that should be skipped for the result set.

A negative or zero offset value disables the skipping of results.

NOTE: If set to a value greater zero you must also specify a limit.

Throws:
java.lang.IllegalStateException - if an offset is to be set but no limit is set.
See Also:
getLimit()

getForCount

public final boolean getForCount()

setForCount

public void setForCount(boolean forCount)

storeState

public EvalState storeState()

restoreState

public abstract java.lang.String restoreState(EvalState s,
                                              Term conj)

getSqlType

public java.lang.String getSqlType(Type type)
Returns the SQL type name for the given type.

Throws:
java.lang.UnsupportedOperationException - if the type class is not supported.
See Also:
Cast

resolveSelector

public ColumnReference resolveSelector(int baseColumn,
                                       Column... selector)

deref

public final TableRef deref(TableRef tr,
                            Column column)

requiresOuterJoin

public static boolean requiresOuterJoin(Column column)
Returns whether an outer join is required for the reference column.


deref

public final TableRef deref(TableRef tr,
                            ClassDecl cd,
                            boolean isExtension)

deref

public abstract TableRef deref(TableRef tr,
                               ClassDecl te,
                               Column c,
                               boolean join)