|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.empire.commons.ErrorObject
org.apache.empire.db.DBObject
org.apache.empire.db.DBExpr
org.apache.empire.db.DBCommandExpr
org.apache.empire.db.DBCommand
public abstract class DBCommand
This abstract class handles the creation of the SQL-Commands. There are methods to create SQL-Commandos, like update, insert, delete and select.
Nested Class Summary | |
---|---|
static class |
DBCommand.DBCmdParameter
|
Nested classes/interfaces inherited from class org.apache.empire.db.DBCommandExpr |
---|
DBCommandExpr.DBCmdColumn, DBCommandExpr.DBCmdQuery |
Nested classes/interfaces inherited from class org.apache.empire.commons.ErrorObject |
---|
ErrorObject.ObjectErrorInfo |
Field Summary | |
---|---|
protected java.util.Vector<java.lang.Object> |
cmdParams
|
protected java.util.List<DBColumnExpr> |
groupBy
|
protected java.util.List<DBCompareExpr> |
having
|
protected java.util.List<DBJoinExpr> |
joins
|
protected java.util.List<DBColumnExpr> |
select
|
protected boolean |
selectDistinct
|
protected java.util.List<DBSetExpr> |
set
|
protected java.util.List<DBCompareExpr> |
where
|
Fields inherited from class org.apache.empire.db.DBCommandExpr |
---|
cmdQuery, orderBy |
Fields inherited from class org.apache.empire.db.DBExpr |
---|
CTX_ALIAS, CTX_ALL, CTX_DEFAULT, CTX_FULLNAME, CTX_NAME, CTX_NOPARENTHESES, CTX_VALUE, log |
Constructor Summary | |
---|---|
protected |
DBCommand(DBDatabase db)
Constructs a new DBCommand object and set the specified DBDatabase object. |
Method Summary | |
---|---|
DBCommand.DBCmdParameter |
addCmdParam(java.lang.Object item)
Adds an object to in the list of Parameters and returns a parameter object. |
protected void |
addFrom(java.lang.StringBuilder buf)
|
protected void |
addGrouping(java.lang.StringBuilder buf)
|
void |
addJoins(java.util.List<DBJoinExpr> joinExprList)
Adds a list of join expressions to the command. |
protected void |
addOrder(java.lang.StringBuilder buf)
|
void |
addReferencedColumns(java.util.Set<DBColumn> list)
Adds Columns |
protected void |
addSelect(java.lang.StringBuilder buf)
|
protected void |
addWhere(java.lang.StringBuilder buf)
|
void |
addWhereConstraints(java.util.List<DBCompareExpr> constraints)
Adds a list of constraints to the command. |
void |
clear()
Clears the entire command object. |
void |
clearGroupBy()
Clears the list of group by constraints. |
void |
clearHaving()
Clears the list of having constraints. |
void |
clearJoin()
Clears the list of join expressions. |
void |
clearSelect()
Clears the list of selected columns. |
void |
clearSelectDistinct()
Clears the select distinct option. |
void |
clearSet()
Clears the list of set expressions. |
void |
clearWhere()
Clears the list of where constraints. |
DBCommand |
clone()
Creates a clone of this class. |
java.lang.Object[] |
getCmdParams()
Returns the list of parameter values for a prepared statement. |
protected java.lang.Object |
getCmdParamValue(DBColumn col,
java.lang.Object value)
|
DBDatabase |
getDatabase()
Returns the current DBDatabase object. |
java.lang.String |
getDelete(DBTable table)
Creates the delete SQL-Command. |
java.lang.String |
getInsert()
Creates the insert SQL-Command. |
java.util.List<DBJoinExpr> |
getJoins()
Returns a copy of the defined joins. |
boolean |
getSelect(java.lang.StringBuilder buf)
|
DBColumnExpr[] |
getSelectExprList()
Returns a array of all select DBColumnExpr for this command |
protected java.util.List<DBRowSet> |
getTableList()
Gets a list of all tables referenced by the query. |
java.lang.String |
getUpdate()
Creates the update SQL-Command. |
java.util.List<DBCompareExpr> |
getWhereConstraints()
Returns a copy of the defined where clauses. |
void |
groupBy(DBColumnExpr... exprs)
Adds a list of columns to the group by phrase of an sql statement. |
boolean |
hasJoinOn(DBRowSet rowset)
Returns true if the command has a join on the given table or false otherwise. |
boolean |
hasSelectExpr()
Returns true if the command has constaints or false if not. |
protected boolean |
hasSetExprOn(DBColumn column)
checks whether a column is in the list of set expressions |
boolean |
hasWhereConstraints()
Returns true if the command has constaints or false if not. |
void |
having(DBCompareExpr expr)
Sets a having contraint. |
boolean |
isSelectDistinct()
Returns whether or not the select statement will be distinct or not. |
boolean |
isValid()
|
boolean |
isValidQuery()
Returns whether the command object can produce a select sql-statement. |
boolean |
isValidUpdate()
Returns whether the command object can produce a update sql-statement. |
DBJoinExpr |
join(DBColumnExpr left,
DBColumn right)
Adds an inner join based on two columns to the list of join expressions. |
DBJoinExpr |
join(DBColumnExpr left,
DBColumn right,
DBJoinType joinType)
Adds a join based on two columns to the list of join expressions. |
void |
join(DBJoinExpr join)
Adds a join to the list of join expressions. |
DBJoinExpr |
join(DBRowSet rowset,
DBCompareExpr cmp)
Adds an inner join based on a compare expression to the command. |
DBJoinExpr |
join(DBRowSet rowset,
DBCompareExpr cmp,
DBJoinType joinType)
Adds a join based on a compare expression to the command. |
void |
select(java.util.Collection<? extends DBColumnExpr> columns)
Adds a list of columns to the select phrase of an sql statement. |
void |
select(DBColumnExpr... exprs)
Adds a list of columns to the select phrase of an sql statement. |
void |
select(DBColumnExpr expr)
Adds a DBColumnExpr object to the Vector: 'select'. |
void |
selectDistinct()
Sets whether or not the select statement should contain the distinct directive . |
void |
set(DBSetExpr expr)
Inserts DBSetExpr objects to the Vector 'set'. |
boolean |
setCmdParam(int index,
java.lang.Object item)
Sets a object to in the list of Parameters. |
protected void |
setCompare(java.util.List<DBCompareExpr> list,
DBCompareExpr expr)
Compares the DBCompareExpr object with the Elements of the Vector 'where' or 'having'. |
protected boolean |
useCmdParam(DBColumn col)
|
void |
where(DBCompareExpr expr)
Adds a compare expression to the list of constraints. |
Methods inherited from class org.apache.empire.db.DBCommandExpr |
---|
addListExpr, addSQL, clearOrderBy, getCmdColumn, getCmdColumn, getInsertInto, getInsertInto, getInsertInto, getSelect, intersect, orderBy, orderBy, orderBy, union |
Methods inherited from class org.apache.empire.db.DBExpr |
---|
getObjectValue, getValueClass |
Methods inherited from class org.apache.empire.db.DBObject |
---|
error, error |
Methods inherited from class org.apache.empire.commons.ErrorObject |
---|
clearError, clearErrorInfo, error, error, error, error, error, error, error, getErrorInfo, getErrorMessage, getErrorParams, getErrorSource, getErrorType, getMessage, hasError, internalSetError, isExceptionsEnabled, setExceptionsEnabled, success |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected boolean selectDistinct
protected java.util.List<DBColumnExpr> select
protected java.util.List<DBSetExpr> set
protected java.util.List<DBJoinExpr> joins
protected java.util.List<DBCompareExpr> where
protected java.util.List<DBCompareExpr> having
protected java.util.List<DBColumnExpr> groupBy
protected java.util.Vector<java.lang.Object> cmdParams
Constructor Detail |
---|
protected DBCommand(DBDatabase db)
db
- the current database objectMethod Detail |
---|
public DBCommand clone()
clone
in class java.lang.Object
public DBDatabase getDatabase()
getDatabase
in class DBObject
public boolean isValid()
isValid
in class DBCommandExpr
public boolean isValidQuery()
public boolean isValidUpdate()
public void selectDistinct()
public boolean isSelectDistinct()
public void select(DBColumnExpr expr)
expr
- the DBColumnExpr objectpublic void select(DBColumnExpr... exprs)
exprs
- an vararg of DBColumnExpr's to selectpublic void select(java.util.Collection<? extends DBColumnExpr> columns)
columns
- the column expressions to addprotected boolean useCmdParam(DBColumn col)
protected java.lang.Object getCmdParamValue(DBColumn col, java.lang.Object value)
public void set(DBSetExpr expr)
expr
- the DBSetExpr object(s)protected boolean hasSetExprOn(DBColumn column)
column
-
public boolean setCmdParam(int index, java.lang.Object item)
index
- the parameter indexitem
- the parameter value
public DBCommand.DBCmdParameter addCmdParam(java.lang.Object item)
item
- the parameter value
public void join(DBJoinExpr join)
join
- the join expressionpublic DBJoinExpr join(DBColumnExpr left, DBColumn right, DBJoinType joinType)
left
- the left join valueright
- the right joinjoinType
- type of join (DBJoinType.INNER
, DBJoinType.LEFT
, DBJoinType.RIGHT
)
public DBJoinExpr join(DBColumnExpr left, DBColumn right)
left
- the left join valueright
- the right join
public DBJoinExpr join(DBRowSet rowset, DBCompareExpr cmp, DBJoinType joinType)
rowset
- table or view to joincmp
- the compare expression with wich to join the tablejoinType
- type of join (DBJoinType.INNER
, DBJoinType.LEFT
, DBJoinType.RIGHT
)
public DBJoinExpr join(DBRowSet rowset, DBCompareExpr cmp)
rowset
- table of view which to joincmp
- the compare expression with wich to join the table
public void addJoins(java.util.List<DBJoinExpr> joinExprList)
joinExprList
- list of join expressionspublic boolean hasJoinOn(DBRowSet rowset)
rowset
- rowset table or view to join
public void where(DBCompareExpr expr)
expr
- the DBCompareExpr objectpublic boolean hasWhereConstraints()
public java.util.List<DBCompareExpr> getWhereConstraints()
public java.util.List<DBJoinExpr> getJoins()
public void addWhereConstraints(java.util.List<DBCompareExpr> constraints)
constraints
- list of constraintspublic void having(DBCompareExpr expr)
expr
- the DBCompareExpr objectpublic void groupBy(DBColumnExpr... exprs)
exprs
- vararg of columns by which to group the rowspublic boolean hasSelectExpr()
public boolean getSelect(java.lang.StringBuilder buf)
getSelect
in class DBCommandExpr
public DBColumnExpr[] getSelectExprList()
getSelectExprList
in class DBCommandExpr
null
if there are no selectspublic void clearSelectDistinct()
public void clearSelect()
public void clearSet()
public void clearJoin()
public void clearWhere()
public void clearHaving()
public void clearGroupBy()
public void clear()
protected void setCompare(java.util.List<DBCompareExpr> list, DBCompareExpr expr)
list
- the Vector 'where' or 'having'expr
- the DBCompareExpr objectexpr
- the DBCompareExpr objectprotected java.util.List<DBRowSet> getTableList()
public void addReferencedColumns(java.util.Set<DBColumn> list)
addReferencedColumns
in class DBExpr
list
- list to which all used column expressions must be addedpublic java.lang.Object[] getCmdParams()
public java.lang.String getUpdate()
public java.lang.String getInsert()
public java.lang.String getDelete(DBTable table)
table
- the table object
protected void addSelect(java.lang.StringBuilder buf)
protected void addFrom(java.lang.StringBuilder buf)
protected void addWhere(java.lang.StringBuilder buf)
protected void addGrouping(java.lang.StringBuilder buf)
protected void addOrder(java.lang.StringBuilder buf)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |