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


Java SQLBinaryOpExpr.getLeft方法代码示例

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


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

示例1: splitUntilNoOr

import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr; //导入方法依赖的package包/类
/**
	 * 递归拆分OR
	 * 
	 * @param whereUnit
	 * TODO:考虑嵌套or语句,条件中有子查询、 exists等很多种复杂情况是否能兼容
	 */
	private void splitUntilNoOr(WhereUnit whereUnit) {
		if(whereUnit.isFinishedParse()) {
			if(whereUnit.getSubWhereUnit().size() > 0) {
				for(int i = 0; i < whereUnit.getSubWhereUnit().size(); i++) {
					splitUntilNoOr(whereUnit.getSubWhereUnit().get(i));
				}
			} 
		} else {
			SQLBinaryOpExpr expr = whereUnit.getCanSplitExpr();
			if(expr.getOperator() == SQLBinaryOperator.BooleanOr) {
//				whereUnit.addSplitedExpr(expr.getRight());
				addExprIfNotFalse(whereUnit, expr.getRight());
				if(expr.getLeft() instanceof SQLBinaryOpExpr) {
					whereUnit.setCanSplitExpr((SQLBinaryOpExpr)expr.getLeft());
					splitUntilNoOr(whereUnit);
				} else {
					addExprIfNotFalse(whereUnit, expr.getLeft());
				}
			} else {
				addExprIfNotFalse(whereUnit, expr);
				whereUnit.setFinishedParse(true);
			}
		}
    }
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:31,代码来源:MycatSchemaStatVisitor.java

示例2: opSQLExpr

import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr; //导入方法依赖的package包/类
private void opSQLExpr(SQLBinaryOpExpr expr,String Operator) {
	   if (expr==null) {
		   return;
	   }
	   SQLExpr exprL=expr.getLeft();
	   if (!(exprL instanceof SQLBinaryOpExpr))
	   {
		   String field=exprL.toString();
		   String value=getExpValue(expr.getRight()).toString();
		   if (expr.getOperator()==SQLBinaryOperator.Equality) {  
			 if (checkJoinField(value)) {
				//joinLkey=field;
				//joinRkey=value; 
				tableFilter.setJoinKey(field,value);
			 }
			 else {
				 tableFilter.addWhere(field, value, expr.getOperator().getName(), Operator);
			 }
		   }
		   else {
			   tableFilter.addWhere(field, value, expr.getOperator().getName(), Operator);
		   }
	   }		
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:25,代码来源:JoinParser.java

示例3: explanSpecialCondWithBothSidesAreLiterals

import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr; //导入方法依赖的package包/类
private boolean explanSpecialCondWithBothSidesAreLiterals(SQLBinaryOpExpr bExpr, Where where) throws SqlParseException {
    if ((bExpr.getLeft() instanceof SQLNumericLiteralExpr || bExpr.getLeft() instanceof SQLCharExpr) &&
            (bExpr.getRight() instanceof SQLNumericLiteralExpr || bExpr.getRight() instanceof SQLCharExpr)
            ) {
        SQLMethodInvokeExpr sqlMethodInvokeExpr = new SQLMethodInvokeExpr("script", null);
        String operator = bExpr.getOperator().getName();
        if (operator.equals("=")) {
            operator = "==";
        }
        sqlMethodInvokeExpr.addParameter(
                new SQLCharExpr(Util.expr2Object(bExpr.getLeft(), "'") +
                        " " + operator + " " +
                        Util.expr2Object(bExpr.getRight(), "'"))
        );

        explanCond("AND", sqlMethodInvokeExpr, where);
        return true;
    }
    return false;
}
 
开发者ID:NLPchina,项目名称:elasticsearch-sql,代码行数:21,代码来源:WhereParser.java

示例4: parserWhere

import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr; //导入方法依赖的package包/类
private void parserWhere(SQLExpr aexpr,String Operator){
	 if (aexpr==null) {
		 return;
	 }
     if (aexpr instanceof SQLBinaryOpExpr){
	   SQLBinaryOpExpr expr=(SQLBinaryOpExpr)aexpr;  
	   SQLExpr exprL=expr.getLeft();
	   if (!(exprL instanceof SQLBinaryOpExpr))
	   {
		  opSQLExpr((SQLBinaryOpExpr)aexpr,Operator);			  
	   }
	   else {
		// if (expr.getOperator().getName().equals("AND")) { 
		 if (expr.getOperator()==SQLBinaryOperator.BooleanAnd) { 	 
		   //parserWhere(exprL); 
		   //parserWhere(expr.getRight());
		   andorWhere(exprL,expr.getOperator().getName(),expr.getRight());
		 }
		 else if (expr.getOperator()==SQLBinaryOperator.BooleanOr){//.getName().equals("OR")) {  
			andorWhere(exprL,expr.getOperator().getName(),expr.getRight()); 				
		 }
		 else {
			 throw new RuntimeException("Can't identify the operation of  of where"); 
		 }
	   }
   }		
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:28,代码来源:JoinParser.java

示例5: expandOrExpression

import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr; //导入方法依赖的package包/类
/**
 * (A OR B) AND C OR B OR (E OR F) AND G = ((A AND C ) OR (A AND B)) OR B OR
 * ((E AND G) OR (F AND G))
 *
 * @param expr
 * @return
 */
private static SQLBinaryOpExpr expandOrExpression(SQLBinaryOpExpr expr) {
    SQLExpr left = expr.getLeft();
    SQLExpr right = expr.getRight();
    SQLExpr leftOp = toDNF(left);
    SQLExpr rightOp = toDNF(right);
    return new SQLBinaryOpExpr(leftOp, SQLBinaryOperator.BooleanOr, rightOp);
}
 
开发者ID:actiontech,项目名称:dble,代码行数:15,代码来源:ExpressionUtil.java

示例6: isDNF

import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr; //导入方法依赖的package包/类
/**
 * allow (A and B) and C
 *
 * @param expr
 * @return
 */
public static boolean isDNF(SQLExpr expr) {
    if (!isLogicalExpression(expr)) {
        return true;
    }
    SQLBinaryOpExpr binOpExpr = (SQLBinaryOpExpr) expr;
    SQLExpr left = binOpExpr.getLeft();
    SQLExpr right = binOpExpr.getRight();
    if (binOpExpr.getOperator() == SQLBinaryOperator.BooleanAnd) {
        boolean isAllNonLogicExpr = true;
        if (left instanceof SQLBinaryOpExpr) {
            SQLBinaryOpExpr leftBinaryOp = (SQLBinaryOpExpr) left;
            if (leftBinaryOp.getOperator() == SQLBinaryOperator.BooleanOr) {
                return false;
            }
            if (isLogicalExpression(leftBinaryOp)) {
                isAllNonLogicExpr = false;
            }
        }
        if (right instanceof SQLBinaryOpExpr) {
            SQLBinaryOpExpr rightBinaryOp = (SQLBinaryOpExpr) right;
            if (rightBinaryOp.getOperator() == SQLBinaryOperator.BooleanOr) {
                return false;
            }
            if (isLogicalExpression(rightBinaryOp)) {
                isAllNonLogicExpr = false;
            }
        }
        if (isAllNonLogicExpr) {
            return true;
        }
    }

    if (!isDNF(left)) {
        return false;
    }
    return isDNF(right);
}
 
开发者ID:actiontech,项目名称:dble,代码行数:44,代码来源:ExpressionUtil.java

示例7: explanSpecialCondWithBothSidesAreProperty

import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr; //导入方法依赖的package包/类
private boolean explanSpecialCondWithBothSidesAreProperty(SQLBinaryOpExpr bExpr, Where where) throws SqlParseException {
    //join is not support
    if ((bExpr.getLeft() instanceof SQLPropertyExpr || bExpr.getLeft() instanceof SQLIdentifierExpr) &&
            (bExpr.getRight() instanceof SQLPropertyExpr || bExpr.getRight() instanceof SQLIdentifierExpr) &&
            Sets.newHashSet("=", "<", ">", ">=", "<=").contains(bExpr.getOperator().getName()) &&
            !Util.isFromJoinOrUnionTable(bExpr)

            ) {
        SQLMethodInvokeExpr sqlMethodInvokeExpr = new SQLMethodInvokeExpr("script", null);
        String operator = bExpr.getOperator().getName();
        if (operator.equals("=")) {
            operator = "==";
        }

        String leftProperty = Util.expr2Object(bExpr.getLeft()).toString();
        String rightProperty = Util.expr2Object(bExpr.getRight()).toString();
        if (leftProperty.split("\\.").length > 1) {

            leftProperty = leftProperty.substring(leftProperty.split("\\.")[0].length() + 1);
        }

        if (rightProperty.split("\\.").length > 1) {
            rightProperty = rightProperty.substring(rightProperty.split("\\.")[0].length() + 1);
        }

        sqlMethodInvokeExpr.addParameter(new SQLCharExpr(
                "doc['" + leftProperty + "'].value " +
                        operator +
                        " doc['" + rightProperty + "'].value"));


        explanCond("AND", sqlMethodInvokeExpr, where);
        return true;
    }
    return false;
}
 
开发者ID:NLPchina,项目名称:elasticsearch-sql,代码行数:37,代码来源:WhereParser.java

示例8: isCond

import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr; //导入方法依赖的package包/类
private boolean isCond(SQLBinaryOpExpr expr) {
    SQLExpr leftSide = expr.getLeft();
    if (leftSide instanceof SQLMethodInvokeExpr) {
        return isAllowedMethodOnConditionLeft((SQLMethodInvokeExpr) leftSide, expr.getOperator());
    }
    return leftSide instanceof SQLIdentifierExpr ||
            leftSide instanceof SQLPropertyExpr ||
            leftSide instanceof SQLVariantRefExpr;
}
 
开发者ID:NLPchina,项目名称:elasticsearch-sql,代码行数:10,代码来源:WhereParser.java

示例9: rearrangement

import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr; //导入方法依赖的package包/类
/**
 * a inner_join (b inner_join c) -&lt; a inner_join b innre_join c
 */
public void rearrangement() {
    if (joinType != JoinType.COMMA && joinType != JoinType.INNER_JOIN) {
        return;
    }
    if (right instanceof SQLJoinTableSource) {
        SQLJoinTableSource rightJoin = (SQLJoinTableSource) right;

        if (rightJoin.joinType != JoinType.COMMA && rightJoin.joinType != JoinType.INNER_JOIN) {
            return;
        }

        SQLTableSource a = left;
        SQLTableSource b = rightJoin.getLeft();
        SQLTableSource c = rightJoin.getRight();
        SQLExpr on_ab = condition;
        SQLExpr on_bc = rightJoin.condition;

        setLeft(rightJoin);
        rightJoin.setLeft(a);
        rightJoin.setRight(b);


        boolean on_ab_match = false;
        if (on_ab instanceof SQLBinaryOpExpr) {
            SQLBinaryOpExpr on_ab_binaryOpExpr = (SQLBinaryOpExpr) on_ab;
            if (on_ab_binaryOpExpr.getLeft() instanceof SQLPropertyExpr
                    && on_ab_binaryOpExpr.getRight() instanceof SQLPropertyExpr) {
                String leftOwnerName = ((SQLPropertyExpr) on_ab_binaryOpExpr.getLeft()).getOwnernName();
                String rightOwnerName = ((SQLPropertyExpr) on_ab_binaryOpExpr.getRight()).getOwnernName();

                if (rightJoin.containsAlias(leftOwnerName) && rightJoin.containsAlias(rightOwnerName)) {
                    on_ab_match = true;
                }
            }
        }

        if (on_ab_match) {
            rightJoin.setCondition(on_ab);
        } else {
            rightJoin.setCondition(null);
            on_bc = SQLBinaryOpExpr.and(on_bc, on_ab);
        }

        setRight(c);
        setCondition(on_bc);
    }
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:51,代码来源:SQLJoinTableSource.java


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