Examples of AviatorJavaType


Examples of com.googlecode.aviator.runtime.type.AviatorJavaType

        Map<String, Object> env = new HashMap<String, Object>();
        env.put("a", 300);
        env.put("b", -3.14);

        assertEquals(300, this.function.call(env, new AviatorJavaType("a")).getValue(null));
        assertEquals(3.14, this.function.call(env, new AviatorJavaType("b")).getValue(null));
    }
View Full Code Here

Examples of com.googlecode.aviator.runtime.type.AviatorJavaType

        AviatorObject[] args = new AviatorObject[1];
        args[0] = new AviatorRuntimeJavaType("hello");

        Map<String, Object> env = new HashMap<String, Object>();
        AviatorJavaType predicateName = (AviatorJavaType) fun.call(env, args);

        assertNotNull(predicateName);
        assertEquals(1, env.size());
        AviatorFunction predicate = (AviatorFunction) env.get(predicateName.getName());
        assertNotNull(predicate);
        AviatorObject result = predicate.call(null, args);
        // equals self
        assertTrue(result.booleanValue(null));
View Full Code Here

Examples of com.googlecode.aviator.runtime.type.AviatorJavaType

    @Test
    public void testMakePredicate_FixedValue() {
        SeqMakePredicateFunFunction fun =
                new SeqMakePredicateFunFunction("eq", OperatorType.EQ, new AviatorRuntimeJavaType("hello"));
        Map<String, Object> env = new HashMap<String, Object>();
        AviatorJavaType predicateName = (AviatorJavaType) fun.call(env);

        assertNotNull(predicateName);
        assertEquals(1, env.size());
        AviatorFunction predicate = (AviatorFunction) env.get(predicateName.getName());
        assertNotNull(predicate);
        AviatorObject[] args = new AviatorObject[1];
        args[0] = new AviatorRuntimeJavaType("hello");
        AviatorObject result = predicate.call(null, args);
        // equals self
View Full Code Here

Examples of com.googlecode.aviator.runtime.type.AviatorJavaType

        // generate a temp function object as predicate
        AviatorFunction fun = new SeqPredicateFunction(name, opType, value == null ? args[0] : value);
        final String funName = name + "_tmp_" + System.nanoTime();
        env.put(funName, fun);
        return new AviatorJavaType(funName);
    }
View Full Code Here

Examples of com.googlecode.aviator.runtime.type.AviatorJavaType

        assertTrue((Boolean) this.function.call(null, new AviatorString("hello"), new AviatorString("hel")).getValue(
            null));
        assertFalse((Boolean) this.function.call(null, new AviatorString("hello"), new AviatorString("world"))
            .getValue(null));
        assertTrue((Boolean) this.function.call(env, new AviatorString("hello"), new AviatorJavaType("s2")).getValue(
            env));
        assertTrue((Boolean) this.function.call(env, new AviatorString("hello"), new AviatorJavaType("ch")).getValue(
            env));
        assertTrue((Boolean) this.function.call(env, new AviatorJavaType("s1"), new AviatorJavaType("s2"))
            .getValue(env));
        assertFalse((Boolean) this.function.call(env, new AviatorJavaType("s1"), new AviatorJavaType("temp")).getValue(
            env));
        assertTrue((Boolean) this.function.call(env, new AviatorJavaType("s1"), new AviatorJavaType("ch"))
            .getValue(env));
        assertTrue((Boolean) this.function.call(env, new AviatorJavaType("s1"), new AviatorString("hel")).getValue(env));
    }
View Full Code Here

Examples of com.googlecode.aviator.runtime.type.AviatorJavaType

    @Test
    public void testCall_WithTwoArgument() throws Exception {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        System.setOut(new PrintStream(out));
        AviatorObject[] args = new AviatorObject[2];
        args[0] = new AviatorJavaType("out");
        args[1] = new AviatorString("hello");
        Map<String, Object> env = new HashMap<String, Object>();
        env.put("out", out);
        fun.call(env, args);
        out.flush();
View Full Code Here

Examples of com.googlecode.aviator.runtime.type.AviatorJavaType

        env.put("s1", "hello");
        env.put("s2", "hello world");

        assertEquals(5, function.call(null, new AviatorString("hello")).getValue(null));
        assertEquals(11, function.call(null, new AviatorString("hello world")).getValue(null));
        assertEquals(5, function.call(env, new AviatorJavaType("s1")).getValue(null));
        assertEquals(11, function.call(env, new AviatorJavaType("s2")).getValue(null));

    }
View Full Code Here

Examples of com.googlecode.aviator.runtime.type.AviatorJavaType

        env.put("s2", "llo");
        env.put("ch", 'o');

        assertTrue((Boolean) this.function.call(null, new AviatorString("hello"), new AviatorString("llo")).getValue(
            null));
        assertTrue((Boolean) this.function.call(env, new AviatorString("hello"), new AviatorJavaType("s2")).getValue(
            env));
        assertTrue((Boolean) this.function.call(env, new AviatorString("hello"), new AviatorJavaType("ch")).getValue(
            env));
        assertTrue((Boolean) this.function.call(env, new AviatorJavaType("s1"), new AviatorJavaType("s2"))
            .getValue(env));
        assertTrue((Boolean) this.function.call(env, new AviatorJavaType("s1"), new AviatorJavaType("ch"))
            .getValue(env));
        assertTrue((Boolean) this.function.call(env, new AviatorJavaType("s1"), new AviatorString("llo")).getValue(env));
    }
View Full Code Here

Examples of com.googlecode.aviator.runtime.type.AviatorJavaType

        SeqPredicateFunction predicate =
                new SeqPredicateFunction("eq_temp_1", OperatorType.EQ, new AviatorString("hello1"));
        Map<String, Object> env = new HashMap<String, Object>();
        env.putAll(AviatorEvaluator.FUNC_MAP);
        env.put("eq_temp_1", predicate);
        args[1] = new AviatorJavaType("eq_temp_1");
        SeqFilterFunction fun = new SeqFilterFunction();
        AviatorObject result = fun.call(env, args);
        Object[] array = (Object[]) result.getValue(null);
        assertEquals(1, array.length);
        for (Object i : array) {
View Full Code Here

Examples of com.googlecode.aviator.runtime.type.AviatorJavaType

    @Test
    public void testCall_WithTwoArgument() throws Exception {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        System.setOut(new PrintStream(out));
        AviatorObject[] args = new AviatorObject[2];
        args[0] = new AviatorJavaType("out");
        args[1] = new AviatorString("hello");
        Map<String, Object> env = new HashMap<String, Object>();
        env.put("out", out);
        fun.call(env, args);
        out.flush();
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.