Examples of ExqlContext


Examples of net.paoding.rose.jade.statement.expression.ExqlContext

    public void testExqlContext() {

        Date current = new Date();

        ExqlContext context = new ExqlContextImpl(1024);

        context.fillText("WHERE uid = ");
        context.fillValue(102);
        context.fillText(" AND sid IN (");
        context.fillValue(new int[] { 11, 12, 24, 25, 31, 32, 33 });
        context.fillText(") AND (create_time > ");
        context.fillValue(current);
        context.fillText(" OR create_time <= ");
        context.fillValue(current);
        context.fillChar(')');

        Assert.assertEquals( // NL
                "WHERE uid = ? AND sid IN (?,?,?,?,?,?,?) "
                        + "AND (create_time > ? OR create_time <= ?)", // NL
                context.flushOut());

        Object[] expectArray = new Object[] { 102, 11, 12, 24, 25, 31, 32, 33, // NL
                current, current };
        Object[] paramArray = context.getParams();

        Assert.assertEquals(expectArray.length, paramArray.length);
        for (int i = 0; i < expectArray.length; i++) {
            Assert.assertEquals(expectArray[i], paramArray[i]);
        }
View Full Code Here

Examples of net.paoding.rose.jade.statement.expression.ExqlContext

                .compile("SELECT #(:expr1.length()), :expr2.class.name,"
                        + " ##(:expr3) WHERE #if(:expr4) {e = :expr4} #else {e IS NULL}"
                        + "#for(variant in :expr5.bytes) { AND c = :variant}" // NL
                        + " GROUP BY ##(:expr1) ASC");

        ExqlContext context = new ExqlContextImpl(1024);

        HashMap<String, Object> map = new HashMap<String, Object>();

        map.put("expr1", expr1);
        map.put("expr2", expr2);
        map.put("expr3", expr3);
        map.put("expr4", expr4);
        map.put("expr5", expr5);

        Assert.assertEquals("SELECT ?, ?, expr3 WHERE e = ? AND c = ? AND c = ? "
                + "AND c = ? AND c = ? AND c = ? GROUP BY expr1 ASC", // NL
                pattern.execute(context, map));

        Object[] expectArray = new Object[] { expr1.length(), expr2.getClass().getName(), expr4,
                expr5.getBytes()[0], expr5.getBytes()[1], expr5.getBytes()[2], expr5.getBytes()[3],
                expr5.getBytes()[4] };
        Object[] paramArray = context.getParams();

        Assert.assertEquals(expectArray.length, paramArray.length);
        for (int i = 0; i < expectArray.length; i++) {
            Assert.assertEquals(expectArray[i], paramArray[i]);
        }
View Full Code Here

Examples of net.paoding.rose.jade.statement.expression.ExqlContext

                .compile("SELECT #($expr1.length()), #($expr2.class.name),"
                        + " $expr3 WHERE #if($expr4) {e = #($expr4)} #else {e IS NULL}"
                        + "#for(variant in $expr5.bytes) { AND c = :variant}" // NL
                        + " GROUP BY $expr1 ASC");

        ExqlContext context = new ExqlContextImpl(1024);

        HashMap<String, Object> map = new HashMap<String, Object>();

        map.put("expr1", expr1);
        map.put("expr2", expr2);
        map.put("expr3", expr3);
        map.put("expr4", expr4);
        map.put("expr5", expr5);

        Assert.assertEquals("SELECT ?, ?, expr3 WHERE e = ? AND c = ? AND c = ? "
                + "AND c = ? AND c = ? AND c = ? GROUP BY expr1 ASC", // NL
                pattern.execute(context, map, map));

        Object[] expectArray = new Object[] { expr1.length(), expr2.getClass().getName(), expr4,
                expr5.getBytes()[0], expr5.getBytes()[1], expr5.getBytes()[2], expr5.getBytes()[3],
                expr5.getBytes()[4] };
        Object[] paramArray = context.getParams();

        Assert.assertEquals(expectArray.length, paramArray.length);
        for (int i = 0; i < expectArray.length; i++) {
            Assert.assertEquals(expectArray[i], paramArray[i]);
        }
View Full Code Here

Examples of net.paoding.rose.jade.statement.expression.ExqlContext

                .compile("SELECT #(:expr1.length()), #($expr2.bytes[:expr1.length() - 1]),"
                        + " $expr3 WHERE #if($expr4) {e = :expr4} #else {e IS NULL}"
                        + "#for(variant in $expr5.bytes) { AND c = :variant}" // NL
                        + " GROUP BY $expr1 ASC");

        ExqlContext context = new ExqlContextImpl(1024);

        HashMap<String, Object> map = new HashMap<String, Object>();

        map.put("expr1", expr1);
        map.put("expr2", expr2);
        map.put("expr3", expr3);
        map.put("expr4", expr4);
        map.put("expr5", expr5);

        Assert.assertEquals("SELECT ?, ?, expr3 WHERE e = ? AND c = ? AND c = ? "
                + "AND c = ? AND c = ? AND c = ? GROUP BY expr1 ASC", // NL
                pattern.execute(context, map, map));

        Object[] expectArray = new Object[] { expr1.length(), expr2.getBytes()[expr1.length() - 1],
                expr4, expr5.getBytes()[0], expr5.getBytes()[1], expr5.getBytes()[2],
                expr5.getBytes()[3], expr5.getBytes()[4] };
        Object[] paramArray = context.getParams();

        Assert.assertEquals(expectArray.length, paramArray.length);
        for (int i = 0; i < expectArray.length; i++) {
            Assert.assertEquals(expectArray[i], paramArray[i]);
        }
View Full Code Here

Examples of net.paoding.rose.jade.statement.expression.ExqlContext

        }

        // 编译下列语句
        ExqlPattern pattern = new ExqlCompiler(string).compile();

        ExqlContext context = new ExqlContextImpl(string.length());

        HashMap<String, Object> map = new HashMap<String, Object>();

        map.put("expr1", "expr1");
        map.put("expr2", "expr2");
        map.put("expr3", "expr3");
        map.put("expr4", "expr4");
        map.put("expr5", "expr5");
        // map.put("expr6", "expr6");
        map.put("expr7", "expr7");

        System.out.println(pattern.execute(context, map, map));
        System.out.println(Arrays.toString(context.getParams()));
    }
View Full Code Here

Examples of net.paoding.rose.jade.statement.expression.ExqlContext

    //--------------

    // 进行简单测试
    public static void main(String... args) throws Exception {

        ExqlContext context = new ExqlContextImpl(1024);

        context.fillText("WHERE uid = ");
        context.fillValue(102);
        context.fillText(" AND sid IN (");
        context.fillValue(new int[] { 11, 12, 24, 25, 31, 32, 33 });
        context.fillText(") AND (create_time > ");
        context.fillValue(new Date());
        context.fillText(" OR create_time <= ");
        context.fillValue(new Date());
        context.fillChar(')');

        System.out.println(context.flushOut());
        System.out.println(Arrays.toString(context.getParams()));
    }
View Full Code Here

Examples of net.paoding.rose.jade.statement.expression.ExqlContext

                .compile("SELECT #(:expr1.length()), :expr2.class.name,"
                        + " ##(:expr3) WHERE #if(:expr4) {e = :expr4} #else {e IS NULL}"
                        + "#for(variant in :expr5.bytes) { AND c = :variant}" // NL
                        + " GROUP BY #!(:expr1) ASC");

        ExqlContext context = new ExqlContextImpl(1024);

        HashMap<String, Object> map = new HashMap<String, Object>();

        map.put("expr1", "expr1");
        map.put("expr2", "expr2");
        map.put("expr3", "expr3");
        map.put("expr4", "expr4");
        map.put("expr5", "expr5");

        System.out.println(pattern.execute(context, map));
        System.out.println(Arrays.toString(context.getParams()));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.