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

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


                throw getSyntaxError();
            }
            if (indexedParameterList != null) {
                for (int i = 0; i < indexedParameterList.size(); i++) {
                    if (indexedParameterList.get(i) == null) {
                        indexedParameterList.set(i, new Parameter(session, i));
                    }
                }
                parameters = indexedParameterList;
            }
            if (readIf("{")) {
                do {
                    int index = (int) readLong() - 1;
                    if (index < 0 || index >= parameters.size()) {
                        throw getSyntaxError();
                    }
                    Parameter p = parameters.get(index);
                    if (p == null) {
                        throw getSyntaxError();
                    }
                    read(":");
                    Expression expr = readExpression();
View Full Code Here


                  do {
                      last = readExpression();
                      v.add(last);
                  } while (readIf(","));
                  read(")");
                  b = new Parameter(session, v);
                  break;
                }
                default:
                    throw new IllegalArgumentException("Can't handle "
                            + op.getCardinality());
View Full Code Here

//            break;
        case PARAMETER:
            // there must be no space between ? and the number
            boolean indexed = Character.isDigit(sqlCommandChars[parseIndex]);
            read();
            Parameter p;
//            if (indexed && currentTokenType == VALUE && currentValue.getType() == Value.INT) {
//                if (indexedParameterList == null) {
//                    if (parameters == null) {
//                        // this can occur when parsing expressions only (for example check constraints)
//                        throw getSyntaxError();
//                    } else if (parameters.size() > 0) {
//                        throw Message.getSQLException(ErrorCode.CANNOT_MIX_INDEXED_AND_UNINDEXED_PARAMS);
//                    }
//                    indexedParameterList = ObjectArray.newInstance();
//                }
//                int index = 0;//currentValue.getInt() - 1;
//                if (index < 0 || index >= Constants.MAX_PARAMETER_INDEX) {
//                    throw Message.getInvalidValueException("" + index, "Parameter Index");
//                }
//                if (indexedParameterList.size() <= index) {
//                    indexedParameterList.setSize(index + 1);
//                }
//                p = indexedParameterList.get(index);
//                if (p == null) {
//                    p = new Parameter(index);
//                    indexedParameterList.set(index, p);
//                }
//                read();
//            } else {
//                if (indexedParameterList != null) {
//                    throw Message.getSQLException(ErrorCode.CANNOT_MIX_INDEXED_AND_UNINDEXED_PARAMS);
//                }
                p = new Parameter(session, parameters.size());
//            }
            parameters.add(p);
            r = p;
            break;
//        case KEYWORD:
View Full Code Here

    @Test
    public void testComparison() throws Exception {
        Parser p = new Parser(getSession());
        Comparison c = (Comparison) p.parseExpression("id = ?");
        ExpressionColumn left = (ExpressionColumn) c.getLeft();
        Parameter param = (Parameter) c.getRight();
    }
View Full Code Here

        cb.fireDirty();

        {
            Comparison comp = (Comparison) s.getCondition();
            Parameter right = (Parameter) comp.getRight();
            Element selectElmt = right.getElement();

            String html = "<select class='gwt-ListBox' multiple='multiple' size='2'>"
                    + "<option value='A'>A</option>"
                    + "<option value='B'>B</option>"
                    + "<option value='C'>C</option>" + "</select>";
            assertEquals(html, selectElmt);

            assertEquals("SELECT X.ID\nFROM PERSON X\nWHERE (X.CATEGORY IN (?, ?))", s.getSQL(args()));


            // change to sex
            ExpressionColumn left2 = (ExpressionColumn) comp.getLeft();
            left2.updateColumn("X", sess.getDatabase().getMainSchema()
                    .findTableOrView("PERSON").getColumn("category2"));
            cb.fireDirty();
        }

        {
            Comparison comp = (Comparison) s.getCondition();
            Parameter right = (Parameter) comp.getRight();
            Element selectElmt = right.getElement();

            String html = "<select class='gwt-ListBox' multiple='multiple' size='2'>"
                    + "<option value='X'>X</option>"
                    + "<option value='Y'>Y</option>"
                    + "<option value='Z'>Z</option>" + "</select>";
            assertEquals(html, selectElmt);

            assertEquals("SELECT X.ID\nFROM PERSON X\nWHERE (X.category2 IN ?)", s.getSQL(args()));

            // change to sex
            ExpressionColumn left2 = (ExpressionColumn) comp.getLeft();
            left2.updateColumn("X", sess.getDatabase().getMainSchema()
                    .findTableOrView("PERSON").getColumn("sex"));
            cb.fireDirty();
        }

        {
            Comparison comp = (Comparison) s.getCondition();
            Parameter right = (Parameter) comp.getRight();

            Element selectElmt = right.getElement();

            String html = "<select class='gwt-ListBox'>"
                    + "<option value='Please select...'>Please select...</option>"
                    + "<option value='M'>M</option>"
                    + "<option value='F'>F</option>"
View Full Code Here

        CommandBuilder cb = new CommandBuilder(sess, "SELECT x.id FROM Person x WHERE sex = ?", args);
        RootPanel.get().add(cb);
        Select s = cb.getSelect();

        Comparison c = (Comparison) s.getCondition();
        Parameter p = (Parameter) c.getRight();
        SelectEditorWidget sew = (SelectEditorWidget) p.getEditorWidget();
        assertEquals("M", sew.getValue());
    }
View Full Code Here

        s2.add(new MultiWordSuggestion("F", "F"));

        config.getEnumerateCallback().onSuccess(new Response(s2));

        Comparison c = (Comparison) s.getCondition();
        Parameter p = (Parameter) c.getRight();
        SelectEditorWidget sew = (SelectEditorWidget) p.getEditorWidget();
        assertEquals("M", sew.getValue());
    }
View Full Code Here

       // cb.fireDirty();

        ConditionAndOr andOr = (ConditionAndOr) s.getCondition();
        Comparison comp = (Comparison) andOr.getLeft();
        Parameter right = (Parameter) comp.getRight();
        Element selectElmt = right.getElement();

        String html = "<input type='text' class='gwt-TextBox' value='13'>";
        assertEquals(html, selectElmt);
    }
View Full Code Here

TOP

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

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.