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


Java SQLBinaryOpExpr.getOperator方法代码示例

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


在下文中一共展示了SQLBinaryOpExpr.getOperator方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: visit

import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr; //导入方法依赖的package包/类
/**
    * 二元表达
    * @param x
    * @return
    */
   @Override
public boolean visit(SQLBinaryOpExpr x) {
       x.getLeft().setParent(x);
       x.getRight().setParent(x);
       switch (x.getOperator()) {
           case Equality:
               // a=1 and a=2 or a=3
               handleCondition(x.getLeft(), x.getOperator().name, x.getRight());
               // a=b 转化为 b=a
               // a=1 不用转化
               handleCondition(x.getRight(), x.getOperator().name, x.getLeft());
               handleRelationship(x.getLeft(), x.getOperator().name, x.getRight());
               break;
           case BooleanOr:
               this.hasOrCondition = true;
               break;
           default:
               break;
       }
       return true;
   }
 
开发者ID:tongbanjie,项目名称:baymax,代码行数:27,代码来源:SqlVisitor.java

示例4: visit

import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr; //导入方法依赖的package包/类
@Override
public boolean visit(final SQLBinaryOpExpr x) {

	switch (x.getOperator()) {
	case BooleanOr:
		parseResult.setHasOrCondition(true);
		break;
	case Equality:
		parseResult.addCondition(x.getLeft(), Condition.BinaryOperator.EQUAL, Collections.singletonList(x.getRight()), getDatabaseType(), getParameters());
		parseResult.addCondition(x.getRight(), Condition.BinaryOperator.EQUAL, Collections.singletonList(x.getLeft()), getDatabaseType(), getParameters());
		break;
	default:
		break;
	}
	return super.visit(x);
}
 
开发者ID:balancebeam,项目名称:sherlock,代码行数:17,代码来源:AbstractPGSQLVisitor.java

示例5: 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

示例6: parseThreeLevelPageSql

import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr; //导入方法依赖的package包/类
private void parseThreeLevelPageSql(SQLStatement stmt, RouteResultset rrs, SchemaConfig schema, SQLSubqueryTableSource from, SQLBinaryOpExpr one, SQLBinaryOperator operator)
{
       SQLIntegerExpr right = (SQLIntegerExpr) one.getRight();
	int firstrownum = right.getNumber().intValue();
	if (operator == SQLBinaryOperator.GreaterThanOrEqual&&firstrownum!=0) {
		firstrownum = firstrownum - 1;
	}
	SQLSelectQuery subSelect = from.getSelect().getQuery();
	if (subSelect instanceof OracleSelectQueryBlock)
       {  //第二层子查询
           OracleSelectQueryBlock twoSubSelect = (OracleSelectQueryBlock) subSelect;
           if (twoSubSelect.getWhere() instanceof SQLBinaryOpExpr && twoSubSelect.getFrom() instanceof SQLSubqueryTableSource)
           {
               SQLBinaryOpExpr twoWhere = (SQLBinaryOpExpr) twoSubSelect.getWhere();
               boolean isRowNum = "rownum".equalsIgnoreCase(twoWhere.getLeft().toString());
               boolean isLess = twoWhere.getOperator() == SQLBinaryOperator.LessThanOrEqual || twoWhere.getOperator() == SQLBinaryOperator.LessThan;
               if (isRowNum && twoWhere.getRight() instanceof SQLIntegerExpr && isLess)
               {
                   int lastrownum = ((SQLIntegerExpr) twoWhere.getRight()).getNumber().intValue();
                   if (operator == SQLBinaryOperator.LessThan&&lastrownum!=0) {
					lastrownum = lastrownum - 1;
				}
                   SQLSelectQuery finalQuery = ((SQLSubqueryTableSource) twoSubSelect.getFrom()).getSelect().getQuery();
                   if (finalQuery instanceof OracleSelectQueryBlock)
                   {
					setLimitIFChange(stmt, rrs, schema, one, firstrownum, lastrownum);
                       parseOrderAggGroupOracle(stmt,rrs, (OracleSelectQueryBlock) finalQuery, schema);
                       isNeedParseOrderAgg=false;
                   }

               }

           }

       }
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:37,代码来源:DruidSelectOracleParser.java

示例7: toDNF

import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr; //导入方法依赖的package包/类
/**
 * convert Expression to DNF Expression
 *
 * @param expr
 * @return
 */
public static SQLExpr toDNF(SQLExpr expr) {
    if (expr == null)
        return null;

    while (!isDNF(expr)) {
        SQLBinaryOpExpr binOpExpr = (SQLBinaryOpExpr) expr;
        if (binOpExpr.getOperator() == SQLBinaryOperator.BooleanOr) {
            expr = expandOrExpression(binOpExpr);
        } else if (binOpExpr.getOperator() == SQLBinaryOperator.BooleanAnd) {
            expr = expandAndExpression(binOpExpr);
        }
    }
    return expr;
}
 
开发者ID:actiontech,项目名称:dble,代码行数:21,代码来源:ExpressionUtil.java

示例8: 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

示例9: isLogicalExpression

import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr; //导入方法依赖的package包/类
private static boolean isLogicalExpression(SQLExpr expr) { //XOR?
    if (!(expr instanceof SQLBinaryOpExpr)) {
        return false;
    }
    SQLBinaryOpExpr binOpExpr = (SQLBinaryOpExpr) expr;
    return binOpExpr.getOperator() == SQLBinaryOperator.BooleanAnd || binOpExpr.getOperator() == SQLBinaryOperator.BooleanOr;
}
 
开发者ID:actiontech,项目名称:dble,代码行数:8,代码来源:ExpressionUtil.java

示例10: isColumnOperator

import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr; //导入方法依赖的package包/类
private static boolean isColumnOperator(SQLBinaryOpExpr binaryOpExpr) {
    switch (binaryOpExpr.getOperator()) {
        case Equality:
        case GreaterThan:
        case GreaterThanOrEqual:
        case NotEqual:
        case LessThan:
        case LessThanOrEqual:
        case LessThanOrEqualOrGreaterThan:
        case Like:
        case NotLike:
            return true;
    }
    return false;
}
 
开发者ID:maniaclee,项目名称:shardy,代码行数:16,代码来源:DruidUtils.java

示例11: visit

import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr; //导入方法依赖的package包/类
@Override
public boolean visit(SQLBinaryOpExpr x) {
       x.getLeft().setParent(x);
       x.getRight().setParent(x);

       switch (x.getOperator()) {
           case Equality:
           case LessThanOrEqualOrGreaterThan:
           case Is:
           case IsNot:
               handleCondition(x.getLeft(), x.getOperator().name, x.getRight());
               handleCondition(x.getRight(), x.getOperator().name, x.getLeft());
               handleRelationship(x.getLeft(), x.getOperator().name, x.getRight());
               break;
           case BooleanOr:
           	//永真条件,where条件抛弃
           	if(!RouterUtil.isConditionAlwaysTrue(x)) {
           		hasOrCondition = true;
           		
           		WhereUnit whereUnit = null;
           		if(conditions.size() > 0) {
           			whereUnit = new WhereUnit();
           			whereUnit.setFinishedParse(true);
           			whereUnit.addOutConditions(getConditions());
           			WhereUnit innerWhereUnit = new WhereUnit(x);
           			whereUnit.addSubWhereUnit(innerWhereUnit);
           		} else {
           			whereUnit = new WhereUnit(x);
           			whereUnit.addOutConditions(getConditions());
           		}
           		whereUnits.add(whereUnit);
           	}
           	return false;
           case Like:
           case NotLike:
           case NotEqual:
           case GreaterThan:
           case GreaterThanOrEqual:
           case LessThan:
           case LessThanOrEqual:
           default:
               break;
       }
       return true;
   }
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:46,代码来源:MycatSchemaStatVisitor.java

示例12: visit

import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr; //导入方法依赖的package包/类
@Override
public boolean visit(final SQLBinaryOpExpr x) {
	String sqlExpr = SQLUtil.getExactlyValue(x.getLeft().toString());
	if(sqlExpr.toLowerCase().equals("rownum") || parseResult.getRownumAlias().contains(sqlExpr)) {
		SQLExpr intExpr = new SQLIntegerExpr(0); 
		switch(x.getOperator()) {
		case LessThan:
			parseResult.getLimit().setUpperBound(Integer.parseInt(x.getRight().toString()));
			if(parseResult.getLimit().getOffset() == -1) {
			    parseResult.getLimit().setOffset(0);
			}
			break;
		case LessThanOrEqual:
			parseResult.getLimit().setUpperBound(Integer.parseInt(x.getRight().toString()) + 1);
			parseResult.getLimit().setOffset(0);
			if(parseResult.getLimit().getOffset() == -1) {
			    parseResult.getLimit().setOffset(0);
			}
			break;
		case GreaterThan:
			parseResult.getLimit().setOffset((Integer.parseInt(x.getRight().toString()) + 1));	
			x.setRight(intExpr);
			if(parseResult.getLimit().getUpperBound() == -1) {
				parseResult.getLimit().setUpperBound(MAX_UPPER_BOUND);
			}
			break;
		case GreaterThanOrEqual:
			parseResult.getLimit().setOffset(Integer.parseInt(x.getRight().toString()));
			x.setRight(intExpr);
			if(parseResult.getLimit().getUpperBound() == -1) {
				parseResult.getLimit().setUpperBound(MAX_UPPER_BOUND);
			}
			break;
		case Equality:
			parseResult.getLimit().setUpperBound(Integer.parseInt(x.getRight().toString())+1);
			parseResult.getLimit().setOffset(Integer.parseInt(x.getRight().toString()));
			x.setOperator(SQLBinaryOperator.LessThanOrEqual);
		default:
			break;
		}
       }

	switch (x.getOperator()) {
	case BooleanOr:
		parseResult.setHasOrCondition(true);
		break;
	case Equality:
		parseResult.addCondition(x.getLeft(), BinaryOperator.EQUAL, Collections.singletonList(x.getRight()), getDatabaseType(), getParameters());
		parseResult.addCondition(x.getRight(), BinaryOperator.EQUAL, Collections.singletonList(x.getLeft()), getDatabaseType(), getParameters());
		break;
	default:
		break;
	}
	return super.visit(x);
}
 
开发者ID:balancebeam,项目名称:sherlock,代码行数:56,代码来源:AbstractOracleVisitor.java


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