当前位置: 首页>>代码示例>>Java>>正文


Java SQLExpr.accept方法代码示例

本文整理汇总了Java中com.alibaba.druid.sql.ast.SQLExpr.accept方法的典型用法代码示例。如果您正苦于以下问题:Java SQLExpr.accept方法的具体用法?Java SQLExpr.accept怎么用?Java SQLExpr.accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.druid.sql.ast.SQLExpr的用法示例。


在下文中一共展示了SQLExpr.accept方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visit

import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
@Override
public boolean visit(PGTypeCastExpr x) {
    SQLExpr expr = x.getExpr();
    if (expr != null) {
        if (expr instanceof SQLBinaryOpExpr) {
            print('(');
            expr.accept(this);
            print(')');
        } else {
            expr.accept(this);
        }
    }
    print0("::");
    x.getDataType().accept(this);
    return false;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:17,代码来源:PGOutputVisitor.java

示例2: printGrantPrivileges

import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
protected void printGrantPrivileges(SQLGrantStatement x) {
    List<SQLExpr> privileges = x.getPrivileges();
    int i = 0;
    for (SQLExpr privilege : privileges) {
        if (i != 0) {
            print(", ");
        }

        if (privilege instanceof SQLIdentifierExpr) {
            String name = ((SQLIdentifierExpr) privilege).getName();
            if ("RESOURCE".equalsIgnoreCase(name)) {
                continue;
            }
        }

        privilege.accept(this);
        i++;
    }
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:20,代码来源:PGOutputVisitor.java

示例3: testGroupbyOrder

import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
@Test
public void testGroupbyOrder() {
    MySqlSelectQueryBlock query = getQuery("select col1,col2 from table1 group by col1 desc,col2 asc ");
    SQLSelectGroupByClause groupBy = query.getGroupBy();
    int i = 0;
    for (SQLExpr p : groupBy.getItems()) {
        i++;
        String groupCol = "col" + i;
        MySqlOrderingExpr groupitem = (MySqlOrderingExpr) p;
        SQLExpr q = groupitem.getExpr();
        MySQLItemVisitor v = new MySQLItemVisitor(this.currentDb, utf8Charset, null);
        q.accept(v);
        Item item = v.getItem();
        Assert.assertEquals(true, groupCol.equals(item.getItemName()));
    }
}
 
开发者ID:actiontech,项目名称:dble,代码行数:17,代码来源:TestMySQLItemVisitor.java

示例4: eval

import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
public Object eval(SQLEvalVisitor visitor, SQLMethodInvokeExpr x) {
    final List<SQLExpr> parameters = x.getParameters();
    if (parameters.size() == 0) {
        return EVAL_ERROR;
    }

    SQLExpr condition = parameters.get(0);
    condition.accept(visitor);
    Object itemValue = condition.getAttributes().get(EVAL_VALUE);
    if (itemValue == null) {
        return null;
    }
    if (Boolean.TRUE == itemValue || !SQLEvalVisitorUtils.eq(itemValue, 0)) {
        SQLExpr trueExpr = parameters.get(1);
        trueExpr.accept(visitor);
        return trueExpr.getAttributes().get(EVAL_VALUE);
    } else {
        SQLExpr falseExpr = parameters.get(2);
        falseExpr.accept(visitor);
        return falseExpr.getAttributes().get(EVAL_VALUE);
    }
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:23,代码来源:If.java

示例5: eval

import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
public Object eval(SQLEvalVisitor visitor, SQLMethodInvokeExpr x) {
    if (x.getParameters().size() != 1) {
        return SQLEvalVisitor.EVAL_ERROR;
    }

    SQLExpr param0 = x.getParameters().get(0);
    param0.accept(visitor);

    Object param0Value = param0.getAttributes().get(EVAL_VALUE);
    if (param0Value == null) {
        return SQLEvalVisitor.EVAL_ERROR;
    }

    if (param0Value instanceof Number) {
        long longValue = ((Number) param0Value).longValue();
        String result = Long.toString(longValue, 2);
        return result;
    }
    return SQLEvalVisitor.EVAL_ERROR;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:21,代码来源:Bin.java

示例6: eval

import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
public Object eval(SQLEvalVisitor visitor, SQLMethodInvokeExpr x) {
    final List<SQLExpr> parameters = x.getParameters();
    if (parameters.size() == 0) {
        return EVAL_ERROR;
    }

    SQLExpr condition = parameters.get(0);
    condition.accept(visitor);
    Object itemValue = condition.getAttributes().get(EVAL_VALUE);
    if (itemValue == EVAL_VALUE_NULL) {
        return Boolean.TRUE;
    } else if (itemValue == null) {
        return null;
    } else {
        return Boolean.FALSE;
    }
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:18,代码来源:Isnull.java

示例7: eval

import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
public Object eval(SQLEvalVisitor visitor, SQLMethodInvokeExpr x) {
    if (x.getParameters().size() != 1) {
        return SQLEvalVisitor.EVAL_ERROR;
    }

    SQLExpr param0 = x.getParameters().get(0);
    param0.accept(visitor);

    Object param0Value = param0.getAttributes().get(EVAL_VALUE);
    if (param0Value == null) {
        return SQLEvalVisitor.EVAL_ERROR;
    }

    if (param0Value instanceof String) {
        return ((String) param0Value).getBytes().length * 8;
    }
    return SQLEvalVisitor.EVAL_ERROR;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:19,代码来源:BitLength.java

示例8: eval

import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
public Object eval(SQLEvalVisitor visitor, SQLMethodInvokeExpr x) {
    if (x.getParameters().size() <= 1) {
        return SQLEvalVisitor.EVAL_ERROR;
    }

    SQLExpr param0 = x.getParameters().get(0);
    param0.accept(visitor);

    Object param0Value = param0.getAttributes().get(EVAL_VALUE);
    int param0IntValue;
    if (!(param0Value instanceof Number)) {
        return SQLEvalVisitor.EVAL_ERROR;
    }
    param0IntValue = ((Number) param0Value).intValue();

    if (param0IntValue >= x.getParameters().size()) {
        return null;
    }

    SQLExpr item = x.getParameters().get(param0IntValue);
    item.accept(visitor);

    Object itemValue = item.getAttributes().get(EVAL_VALUE);
    return itemValue;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:26,代码来源:Elt.java

示例9: eval

import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
public Object eval(SQLEvalVisitor visitor, SQLMethodInvokeExpr x) {
    if (x.getParameters().size() != 2) {
        return SQLEvalVisitor.EVAL_ERROR;
    }

    SQLExpr param0 = x.getParameters().get(0);
    SQLExpr param1 = x.getParameters().get(1);
    param0.accept(visitor);
    param1.accept(visitor);

    Object param0Value = param0.getAttributes().get(EVAL_VALUE);
    Object param1Value = param1.getAttributes().get(EVAL_VALUE);
    if (param0Value == null || param1Value == null) {
        return SQLEvalVisitor.EVAL_ERROR;
    }

    String strValue0 = param0Value.toString();
    String strValue1 = param1Value.toString();

    int result = strValue0.indexOf(strValue1) + 1;
    return result;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:23,代码来源:Instr.java

示例10: eval

import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
public Object eval(SQLEvalVisitor visitor, SQLMethodInvokeExpr x) {
    if (x.getParameters().size() != 1) {
        return SQLEvalVisitor.EVAL_ERROR;
    }

    SQLExpr param0 = x.getParameters().get(0);
    param0.accept(visitor);

    Object param0Value = param0.getAttributes().get(EVAL_VALUE);
    if (param0Value == null) {
        return SQLEvalVisitor.EVAL_ERROR;
    }

    String strValue = param0Value.toString();

    int result = strValue.length();
    return result;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:19,代码来源:Length.java

示例11: getItemName

import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
public final String getItemName() {
    if (itemName == null || itemName.length() == 0) {
        SQLExpr expr = toExpression();
        StringBuilder sb = new StringBuilder();
        MySqlOutputVisitor ov = new MySqlOutputVisitor(sb);
        expr.accept(ov);
        itemName = sb.toString();
    }
    return itemName;
}
 
开发者ID:actiontech,项目名称:dble,代码行数:11,代码来源:Item.java

示例12: visit

import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
public static boolean visit(SQLEvalVisitor visitor, SQLBetweenExpr x) {
    SQLExpr testExpr = unwrap(x.getTestExpr());
    testExpr.accept(visitor);

    if (!testExpr.getAttributes().containsKey(EVAL_VALUE)) {
        return false;
    }

    Object value = testExpr.getAttribute(EVAL_VALUE);

    SQLExpr beginExpr = unwrap(x.getBeginExpr());
    beginExpr.accept(visitor);
    if (!beginExpr.getAttributes().containsKey(EVAL_VALUE)) {
        return false;
    }

    Object begin = beginExpr.getAttribute(EVAL_VALUE);

    if (lt(value, begin)) {
        x.getAttributes().put(EVAL_VALUE, x.isNot() ? true : false);
        return false;
    }

    SQLExpr endExpr = unwrap(x.getEndExpr());
    endExpr.accept(visitor);
    if (!endExpr.getAttributes().containsKey(EVAL_VALUE)) {
        return false;
    }

    Object end = endExpr.getAttribute(EVAL_VALUE);

    if (gt(value, end)) {
        x.getAttributes().put(EVAL_VALUE, x.isNot() ? true : false);
        return false;
    }

    x.getAttributes().put(EVAL_VALUE, x.isNot() ? false : true);
    return false;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:40,代码来源:SQLEvalVisitorUtils.java

示例13: testOrderby

import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
@Test
public void testOrderby() {
    MySqlSelectQueryBlock query = getQuery("select col1,col2  from table1 order by col1 asc, col2 desc ");
    SQLOrderBy orderBy = query.getOrderBy();
    int i = 0;
    for (SQLSelectOrderByItem p : orderBy.getItems()) {
        i++;
        String orderCol = "col" + i;
        SQLExpr expr = p.getExpr();
        MySQLItemVisitor v = new MySQLItemVisitor(this.currentDb, utf8Charset, null);
        expr.accept(v);
        Item item = v.getItem();
        Assert.assertEquals(true, orderCol.equals(item.getItemName()));
    }
}
 
开发者ID:actiontech,项目名称:dble,代码行数:16,代码来源:TestMySQLItemVisitor.java

示例14: isNoSharding

import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
public static boolean isNoSharding(ServerConnection source, SQLExpr sqlExpr, String contextSchema, StringPtr sqlSchema)
        throws SQLException {
    SubQueryTableVisitor subQueryTableVisitor = new SubQueryTableVisitor();
    sqlExpr.accept(subQueryTableVisitor);
    SQLSelect sqlSelect = subQueryTableVisitor.getSQLSelect();
    return sqlSelect == null || isNoSharding(source, sqlSelect.getQuery(), new SQLSelectStatement(sqlSelect), contextSchema, sqlSchema);
}
 
开发者ID:actiontech,项目名称:dble,代码行数:8,代码来源:SchemaUtil.java

示例15: eval

import com.alibaba.druid.sql.ast.SQLExpr; //导入方法依赖的package包/类
public Object eval(SQLEvalVisitor visitor, SQLMethodInvokeExpr x) {
    List<SQLExpr> params = x.getParameters();
    int paramSize = params.size();
    if (paramSize != 3) {
        return SQLEvalVisitor.EVAL_ERROR;
    }

    SQLExpr param0 = params.get(0);
    SQLExpr param1 = params.get(1);
    SQLExpr param2 = params.get(2);

    param0.accept(visitor);
    param1.accept(visitor);
    param2.accept(visitor);

    Object param0Value = param0.getAttributes().get(EVAL_VALUE);
    Object param1Value = param1.getAttributes().get(EVAL_VALUE);
    Object param2Value = param2.getAttributes().get(EVAL_VALUE);
    if (param0Value == null || param1Value == null || param2Value == null) {
        return SQLEvalVisitor.EVAL_ERROR;
    }

    String strValue0 = param0Value.toString();
    int len = ((Number) param1Value).intValue();
    String strValue1 = param2Value.toString();
    
    String result = strValue0;
    if (result.length() > len) {
        return result.substring(0, len);
    }
    
    while (result.length() < len) {
        result = strValue1 + result;
    }

    return result;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:38,代码来源:Lpad.java


注:本文中的com.alibaba.druid.sql.ast.SQLExpr.accept方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。