wall filter refactor

This commit is contained in:
wenshao
2012-12-10 19:00:22 +08:00
parent b5423e96cf
commit 2a7579bf86
6 changed files with 120 additions and 53 deletions
@@ -145,14 +145,7 @@ public class SQLUtils {
try {
List<SQLStatement> statementList = toStatementList(sql, dbType);
StringBuilder out = new StringBuilder();
SQLASTOutputVisitor visitor = createFormatOutputVisitor(out, statementList, dbType);
for (SQLStatement stmt : statementList) {
stmt.accept(visitor);
}
return out.toString();
return toSQLString(statementList, dbType);
} catch (SQLParseException ex) {
LOG.warn("format error", ex);
return sql;
@@ -162,6 +155,17 @@ public class SQLUtils {
}
}
public static String toSQLString(List<SQLStatement> statementList, String dbType) {
StringBuilder out = new StringBuilder();
SQLASTOutputVisitor visitor = createFormatOutputVisitor(out, statementList, dbType);
for (SQLStatement stmt : statementList) {
stmt.accept(visitor);
}
return out.toString();
}
public static SQLASTOutputVisitor createFormatOutputVisitor(Appendable out, List<SQLStatement> statementList,
String dbType) {
if (JdbcUtils.ORACLE.equals(dbType) || JdbcUtils.ALI_ORACLE.equals(dbType)) {