Skip to content

Commit

Permalink
2012-09-30
Browse files Browse the repository at this point in the history
1,增加对between and 的支持
2,修改不需要解析的bug
3,修改解析器delegate
4,增加对db2分页获取数据的支持
  • Loading branch information
akwei committed Sep 30, 2012
1 parent 44aaea4 commit 5f8dc17
Show file tree
Hide file tree
Showing 13 changed files with 6,486 additions and 6,830 deletions.
5 changes: 5 additions & 0 deletions releasenote.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2012-09-30
1,增加对between and 的支持
2,修改不需要解析的bug
3,修改解析器delegate
4,增加对db2分页获取数据的支持
2012-07-18
1,支持sql中使用column_name='a' column_name=sysdate() 的赋值方式,但是此column_name的值不能作为分区关键字使用
2,添加当使用 PartitionParser 进行解析时,返回null的提示
Expand Down
78 changes: 31 additions & 47 deletions src/main/java/halo/dal/analysis/antlr/AntlrParserDelegate.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,61 +9,45 @@
*/
public interface AntlrParserDelegate {

int SQLOP_INSERT = 1;
int SQLOP_INSERT = 1;

int SQLOP_UPDATE = 2;
int SQLOP_UPDATE = 2;

int SQLOP_DELETE = 3;
int SQLOP_DELETE = 3;

int SQLOP_SELECT = 4;
int SQLOP_SELECT = 4;

/**
* 设置当前sql操作的方式
*
* @param sqlOp
*/
void setSqlOp(int sqlOp);
/**
* 设置当前sql操作的方式
*
* @param sqlOp
*/
void setSqlOp(int sqlOp);

int getSqlOp();
int getSqlOp();

/**
* 是否含有from关键字
*
* @param hasSelectFrom
*/
void setHasSelectFrom(boolean hasSelectFrom);
boolean isHasTable();

boolean isHasSelectFrom();
/**
* 当获得表信息时,触发的方法
*
* @param name
* 表名称
* @param alias
*/
void onFindTable(String name, String alias);

/**
* 是否含有between and 关键字
*
* @param hasBetweenAnd
*/
void setHasBetweenAnd(boolean hasBetweenAnd);
/**
* 当获得insert update where 表达式时触发的方法
*
* @param column
* 表达式列名
* @param op
* 表达式符号例如 = >= ...
*/
void onFindColExper(String column, String op);

boolean isHasBetweenAnd();
List<Table> getTables();

/**
* 当获得表信息时,触发的方法
*
* @param name
* 表名称
* @param alias
*/
void onFindTable(String name, String alias);

/**
* 当获得insert update where 表达式时触发的方法
*
* @param column
* 表达式列名
* @param op
* 表达式符号例如 = >= ...
*/
void onFindColExper(String column, String op);

List<Table> getTables();

List<ColExpr> getColExprs();
List<ColExpr> getColExprs();
}
82 changes: 40 additions & 42 deletions src/main/java/halo/dal/analysis/antlr/ColExpr.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,44 @@

public class ColExpr {

private String column;

private String op;

public ColExpr() {
}

/**
* @param column
* columnName不能含有"."
* @param op
*/
public ColExpr(String column, String op) {
this.setColumn(column);
this.setOp(op);
}

public String getColumn() {
return column;
}

/**
* @param column
* columnName不能含有"."
*/
public void setColumn(String column) {
int idx = column.indexOf(".");
if (idx == -1) {
this.column = column;
}
else {
this.column = column.substring(idx + 1);
}
}

public String getOp() {
return op;
}

public void setOp(String op) {
this.op = op;
}
private String column;

private String op;

public ColExpr() {
}

/**
* @param column
* @param op
*/
public ColExpr(String column, String op) {
this.setColumn(column);
this.setOp(op);
}

public String getColumn() {
return column;
}

/**
* @param column
*/
public void setColumn(String column) {
int idx = column.indexOf(".");
if (idx == -1) {
this.column = column;
}
else {
this.column = column.substring(idx + 1);
}
}

public String getOp() {
return op;
}

public void setOp(String op) {
this.op = op;
}
}
71 changes: 34 additions & 37 deletions src/main/java/halo/dal/analysis/antlr/DefAntlrParserDelegate.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,50 @@

public class DefAntlrParserDelegate implements AntlrParserDelegate {

private List<Table> tables = new ArrayList<Table>();
private List<Table> tables = new ArrayList<Table>();

private List<ColExpr> colExprs = new ArrayList<ColExpr>();
private List<ColExpr> colExprs = new ArrayList<ColExpr>();

private boolean hasBetweenAnd;
private boolean hasBetweenAnd;

private boolean hasSelectFrom;
private int sqlOp;

private int sqlOp;
public void setSqlOp(int sqlOp) {
this.sqlOp = sqlOp;
}

public void setSqlOp(int sqlOp) {
this.sqlOp = sqlOp;
}
public int getSqlOp() {
return sqlOp;
}

public int getSqlOp() {
return sqlOp;
}
public boolean isHasBetweenAnd() {
return this.hasBetweenAnd;
}

public boolean isHasBetweenAnd() {
return this.hasBetweenAnd;
}
public boolean isHasTable() {
if (this.tables.isEmpty()) {
return false;
}
return true;
}

public boolean isHasSelectFrom() {
return hasSelectFrom;
}
public void setHasBetweenAnd(boolean hasBetweenAnd) {
this.hasBetweenAnd = hasBetweenAnd;
}

public void setHasSelectFrom(boolean hasSelectFrom) {
this.hasSelectFrom = hasSelectFrom;
}
public void onFindTable(String name, String alias) {
tables.add(new Table(name, alias));
}

public void setHasBetweenAnd(boolean hasBetweenAnd) {
this.hasBetweenAnd = hasBetweenAnd;
}
public void onFindColExper(String column, String op) {
colExprs.add(new ColExpr(column, op));
}

public void onFindTable(String name, String alias) {
tables.add(new Table(name, alias));
}
public List<ColExpr> getColExprs() {
return colExprs;
}

public void onFindColExper(String column, String op) {
colExprs.add(new ColExpr(column, op));
}

public List<ColExpr> getColExprs() {
return colExprs;
}

public List<Table> getTables() {
return tables;
}
public List<Table> getTables() {
return tables;
}
}
52 changes: 0 additions & 52 deletions src/main/java/halo/dal/analysis/antlr/MockAntlrParserDelegate.java

This file was deleted.

Loading

0 comments on commit 5f8dc17

Please sign in to comment.