org.apache.empire.db
Class DBCommandExpr

java.lang.Object
  extended by org.apache.empire.commons.ErrorObject
      extended by org.apache.empire.db.DBObject
          extended by org.apache.empire.db.DBExpr
              extended by org.apache.empire.db.DBCommandExpr
All Implemented Interfaces:
ErrorInfo
Direct Known Subclasses:
DBCombinedCmd, DBCommand

public abstract class DBCommandExpr
extends DBExpr

This abstract class handles the creation of the SQL-Commands. There are inner classes to construct different SQL-Commands.


Field Summary
 
Fields inherited from class org.apache.empire.db.DBExpr
CTX_ALIAS, CTX_ALL, CTX_DEFAULT, CTX_FULLNAME, CTX_NAME, CTX_NOPARENTHESES, CTX_VALUE
 
Constructor Summary
DBCommandExpr()
          Constructs an empty DBCommandExpr object
 
Method Summary
 void addSQL(java.lang.StringBuilder buf, long context)
          Creates the SQL-Command.
 void clearOrderBy()
          Clears the list of order by expressions.
 DBColumnExpr getCmdColumn(DBColumnExpr col)
           
 DBColumnExpr getCmdColumn(int i)
           
 java.lang.String getInsertInto(DBTable table)
          Create the insert into SQL-Command which copies data from a select statement to a destination table.
 java.lang.String getInsertInto(DBTable table, java.util.List<DBColumnExpr> columns)
          Create the insert into SQL-Command which copies data from a select statement to a destination table.
 java.lang.String getSelect()
          returns an SQL select command for querying records.
abstract  boolean getSelect(java.lang.StringBuilder buf)
           
abstract  DBColumnExpr[] getSelectExprList()
           
 DBCommandExpr intersect(DBCommandExpr other)
          Constructs a new DBCombinedCmd object with this object, the key word= "INTERSECT" and the selected DBCommandExpr.
abstract  boolean isValid()
           
 void orderBy(DBColumnExpr expr)
          This helper function calls the method orderBy(DBColumnExpr, boolean) and sets the second parameter to false,creates a new DBOrderByInfo object and adds it to the Vector 'orderBy'.
 void orderBy(DBColumnExpr expr, boolean desc)
          Creates a new DBOrderByInfo object and add it to the Vector 'orderBy'.
 DBCommandExpr union(DBCommandExpr other)
          Constructs a new DBCombinedCmd object with this object, the key word= "UNION" and the selected DBCommandExpr.
 
Methods inherited from class org.apache.empire.db.DBExpr
addReferencedColumns, getValueClass
 
Methods inherited from class org.apache.empire.db.DBObject
getDatabase
 
Methods inherited from class org.apache.empire.commons.ErrorObject
clearError, getErrorMessage, getErrorParams, getErrorSource, getErrorType, getMessage, hasError, isExceptionsEnabled, setExceptionsEnabled
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBCommandExpr

public DBCommandExpr()
Constructs an empty DBCommandExpr object

Method Detail

isValid

public abstract boolean isValid()

getSelect

public abstract boolean getSelect(java.lang.StringBuilder buf)

getSelectExprList

public abstract DBColumnExpr[] getSelectExprList()

getCmdColumn

public DBColumnExpr getCmdColumn(DBColumnExpr col)

getCmdColumn

public DBColumnExpr getCmdColumn(int i)

getSelect

public java.lang.String getSelect()
returns an SQL select command for querying records.

Returns:
the SQL-Command

addSQL

public void addSQL(java.lang.StringBuilder buf,
                   long context)
Creates the SQL-Command.

Specified by:
addSQL in class DBExpr
Parameters:
buf - the SQL-Command
context - the current SQL-Command context

union

public DBCommandExpr union(DBCommandExpr other)
Constructs a new DBCombinedCmd object with this object, the key word= "UNION" and the selected DBCommandExpr.

Parameters:
other - the secend DBCommandExpr
Returns:
the new DBCombinedCmd object
See Also:
DBCombinedCmd

intersect

public DBCommandExpr intersect(DBCommandExpr other)
Constructs a new DBCombinedCmd object with this object, the key word= "INTERSECT" and the selected DBCommandExpr.

Parameters:
other - the secend DBCommandExpr
Returns:
the new DBCombinedCmd object

clearOrderBy

public void clearOrderBy()
Clears the list of order by expressions.


orderBy

public void orderBy(DBColumnExpr expr,
                    boolean desc)
Creates a new DBOrderByInfo object and add it to the Vector 'orderBy'.

Parameters:
expr - the DBColumnExpr object
desc - if true, the results from select statement will sort top down

orderBy

public void orderBy(DBColumnExpr expr)
This helper function calls the method orderBy(DBColumnExpr, boolean) and sets the second parameter to false,creates a new DBOrderByInfo object and adds it to the Vector 'orderBy'.

See Also:
orderBy(DBColumnExpr, boolean)

getInsertInto

public final java.lang.String getInsertInto(DBTable table,
                                            java.util.List<DBColumnExpr> columns)
Create the insert into SQL-Command which copies data from a select statement to a destination table.

Returns:
the insert into SQL-Command

getInsertInto

public final java.lang.String getInsertInto(DBTable table)
Create the insert into SQL-Command which copies data from a select statement to a destination table.

Returns:
the insert into SQL-Command