Java Code Examples for com.alibaba.druid.sql.ast.expr.SQLBooleanExpr

The following examples show how to use com.alibaba.druid.sql.ast.expr.SQLBooleanExpr. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Mycat2   Source File: JoinParser.java    License: GNU General Public License v3.0 6 votes vote down vote up
private Object getExpValue(SQLExpr expr){
	if (expr instanceof SQLIntegerExpr){
		return ((SQLIntegerExpr)expr).getNumber().longValue();
	}
	if (expr instanceof SQLNumberExpr){
		return ((SQLNumberExpr)expr).getNumber().doubleValue();
	}		
	if (expr instanceof SQLCharExpr){
		String va=((SQLCharExpr)expr).toString();
		return va;//remove(va,'\'');
	}
	if (expr instanceof SQLBooleanExpr){			
		return ((SQLBooleanExpr)expr).getValue();
	}			
	if (expr instanceof SQLNullExpr){
		return null;
	}

	return expr;		
}
 
Example 2
Source Project: elasticsearch-sql   Source File: Maker.java    License: Apache License 2.0 6 votes vote down vote up
private Object parseTermValue(Object termValue) {
    if (termValue instanceof SQLNumericLiteralExpr) {
        termValue = ((SQLNumericLiteralExpr) termValue).getNumber();
        if (termValue instanceof BigDecimal || termValue instanceof Double) {
            termValue = ((Number) termValue).doubleValue();
        } else if (termValue instanceof Float) {
            termValue = ((Number) termValue).floatValue();
        } else if (termValue instanceof BigInteger || termValue instanceof Long) {
            termValue = ((Number) termValue).longValue();
        } else if (termValue instanceof Integer) {
            termValue = ((Number) termValue).intValue();
        } else if (termValue instanceof Short) {
            termValue = ((Number) termValue).shortValue();
        } else if (termValue instanceof Byte) {
            termValue = ((Number) termValue).byteValue();
        }
    } else if (termValue instanceof SQLBooleanExpr) {
        termValue = ((SQLBooleanExpr) termValue).getValue();
    } else {
        termValue = termValue.toString();
    }

    return termValue;
}
 
Example 3
Source Project: elasticsearch-sql   Source File: Util.java    License: Apache License 2.0 6 votes vote down vote up
public static Object expr2Object(SQLExpr expr, String charWithQuote) {
    Object value = null;
    if (expr instanceof SQLNumericLiteralExpr) {
        value = ((SQLNumericLiteralExpr) expr).getNumber();
    } else if (expr instanceof SQLCharExpr) {
        value = charWithQuote + ((SQLCharExpr) expr).getText() + charWithQuote;
    } else if (expr instanceof SQLIdentifierExpr) {
        value = expr.toString();
    } else if (expr instanceof SQLPropertyExpr) {
        value = expr.toString();
    } else if (expr instanceof SQLVariantRefExpr) {
        value = expr.toString();
    } else if (expr instanceof SQLAllColumnExpr) {
        value = "*";
    } else if (expr instanceof SQLValuableExpr) {
        value = ((SQLValuableExpr) expr).getValue();
    } else if (expr instanceof SQLBooleanExpr) {
        value = ((SQLBooleanExpr) expr).getValue();
    } else {
        //throw new SqlParseException("can not support this type " + expr.getClass());
    }
    return value;
}
 
Example 4
Source Project: dble   Source File: ItemFuncIstrue.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public SQLExpr toExpression() {
    SQLExpr left = args.get(0).toExpression();
    return new SQLBinaryOpExpr(left, SQLBinaryOperator.Is, new SQLBooleanExpr(true));
}
 
Example 5
Source Project: dble   Source File: ItemFuncIsnottrue.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public SQLExpr toExpression() {
    SQLExpr left = args.get(0).toExpression();
    return new SQLBinaryOpExpr(left, SQLBinaryOperator.IsNot, new SQLBooleanExpr(true));
}
 
Example 6
Source Project: dble   Source File: ItemFuncIsnotfalse.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public SQLExpr toExpression() {
    SQLExpr left = args.get(0).toExpression();
    return new SQLBinaryOpExpr(left, SQLBinaryOperator.IsNot, new SQLBooleanExpr(false));
}
 
Example 7
Source Project: dble   Source File: ItemFuncIsfalse.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public SQLExpr toExpression() {
    SQLExpr left = args.get(0).toExpression();
    return new SQLBinaryOpExpr(left, SQLBinaryOperator.Is, new SQLBooleanExpr(false));
}