new feature : sql builder

This commit is contained in:
wenshao
2015-06-07 22:36:33 +08:00
parent 7575d5f1ff
commit 3a7d001b93
32 changed files with 921 additions and 125 deletions
@@ -31,8 +31,7 @@ public class SQLOrderBy extends SQLObjectImpl {
public SQLOrderBy(SQLExpr expr){
SQLSelectOrderByItem item = new SQLSelectOrderByItem(expr);
item.setParent(this);
this.items.add(item);
addItem(item);
}
public void addItem(SQLSelectOrderByItem item) {
@@ -71,5 +70,14 @@ public class SQLOrderBy extends SQLObjectImpl {
return items.equals(other.items);
}
public void addItem(SQLExpr expr, SQLOrderingSpecification type) {
SQLSelectOrderByItem item = createItem();
item.setExpr(expr);
item.setType(type);
addItem(item);
}
protected SQLSelectOrderByItem createItem() {
return new SQLSelectOrderByItem();
}
}
@@ -27,7 +27,12 @@ public class SQLExprTableSource extends SQLTableSourceImpl {
}
public SQLExprTableSource(SQLExpr expr){
this(expr, null);
}
public SQLExprTableSource(SQLExpr expr, String alias){
this.setExpr(expr);
this.setAlias(alias);
}
public SQLExpr getExpr() {
@@ -82,6 +82,11 @@ public class SQLSelectQueryBlock extends SQLObjectImpl implements SQLSelectQuery
public List<SQLSelectItem> getSelectList() {
return this.selectList;
}
public void addSelectItem(SQLSelectItem item) {
this.selectList.add(item);
item.setParent(this);
}
public SQLTableSource getFrom() {
return this.from;
@@ -75,6 +75,11 @@ public class SQLUpdateStatement extends SQLStatementImpl {
public List<SQLUpdateSetItem> getItems() {
return items;
}
public void addItem(SQLUpdateSetItem item) {
this.items.add(item);
item.setParent(this);
}
@Override
public void output(StringBuffer buf) {