| 37 | private String type; |
| 38 | |
| 39 | public SqlParser(String sql) { |
| 40 | String normalizedSql = sql.toUpperCase().trim(); |
| 41 | if (normalizedSql.indexOf("SELECT") == 0) { |
| 42 | statement = com.sql.parse.statement.Select.parse(sql); |
| 43 | type = "SELECT"; |
| 44 | } else if (normalizedSql.indexOf("INSERT") == 0) { |
| 45 | statement = com.sql.parse.statement.Insert.parse(sql); |
| 46 | type = "INSERT"; |
| 47 | } else if (normalizedSql.indexOf("UPDATE") == 0) { |
| 48 | statement = com.sql.parse.statement.Update.parse(sql); |
| 49 | type = "UPDATE"; |
| 50 | } else if (normalizedSql.indexOf("DELETE") == 0) { |
| 51 | statement = com.sql.parse.statement.Delete.parse(sql); |
| 52 | type = "DELETE"; |
| 53 | } else { |
| 54 | throw BaseException.errorCode(SqlParseConstant.CODE_010); |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | public String getType() { |
| 59 | return type; |