com.alibaba.druid.sql.parser.Lexer Java Examples

The following examples show how to use com.alibaba.druid.sql.parser.Lexer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MycatExprParser.java    From Mycat2 with GNU General Public License v3.0 4 votes vote down vote up
public MycatExprParser(Lexer lexer)
{
    super(lexer);
    super.aggregateFunctions = max_agg_functions;
}
 
Example #2
Source File: ElasticSqlExprParser.java    From elasticsearch-sql with Apache License 2.0 4 votes vote down vote up
public ElasticSqlExprParser(Lexer lexer){
    super(lexer, JdbcConstants.MYSQL);
    this.aggregateFunctions = AGGREGATE_FUNCTIONS;
    this.aggregateFunctionHashCodes = AGGREGATE_FUNCTIONS_CODES;
}
 
Example #3
Source File: ElasticSqlExprParser.java    From elasticsearch-sql with Apache License 2.0 4 votes vote down vote up
private SQLExpr userNameRest(SQLExpr expr) {
    if (lexer.token() != Token.VARIANT || !lexer.stringVal().startsWith("@")) {
        return expr;
    }

    MySqlUserName userName = new MySqlUserName();
    if (expr instanceof SQLCharExpr) {
        userName.setUserName(((SQLCharExpr) expr).toString());
    } else {
        userName.setUserName(((SQLIdentifierExpr) expr).getName());
    }


    String strVal = lexer.stringVal();
    lexer.nextToken();

    if (strVal.length() > 1) {
        userName.setHost(strVal.substring(1));
        return userName;
    }

    if (lexer.token() == Token.LITERAL_CHARS) {
        userName.setHost("'" + lexer.stringVal() + "'");
    } else {
        userName.setHost(lexer.stringVal());
    }
    lexer.nextToken();

    if (lexer.token() == Token.IDENTIFIED) {
        Lexer.SavePoint mark = lexer.mark();

        lexer.nextToken();
        if (lexer.token() == Token.BY) {
            lexer.nextToken();
            if (lexer.identifierEquals(FnvHash.Constants.PASSWORD)) {
                lexer.reset(mark);
            } else {
                userName.setIdentifiedBy(lexer.stringVal());
                lexer.nextToken();
            }
        } else {
            lexer.reset(mark);
        }
    }

    return userName;
}