Package com.redspr.redquerybuilder.core.client.expression

Examples of com.redspr.redquerybuilder.core.client.expression.Expression


    // XXX better name "forChild"
    public static JoinHelper getParent(TableFilter tf) {
        // for (TableFilter tf2 : tf.getSession().getFilters()) {
        // TableFilter child2 = tf2.getJoin();
        Expression joinCondition = tf.getJoinCondition();
        JoinHelper thing = new JoinHelper(tf, joinCondition);

        if (thing.isSimple()) {
            return thing;
        }
View Full Code Here


     *
     * @param cond
     *            the condition to add
     */
    public void addCondition(Expression cond) {
        Expression condition = getCondition();
        if (condition == null) {
            condition = cond;
        } else {
            condition = new ConditionAndOr(session, ConditionAndOr.AND, cond, condition);
        }
View Full Code Here

    }

    @Override
    public void traverse(Callback callback) {
        super.traverse(callback);
        Expression condition = getCondition();
        if (condition != null) {
            condition.traverse(callback);
        }
    }
View Full Code Here

        }
        //command.setSQL(sql);
    }

    private Expression readExpression() throws SQLException {
        Expression r = readAnd();
        while (readIf("OR")) {
            r = new ConditionAndOr(session, ConditionAndOr.OR, r, readAnd());
        }
        return r;
    }
View Full Code Here

        }
        return r;
    }

    private Expression readAnd() throws SQLException {
        Expression r = readCondition();
        while (readIf("AND")) {
            r = new ConditionAndOr(session, ConditionAndOr.AND, r, readCondition());
        }
        return r;
    }
View Full Code Here

//            // can not reduce expression because it might be a union except
//            // query with distinct
//            read(")");
//            return new ConditionExists(query);
//        }
        Expression r = readConcat();
        while (true) {
//            // special case: NOT NULL is not part of an expression (as in CREATE
//            // TABLE TEST(ID INT DEFAULT 0 NOT NULL))
//            int backup = parseIndex;
            boolean not = false;
            if (readIf("NOT")) {
                not = true;
//                if (isToken("NULL")) {
//                    // this really only works for NOT NULL!
//                    parseIndex = backup;
//                    currentToken = "NOT";
//                    break;
//                }
            }
            Operator op = readCustom(not);
            if (op != null) {
                Expression b;
                switch (op.getCardinality()) {
                case ZERO: {
                    b = null;
                    break;
                }
                case ONE: {
                    b = readConcat();
                    break;
                }
                case MULTI: {
                    read("(");
                  Collection<Expression> v = new ArrayList<Expression>();
                  Expression last;
                  do {
                      last = readExpression();
                      v.add(last);
                  } while (readIf(","));
                  read(")");
                  b = new Parameter(session, v);
                  break;
                }
                default:
                    throw new IllegalArgumentException("Can't handle "
                            + op.getCardinality());
                }

                Expression esc = null;
                if (readIf("ESCAPE")) {
                    esc = readConcat();
                }
                recompileAlways = true;
                r = new Comparison(session, op.getName(), r, b);
            } //else if (readIf("REGEXP")) {
//                Expression b = readConcat();
//                r = new CompareLike(database.getCompareMode(), r, b, null, true);
           // } else
              if (readIf("IS")) {
                String type;
                if (readIf("NOT")) {
                    type = Operator.IS_NOT_NULL;
                } else {
                    type = Operator.IS_NULL;
                }
                read("NULL");
                r = new Comparison(session, type, r, null);
//            } else if (readIf("IN")) {
//                if (SysProperties.OPTIMIZE_IN && !SysProperties.OPTIMIZE_IN_LIST) {
//                    recompileAlways = true;
//                }
//                read("(");
//                if (readIf(")")) {
//                    r = ValueExpression.get(ValueBoolean.get(false));
//                } else {
//                    if (isToken("SELECT") || isToken("FROM")) {
//                        Query query = parseSelect();
//                        r = new ConditionInSelect(database, r, query, false, Comparison.EQUAL);
//                    } else {
//                        ObjectArray<Expression> v = ObjectArray.newInstance();
//                        Expression last;
//                        do {
//                            last = readExpression();
//                            v.add(last);
//                        } while (readIf(","));
//                        if (v.size() == 1 && (last instanceof Subquery)) {
//                            Subquery s = (Subquery) last;
//                            Query q = s.getQuery();
//                            r = new ConditionInSelect(database, r, q, false, Comparison.EQUAL);
//                        } else {
//                            r = new ConditionIn(database, r, v);
//                        }
//                    }
//                    read(")");
//                }
//            } else if (readIf("BETWEEN")) {
//                Expression low = readConcat();
//                read("AND");
//                Expression high = readConcat();
//                Expression condLow = new Comparison(session, Comparison.SMALLER_EQUAL, low, r);
//                Expression condHigh = new Comparison(session, Comparison.BIGGER_EQUAL, high, r);
//                r = new ConditionAndOr(ConditionAndOr.AND, condLow, condHigh);
            } else {
                String compareType = getCompareType(currentTokenType);
                if (compareType == null) {
                    break;
                }
                read();
//                if (readIf("ALL")) {
//                    read("(");
//                    Query query = parseSelect();
//                    r = new ConditionInSelect(database, r, query, true, compareType);
//                    read(")");
//                } else if (readIf("ANY") || readIf("SOME")) {
//                    read("(");
//                    Query query = parseSelect();
//                    r = new ConditionInSelect(database, r, query, false, compareType);
//                    read(")");
//                } else {
                    Expression right = readConcat();
//                    if (readIf("(") && readIf("+") && readIf(")")) {
//                        // support for a subset of old-fashioned Oracle outer
//                        // join with (+)
//                        if (r instanceof ExpressionColumn && right instanceof ExpressionColumn) {
//                            ExpressionColumn leftCol = (ExpressionColumn) r;
View Full Code Here

        }
        return r;
    }

    private Expression readConcat() throws SQLException {
        Expression r = readSum();
        return r;
//        while (true) {
//            if (readIf("||")) {
//                r = new Operation(Operation.CONCAT, r, readSum());
//            } else if (readIf("~")) {
View Full Code Here

//            }
//        }
    }

    private Expression readSum() throws SQLException {
        Expression r = readFactor();
//        while (true) {
//            if (readIf("+")) {
//                r = new Operation(Operation.PLUS, r, readFactor());
//            } else if (readIf("-")) {
//                r = new Operation(Operation.MINUS, r, readFactor());
View Full Code Here

//            }
//        }
    }

    private Expression readFactor() throws SQLException {
        Expression r = readTerm();
//        while (true) {
//            if (readIf("*")) {
//                r = new Operation(Operation.MULTIPLY, r, readTerm());
//            } else if (readIf("/")) {
//                r = new Operation(Operation.DIVIDE, r, readTerm());
View Full Code Here

//        }
        return new ExpressionColumn(session, null, objectName, name);
    }

    private Expression readTerm() throws SQLException {
        Expression r = null;
        switch (currentTokenType) {
//        case AT:
//            read();
//            r = new Variable(session, readAliasIdentifier());
//            if (readIf(":=")) {
View Full Code Here

TOP

Related Classes of com.redspr.redquerybuilder.core.client.expression.Expression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.