use of io.shardingjdbc.core.parsing.lexer.token.Assist in project sharding-jdbc by shardingjdbc.
the class SQLJudgeEngine method judge.
/**
* judge SQL Type only.
*
* @return SQL statement
*/
public SQLStatement judge() {
LexerEngine lexerEngine = LexerEngineFactory.newInstance(DatabaseType.MySQL, sql);
lexerEngine.nextToken();
while (true) {
TokenType tokenType = lexerEngine.getCurrentToken().getType();
if (tokenType instanceof Keyword) {
if (isDQL(tokenType)) {
return getDQLStatement();
}
if (isDML(tokenType)) {
return getDMLStatement(tokenType);
}
if (isDDL(tokenType)) {
return getDDLStatement();
}
if (isTCL(tokenType)) {
return getTCLStatement();
}
if (isDAL(tokenType)) {
return getDALStatement(tokenType, lexerEngine);
}
}
if (tokenType instanceof Assist && Assist.END == tokenType) {
throw new SQLParsingException("Unsupported SQL statement: [%s]", sql);
}
lexerEngine.nextToken();
}
}
Aggregations