Skip to content

Commit

Permalink
add testcase & remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Jun 17, 2013
1 parent b199d30 commit 72c9665
Show file tree
Hide file tree
Showing 75 changed files with 2,425 additions and 1,087 deletions.
36 changes: 23 additions & 13 deletions src/main/java/com/alibaba/druid/sql/ast/SQLDataTypeImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,28 @@ public List<SQLExpr> getArguments() {
return this.arguments;
}

public void output(StringBuffer buf) {
buf.append(this.name);
if (this.arguments.size() > 0) {
buf.append("(");
int i = 0;
for (int size = this.arguments.size(); i < size; ++i) {
if (i != 0) {
buf.append(", ");
}
((SQLExpr) this.arguments.get(i)).output(buf);
}
buf.append(")");
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((arguments == null) ? 0 : arguments.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
SQLDataTypeImpl other = (SQLDataTypeImpl) obj;
if (arguments == null) {
if (other.arguments != null) return false;
} else if (!arguments.equals(other.arguments)) return false;
if (name == null) {
if (other.name != null) return false;
} else if (!name.equals(other.name)) return false;
return true;
}

}
30 changes: 19 additions & 11 deletions src/main/java/com/alibaba/druid/sql/ast/SQLOrderBy.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,24 @@ protected void accept0(SQLASTVisitor visitor) {
visitor.endVisit(this);
}

public void output(StringBuffer buf) {
buf.append("ORDER ");
buf.append("BY ");

int i = 0;
for (int size = this.items.size(); i < size; ++i) {
if (i != 0) {
buf.append(", ");
}
this.items.get(i).output(buf);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((items == null) ? 0 : items.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
SQLOrderBy other = (SQLOrderBy) obj;
if (items == null) {
if (other.items != null) return false;
} else if (!items.equals(other.items)) return false;
return true;
}

}
14 changes: 3 additions & 11 deletions src/main/java/com/alibaba/druid/sql/ast/expr/SQLBinaryOpExpr.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
public class SQLBinaryOpExpr extends SQLExprImpl implements Serializable {

private static final long serialVersionUID = 1L;
private SQLExpr left;
private SQLExpr right;
private SQLBinaryOperator operator;
private SQLExpr left;
private SQLExpr right;
private SQLBinaryOperator operator;

public SQLBinaryOpExpr(){

Expand Down Expand Up @@ -76,14 +76,6 @@ public void setOperator(SQLBinaryOperator operator) {
this.operator = operator;
}

public void output(StringBuffer buf) {
this.left.output(buf);
buf.append(" ");
buf.append(this.operator.name);
buf.append(" ");
this.right.output(buf);
}

protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, this.left);
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/com/alibaba/druid/sql/ast/expr/SQLCastExpr.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,6 @@ public void setDataType(SQLDataType dataType) {
this.dataType = dataType;
}

public void output(StringBuffer buf) {
buf.append("CAST(");
this.expr.output(buf);
buf.append(" AS ");
this.dataType.output(buf);
buf.append(")");
}

protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, this.expr);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,25 @@ protected void accept0(SQLASTVisitor visitor) {
public void output(StringBuffer buf) {
this.expr.output(buf);
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((expr == null) ? 0 : expr.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
SQLExprTableSource other = (SQLExprTableSource) obj;
if (expr == null) {
if (other.expr != null) return false;
} else if (!expr.equals(other.expr)) return false;
return true;
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ public class SQLSelectItem extends SQLObjectImpl {
public SQLSelectItem(){

}
public SQLSelectItem(SQLExpr expr) {

public SQLSelectItem(SQLExpr expr){
this(expr, null);
}

public SQLSelectItem(SQLExpr expr, String alias){
this.expr = expr;
this.alias = alias;

if (expr != null) {
expr.setParent(this);
}
Expand Down Expand Up @@ -76,4 +76,29 @@ protected void accept0(SQLASTVisitor visitor) {
}
visitor.endVisit(this);
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((alias == null) ? 0 : alias.hashCode());
result = prime * result + ((expr == null) ? 0 : expr.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
SQLSelectItem other = (SQLSelectItem) obj;
if (alias == null) {
if (other.alias != null) return false;
} else if (!alias.equals(other.alias)) return false;
if (expr == null) {
if (other.expr != null) return false;
} else if (!expr.equals(other.expr)) return false;
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,31 @@ protected void accept0(SQLASTVisitor visitor) {

visitor.endVisit(this);
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((collate == null) ? 0 : collate.hashCode());
result = prime * result + ((expr == null) ? 0 : expr.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
SQLSelectOrderByItem other = (SQLSelectOrderByItem) obj;
if (collate == null) {
if (other.collate != null) return false;
} else if (!collate.equals(other.collate)) return false;
if (expr == null) {
if (other.expr != null) return false;
} else if (!expr.equals(other.expr)) return false;
if (type != other.type) return false;
return true;
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@ public void setUnit(MySqlIntervalUnit unit) {
this.unit = unit;
}

@Override
public void output(StringBuffer buf) {
value.output(buf);
buf.append(' ');
buf.append(unit.name());
}

protected void accept0(SQLASTVisitor visitor) {
MySqlASTVisitor mysqlVisitor = (MySqlASTVisitor) visitor;
mysqlVisitor.visit(this);
Expand Down

This file was deleted.

Loading

0 comments on commit 72c9665

Please sign in to comment.