add testcase & remove unused code

This commit is contained in:
wenshao
2013-06-17 23:34:35 +08:00
parent b199d3043f
commit 72c9665577
75 changed files with 2415 additions and 1077 deletions
@@ -57,18 +57,28 @@ public class SQLDataTypeImpl extends SQLObjectImpl implements SQLDataType {
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;
}
}
@@ -42,16 +42,24 @@ public class SQLOrderBy extends SQLObjectImpl {
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;
}
}
@@ -24,9 +24,9 @@ import com.alibaba.druid.sql.visitor.SQLASTVisitor;
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(){
@@ -76,14 +76,6 @@ public class SQLBinaryOpExpr extends SQLExprImpl implements Serializable {
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);
@@ -50,14 +50,6 @@ public class SQLCastExpr extends SQLExprImpl {
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);
@@ -1,56 +0,0 @@
/*
* Copyright 1999-2011 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast.expr;
public class SQLDateLiteralValue {
private int years;
private int months;
private int days;
public int getYears() {
return years;
}
public void setYears(int years) {
this.years = years;
}
public int getMonths() {
return months;
}
public void setMonths(int months) {
this.months = months;
}
public int getDays() {
return days;
}
public void setDays(int days) {
this.days = days;
}
public void output(StringBuffer buf) {
buf.append(years);
buf.append("-");
buf.append(months);
buf.append("-");
buf.append(days);
}
}
@@ -54,4 +54,25 @@ public class SQLExprTableSource extends SQLTableSourceImpl {
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;
}
}
@@ -1,21 +0,0 @@
/*
* Copyright 1999-2011 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast.statement;
public class SQLIndexDefinition {
}
@@ -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);
}
@@ -76,4 +76,29 @@ public class SQLSelectItem extends SQLObjectImpl {
}
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;
}
}
@@ -63,4 +63,31 @@ public class SQLSelectOrderByItem extends SQLObjectImpl {
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;
}
}
@@ -1,32 +0,0 @@
/*
* Copyright 1999-2011 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast.statement;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
@SuppressWarnings("serial")
public class SQLTableConstaintImpl extends SQLConstaintImpl implements SQLTableConstaint {
public SQLTableConstaintImpl(){
}
@Override
protected void accept0(SQLASTVisitor visitor) {
}
}