本文整理汇总了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);
}
}
}
示例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);
}
}
}
示例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;
}
示例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);
}
示例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");
}
}
}
}
示例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;
}
}
}
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}