Package com.googlecode.aviator.runtime.type

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


            throw new ExpressionRuntimeException("There is no function named " + ((AviatorJavaType) args[1]).getName());
        }
        if (first == null) {
            throw new NullPointerException("null seq");
        }
        AviatorObject result = args[2];
        Class<?> clazz = first.getClass();

        if (Collection.class.isAssignableFrom(clazz)) {
            for (Object obj : (Collection<?>) first) {
                result = fun.call(env, result, new AviatorRuntimeJavaType(obj));
View Full Code Here


    public AviatorObject call(Map<String, Object> env, AviatorObject... args) {
        if (args.length != 2) {
            throw new IllegalArgumentException("include(seq,item)");
        }
        Object first = args[0].getValue(env);
        AviatorObject second = args[1];
        if (first == null) {
            throw new NullPointerException("null seq");
        }
        Class<?> clazz = first.getClass();
        boolean contains = false;
View Full Code Here

public class AviatorMethodUnitTest {
    @Test
    public void testInvoke1() {
        AviatorMethod aviatorMethod = new AviatorMethod("sysdate");
        AviatorObject result = aviatorMethod.invoke(AviatorEvaluator.FUNC_MAP, new ArrayList<AviatorObject>());
        assertNotNull(result);
        assertTrue(result.getValue(null) instanceof Date);
    }
View Full Code Here

    public void testInvoke2() {
        AviatorMethod aviatorMethod = new AviatorMethod("string.contains");
        final ArrayList<AviatorObject> argList = new ArrayList<AviatorObject>();
        argList.add(new AviatorString("hello"));
        argList.add(new AviatorString("hel"));
        AviatorObject result = aviatorMethod.invoke(AviatorEvaluator.FUNC_MAP, argList);
        assertEquals(AviatorBoolean.TRUE, result);
    }
View Full Code Here

    public void testCouldNotFindMethod() {
        AviatorMethod aviatorMethod = new AviatorMethod("string.contains_not");
        final ArrayList<AviatorObject> argList = new ArrayList<AviatorObject>();
        argList.add(new AviatorString("hello"));
        argList.add(new AviatorString("hel"));
        AviatorObject result = aviatorMethod.invoke(AviatorEvaluator.FUNC_MAP, argList);
        assertEquals(AviatorBoolean.TRUE, result);
    }
View Full Code Here

    @Test
    public void testInvoke_ReturnNull() {
        AviatorMethod aviatorMethod = new AviatorMethod("mock_test");
        AviatorEvaluator.addFunction(new MockFunction());
        AviatorObject result = aviatorMethod.invoke(AviatorEvaluator.FUNC_MAP, new ArrayList<AviatorObject>());
        assertNotNull(result);
        assertEquals(AviatorNil.NIL, result);
        AviatorEvaluator.removeFunction("mock_test");
    }
View Full Code Here

    @Test
    public void testCount_Array() {
        AviatorObject[] args = new AviatorObject[1];
        args[0] = new AviatorRuntimeJavaType(new String[10]);
        SeqCountFunction fun = new SeqCountFunction();
        AviatorObject result = fun.call(null, args);
        assertEquals(10, result.getValue(null));
    }
View Full Code Here

    @Test
    public void testCount_EmptyArray() {
        AviatorObject[] args = new AviatorObject[1];
        args[0] = new AviatorRuntimeJavaType(new String[0]);
        SeqCountFunction fun = new SeqCountFunction();
        AviatorObject result = fun.call(null, args);
        assertEquals(0, result.getValue(null));
    }
View Full Code Here

        final HashSet<Integer> set = new HashSet<Integer>();
        set.add(1);
        set.add(2);
        args[0] = new AviatorRuntimeJavaType(set);
        SeqCountFunction fun = new SeqCountFunction();
        AviatorObject result = fun.call(null, args);
        assertEquals(2, result.getValue(null));
    }
View Full Code Here

    public void testCount_String() {
        AviatorObject[] args = new AviatorObject[1];

        args[0] = new AviatorRuntimeJavaType("hello");
        SeqCountFunction fun = new SeqCountFunction();
        AviatorObject result = fun.call(null, args);
    }
View Full Code Here

TOP

Related Classes of com.googlecode.aviator.runtime.type.AviatorObject

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.