public SQLStatement judge ( ) { LexerEngine lexerEngine = LexerEngineFactory . newInstance ( DatabaseType . MySQL , sql ) ; lexerEngine . nextToken ( ) ; while ( true ) { TokenType tokenType = lexerEngine . getCurrentToken ( ) . getType ( ) ; if ( tokenType instanceof Keyword ) { if ( DQLStatement . isDQL ( tokenType ) ) { return getDQLStatement ( ) ; } if ( DMLStatement . isDML ( tokenType ) ) { return getDMLStatement ( tokenType ) ; } if ( TCLStatement . isTCL ( tokenType ) ) { return getTCLStatement ( ) ; } if ( DALStatement . isDAL ( tokenType ) ) { return getDALStatement ( tokenType , lexerEngine ) ; } lexerEngine . nextToken ( ) ; TokenType secondaryTokenType = lexerEngine . getCurrentToken ( ) . getType ( ) ; if ( DDLStatement . isDDL ( tokenType , secondaryTokenType ) ) { return getDDLStatement ( ) ; } if ( DCLStatement . isDCL ( tokenType , secondaryTokenType ) ) { return getDCLStatement ( ) ; } if ( TCLStatement . isTCLUnsafe ( DatabaseType . MySQL , tokenType , lexerEngine ) ) { return getTCLStatement ( ) ; } if ( DefaultKeyword . SET . equals ( tokenType ) ) { return new SetStatement ( ) ; } } else { lexerEngine . nextToken ( ) ; } if ( sql . toUpperCase ( ) . startsWith ( "CALL" ) ) { return getDQLStatement ( ) ; } if ( tokenType instanceof Assist && Assist . END == tokenType ) { throw new SQLParsingException ( "Unsupported SQL statement: [%s]" , sql ) ; } } }
Judge SQL type only .