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

The following examples show how to use com.alibaba.druid.sql.parser.Lexer. These examples are extracted from open source projects. 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 Project: Mycat2   Source File: MycatExprParser.java    License: 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 Project: elasticsearch-sql   Source File: ElasticSqlExprParser.java    License: 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 Project: elasticsearch-sql   Source File: ElasticSqlExprParser.java    License: 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;
}