mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved sql parser.
This commit is contained in:
@@ -59,6 +59,10 @@ public class SQLBinaryExpr extends SQLExprImpl implements SQLLiteralExpr {
|
||||
return result;
|
||||
}
|
||||
|
||||
public SQLBinaryExpr clone() {
|
||||
return new SQLBinaryExpr(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
|
||||
@@ -83,4 +83,8 @@ public class SQLBooleanExpr extends SQLExprImpl implements SQLExpr, SQLLiteralEx
|
||||
public SQLDataType computeDataType() {
|
||||
return DEFAULT_DATA_TYPE;
|
||||
}
|
||||
|
||||
public SQLBooleanExpr clone() {
|
||||
return new SQLBooleanExpr(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,10 @@ public class SQLDateExpr extends SQLExprImpl implements SQLLiteralExpr {
|
||||
|
||||
}
|
||||
|
||||
public SQLDateExpr(String literal) {
|
||||
this.literal = literal;
|
||||
}
|
||||
|
||||
public String getLiteral() {
|
||||
return literal;
|
||||
}
|
||||
@@ -75,4 +79,7 @@ public class SQLDateExpr extends SQLExprImpl implements SQLLiteralExpr {
|
||||
return true;
|
||||
}
|
||||
|
||||
public SQLDateExpr clone() {
|
||||
return new SQLDateExpr(literal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,4 +39,8 @@ public class SQLDefaultExpr extends SQLExprImpl implements SQLLiteralExpr {
|
||||
public String toString() {
|
||||
return "DEFAULT";
|
||||
}
|
||||
|
||||
public SQLDefaultExpr clone() {
|
||||
return new SQLDefaultExpr();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,4 +80,8 @@ public class SQLHexExpr extends SQLExprImpl implements SQLLiteralExpr {
|
||||
public byte[] toBytes() {
|
||||
return HexBin.decode(this.hex);
|
||||
}
|
||||
|
||||
public SQLHexExpr clone () {
|
||||
return new SQLHexExpr(hex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,20 @@ public class SQLInListExpr extends SQLExprImpl implements Serializable {
|
||||
this.not = not;
|
||||
}
|
||||
|
||||
public SQLInListExpr clone() {
|
||||
SQLInListExpr x = new SQLInListExpr();
|
||||
x.not = not;
|
||||
if (expr != null) {
|
||||
x.setExpr(expr.clone());
|
||||
}
|
||||
for (SQLExpr e : targetList) {
|
||||
SQLExpr e2 = e.clone();
|
||||
e2.setParent(x);
|
||||
x.targetList.add(e2);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
public boolean isNot() {
|
||||
return this.not;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,18 @@ public class SQLInSubQueryExpr extends SQLExprImpl implements Serializable {
|
||||
|
||||
}
|
||||
|
||||
public SQLInSubQueryExpr clone() {
|
||||
SQLInSubQueryExpr x = new SQLInSubQueryExpr();
|
||||
x.not = not;
|
||||
if (expr != null) {
|
||||
x.setExpr(expr.clone());
|
||||
}
|
||||
if (subQuery != null) {
|
||||
x.setSubQuery(subQuery.clone());
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
public boolean isNot() {
|
||||
return not;
|
||||
}
|
||||
|
||||
@@ -75,4 +75,14 @@ public class SQLListExpr extends SQLExprImpl {
|
||||
return true;
|
||||
}
|
||||
|
||||
public SQLListExpr clone() {
|
||||
SQLListExpr x = new SQLListExpr();
|
||||
for (SQLExpr item : items) {
|
||||
SQLExpr item2 = item.clone();
|
||||
item2.setParent(x);
|
||||
x.items.add(item2);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,5 +18,5 @@ package com.alibaba.druid.sql.ast.expr;
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
|
||||
public interface SQLLiteralExpr extends SQLExpr {
|
||||
|
||||
SQLLiteralExpr clone();
|
||||
}
|
||||
|
||||
@@ -26,4 +26,6 @@ public abstract class SQLNumericLiteralExpr extends SQLExprImpl implements SQLLi
|
||||
public abstract Number getNumber();
|
||||
|
||||
public abstract void setNumber(Number number);
|
||||
|
||||
public abstract SQLNumericLiteralExpr clone();
|
||||
}
|
||||
|
||||
@@ -67,4 +67,6 @@ public abstract class SQLTextLiteralExpr extends SQLExprImpl implements SQLLiter
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public abstract SQLTextLiteralExpr clone();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user