• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java BinaryOperatorExpression类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中com.alibaba.cobar.parser.ast.expression.BinaryOperatorExpression的典型用法代码示例。如果您正苦于以下问题:Java BinaryOperatorExpression类的具体用法?Java BinaryOperatorExpression怎么用?Java BinaryOperatorExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

BinaryOperatorExpression类属于com.alibaba.cobar.parser.ast.expression包,在下文中一共展示了BinaryOperatorExpression类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: handleArithmetric

点赞 3

import com.alibaba.cobar.parser.ast.expression.BinaryOperatorExpression; //导入依赖的package包/类
private void handleArithmetric(BinaryOperatorExpression expr, String functionName) {
    IFunction func = ASTNodeFactory.getInstance().createFunction();
    func.setFunctionName(functionName);

    List<Object> args = new ArrayList<Object>(2);
    MySqlExprVisitor leftevi = new MySqlExprVisitor(parent);
    expr.getLeftOprand().accept(leftevi);
    args.add(leftevi.getColumnOrValue());

    MySqlExprVisitor rightevi = new MySqlExprVisitor(parent);
    expr.getRightOprand().accept(rightevi);
    args.add(rightevi.getColumnOrValue());

    func.setArgs(args); // 设置参数
    func.setColumnName(getSqlExprStr(expr));
    this.columnOrValue = func;
}
 

开发者ID:loye168,
项目名称:tddl5,
代码行数:18,
代码来源:MySqlExprVisitor.java

示例2: visit

点赞 3

import com.alibaba.cobar.parser.ast.expression.BinaryOperatorExpression; //导入依赖的package包/类
@Override
public void visit(BinaryOperatorExpression node) {
    Expression left = node.getLeftOprand();
    boolean paren = node.isLeftCombine() ? left.getPrecedence() < node.getPrecedence() : left.getPrecedence() <= node.getPrecedence();
    if (paren) appendable.append('(');
    left.accept(this);
    if (paren) appendable.append(')');

    appendable.append(' ').append(node.getOperator()).append(' ');

    Expression right = node.getRightOprand();
    paren = node.isLeftCombine() ? right.getPrecedence() <= node.getPrecedence() : right.getPrecedence() < node.getPrecedence();
    if (paren) appendable.append('(');
    right.accept(this);
    if (paren) appendable.append(')');
}
 

开发者ID:loye168,
项目名称:tddl5,
代码行数:17,
代码来源:MySQLOutputASTVisitor.java

示例3: containsCompIn

点赞 3

import com.alibaba.cobar.parser.ast.expression.BinaryOperatorExpression; //导入依赖的package包/类
protected static boolean containsCompIn(Expression pat) {
    if (pat.getPrecedence() > Expression.PRECEDENCE_COMPARISION) return false;
    if (pat instanceof BinaryOperatorExpression) {
        if (pat instanceof InExpression) {
            return true;
        }
        BinaryOperatorExpression bp = (BinaryOperatorExpression) pat;
        if (bp.isLeftCombine()) {
            return containsCompIn(bp.getLeftOprand());
        } else {
            return containsCompIn(bp.getLeftOprand());
        }
    } else if (pat instanceof ComparisionIsExpression) {
        ComparisionIsExpression is = (ComparisionIsExpression) pat;
        return containsCompIn(is.getOperand());
    } else if (pat instanceof TernaryOperatorExpression) {
        TernaryOperatorExpression tp = (TernaryOperatorExpression) pat;
        return containsCompIn(tp.getFirst()) || containsCompIn(tp.getSecond()) || containsCompIn(tp.getThird());
    } else if (pat instanceof UnaryOperatorExpression) {
        UnaryOperatorExpression up = (UnaryOperatorExpression) pat;
        return containsCompIn(up.getOperand());
    } else {
        return false;
    }
}
 

开发者ID:loye168,
项目名称:tddl5,
代码行数:26,
代码来源:MySQLOutputASTVisitor.java

示例4: handleArithmetric

点赞 3

import com.alibaba.cobar.parser.ast.expression.BinaryOperatorExpression; //导入依赖的package包/类
private void handleArithmetric(BinaryOperatorExpression expr, String functionName) {
    IFunction func = ASTNodeFactory.getInstance().createFunction();
    func.setFunctionName(functionName);

    List<Object> args = new ArrayList<Object>(2);
    MySqlExprVisitor leftevi = new MySqlExprVisitor();
    expr.getLeftOprand().accept(leftevi);
    args.add(leftevi.getColumnOrValue());

    MySqlExprVisitor rightevi = new MySqlExprVisitor();
    expr.getRightOprand().accept(rightevi);
    args.add(rightevi.getColumnOrValue());

    func.setArgs(args); // 设置参数
    func.setColumnName(getSqlExprStr(expr));
    this.columnOrValue = func;
}
 

开发者ID:beebeandwer,
项目名称:TDDL,
代码行数:18,
代码来源:MySqlExprVisitor.java

示例5: visit

点赞 3

import com.alibaba.cobar.parser.ast.expression.BinaryOperatorExpression; //导入依赖的package包/类
@Override
public void visit(BinaryOperatorExpression node) {
    Expression left = node.getLeftOprand();
    boolean paren = node.isLeftCombine()
            ? left.getPrecedence() < node.getPrecedence() : left.getPrecedence() <= node.getPrecedence();
    if (paren)
        appendable.append('(');
    left.accept(this);
    if (paren)
        appendable.append(')');

    appendable.append(' ').append(node.getOperator()).append(' ');

    Expression right = node.getRightOprand();
    paren = node.isLeftCombine()
            ? right.getPrecedence() <= node.getPrecedence() : right.getPrecedence() < node.getPrecedence();
    if (paren)
        appendable.append('(');
    right.accept(this);
    if (paren)
        appendable.append(')');
}
 

开发者ID:alibaba,
项目名称:cobar,
代码行数:23,
代码来源:MySQLOutputASTVisitor.java

示例6: containsCompIn

点赞 3

import com.alibaba.cobar.parser.ast.expression.BinaryOperatorExpression; //导入依赖的package包/类
private static boolean containsCompIn(Expression pat) {
    if (pat.getPrecedence() > Expression.PRECEDENCE_COMPARISION)
        return false;
    if (pat instanceof BinaryOperatorExpression) {
        if (pat instanceof InExpression) {
            return true;
        }
        BinaryOperatorExpression bp = (BinaryOperatorExpression) pat;
        if (bp.isLeftCombine()) {
            return containsCompIn(bp.getLeftOprand());
        } else {
            return containsCompIn(bp.getLeftOprand());
        }
    } else if (pat instanceof ComparisionIsExpression) {
        ComparisionIsExpression is = (ComparisionIsExpression) pat;
        return containsCompIn(is.getOperand());
    } else if (pat instanceof TernaryOperatorExpression) {
        TernaryOperatorExpression tp = (TernaryOperatorExpression) pat;
        return containsCompIn(tp.getFirst()) || containsCompIn(tp.getSecond()) || containsCompIn(tp.getThird());
    } else if (pat instanceof UnaryOperatorExpression) {
        UnaryOperatorExpression up = (UnaryOperatorExpression) pat;
        return containsCompIn(up.getOperand());
    } else {
        return false;
    }
}
 

开发者ID:alibaba,
项目名称:cobar,
代码行数:27,
代码来源:MySQLOutputASTVisitor.java

示例7: visit

点赞 2

import com.alibaba.cobar.parser.ast.expression.BinaryOperatorExpression; //导入依赖的package包/类
@Override
public void visit(BinaryOperatorExpression node) {
    if (eval(node)) { // 计算出了结果
        return;
    }

    if (node instanceof ComparisionEqualsExpression) {
        this.handleBooleanFilter(node, OPERATION.EQ);
    } else if (node instanceof ComparisionGreaterThanExpression) {
        this.handleBooleanFilter(node, OPERATION.GT);
    } else if (node instanceof ComparisionGreaterThanOrEqualsExpression) {
        this.handleBooleanFilter(node, OPERATION.GT_EQ);
    } else if (node instanceof ComparisionLessOrGreaterThanExpression) {
        this.handleBooleanFilter(node, OPERATION.NOT_EQ);
    } else if (node instanceof ComparisionLessThanExpression) {
        this.handleBooleanFilter(node, OPERATION.LT);
    } else if (node instanceof ComparisionLessThanOrEqualsExpression) {
        this.handleBooleanFilter(node, OPERATION.LT_EQ);
    } else if (node instanceof ComparisionNotEqualsExpression) {
        this.handleBooleanFilter(node, OPERATION.NOT_EQ);
    } else if (node instanceof ComparisionNullSafeEqualsExpression) {
        throw new NotSupportException("not support '<=>' ");
    } else if (node instanceof ArithmeticAddExpression) {
        this.handleArithmetric(node, IFunction.BuiltInFunction.ADD);
    } else if (node instanceof ArithmeticDivideExpression) {
        this.handleArithmetric(node, IFunction.BuiltInFunction.DIVISION);
    } else if (node instanceof ArithmeticIntegerDivideExpression) {
        this.handleArithmetric(node, node.getOperator());
    } else if (node instanceof ArithmeticModExpression) {
        this.handleArithmetric(node, IFunction.BuiltInFunction.MOD);
    } else if (node instanceof ArithmeticMultiplyExpression) {
        this.handleArithmetric(node, IFunction.BuiltInFunction.MULTIPLY);
    } else if (node instanceof ArithmeticSubtractExpression) {
        this.handleArithmetric(node, IFunction.BuiltInFunction.SUB);
    } else if (node instanceof AssignmentExpression) {
        throw new NotSupportException("not support ':=' ");
    } else if (node instanceof BitAndExpression) {
        this.handleArithmetric(node, IFunction.BuiltInFunction.BITAND);
    } else if (node instanceof BitOrExpression) {
        this.handleArithmetric(node, IFunction.BuiltInFunction.BITOR);
    } else if (node instanceof BitShiftExpression) {
        if (((BitShiftExpression) node).isRightShift()) {
            this.handleArithmetric(node, IFunction.BuiltInFunction.BITRSHIFT);
        } else {
            this.handleArithmetric(node, IFunction.BuiltInFunction.BITLSHIFT);
        }
    } else if (node instanceof BitXORExpression) {
        this.handleArithmetric(node, IFunction.BuiltInFunction.BITXOR);
    } else if (node instanceof InExpression) {
        this.handleInExpression((InExpression) node);
    } else if (node instanceof LogicalXORExpression) {
        this.handleBooleanFilter(node, OPERATION.XOR);
    } else {
        throw new NotSupportException("not supported this BinaryOperatorExpression type " + node.getOperator());
    }
}
 

开发者ID:loye168,
项目名称:tddl5,
代码行数:57,
代码来源:MySqlExprVisitor.java

示例8: handleBooleanFilter

点赞 2

import com.alibaba.cobar.parser.ast.expression.BinaryOperatorExpression; //导入依赖的package包/类
private void handleBooleanFilter(BinaryOperatorExpression node, OPERATION op) {
    Object column = null;
    Object value = null;

    MySqlExprVisitor lv = new MySqlExprVisitor(parent);
    node.getLeftOprand().accept(lv);
    column = lv.getColumnOrValue();

    MySqlExprVisitor rv = new MySqlExprVisitor(parent);
    node.getRightOprand().accept(rv);
    value = rv.getColumnOrValue();
    precedence = rv.precedence;

    if (precedence == PrecedenceMode.ALL) {
        switch (op) {
            case GT:
                op = OPERATION.GT_ALL;
                break;
            case LT:
                op = OPERATION.LT_ALL;
                break;
            case GT_EQ:
                op = OPERATION.GT_EQ_ALL;
                break;
            case LT_EQ:
                op = OPERATION.LT_EQ_ALL;
                break;
            case EQ:
                op = OPERATION.EQ_ALL;
                break;
            case NOT_EQ:
                op = OPERATION.NOT_EQ_ALL;
                break;
            default:
                break;
        }
    } else if (precedence == PrecedenceMode.ANY) {
        switch (op) {
            case GT:
                op = OPERATION.GT_ANY;
                break;
            case LT:
                op = OPERATION.LT_ANY;
                break;
            case GT_EQ:
                op = OPERATION.GT_EQ_ANY;
                break;
            case LT_EQ:
                op = OPERATION.LT_EQ_ANY;
                break;
            case EQ:
                op = OPERATION.EQ_ANY;
                break;
            case NOT_EQ:
                op = OPERATION.NOT_EQ_ANY;
                break;
            default:
                break;
        }
    }

    this.filter = buildBooleanFilter(column, value, op, node);
}
 

开发者ID:loye168,
项目名称:tddl5,
代码行数:64,
代码来源:MySqlExprVisitor.java

示例9: visit

点赞 2

import com.alibaba.cobar.parser.ast.expression.BinaryOperatorExpression; //导入依赖的package包/类
@Override
public void visit(BinaryOperatorExpression node) {
    visitInternal(node.getLeftOprand());
    visitInternal(node.getRightOprand());
}
 

开发者ID:loye168,
项目名称:tddl5,
代码行数:6,
代码来源:EmptySQLASTVisitor.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)