Examples of AviatorString


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

                result = AviatorLong.valueOf(numberToken.getNumber());
            }
            break;
        case String:
            // load string
            result = new AviatorString((String) lookhead.getValue(null));
            break;
        case Pattern:
            // load pattern
            result = new AviatorPattern((String) lookhead.getValue(null));
            break;
View Full Code Here

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

        String target = FunctionUtils.getStringValue(0, args, env);
        Number beginIndex = FunctionUtils.getNumberValue(1, args, env);
        switch (args.length) {
        case 2:

            return new AviatorString(target.substring(beginIndex.intValue()));
        case 3:
            Number endIndex = FunctionUtils.getNumberValue(2, args, env);
            return new AviatorString(target.substring(beginIndex.intValue(), endIndex.intValue()));

        }
        return null;
    }
View Full Code Here

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

    @Test
    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

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

    @Test(expected = ExpressionRuntimeException.class)
    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

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

        env.put("s1", "hello");
        env.put("s2", "he");
        env.put("ch", 'h');
        env.put("temp", "temp");

        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.AviatorString

    @Test
    public void testCall_WithOneArgument() throws Exception {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        System.setOut(new PrintStream(out));
        AviatorObject[] args = new AviatorObject[1];
        args[0] = new AviatorString("hello");
        fun.call(null, args);
        out.flush();
        out.close();
        String lineSeparator = System.getProperty("line.separator");
        byte[] data = out.toByteArray();
View Full Code Here

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

    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();
        out.close();
View Full Code Here

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

    public void testCall() {
        Map<String, Object> env = new HashMap<String, Object>();
        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.AviatorString

    }


    @Test(expected = IllegalArgumentException.class)
    public void testIllegalArguments_Three() {
        this.function.call(null, new AviatorString("hello"), new AviatorString("hello"), new AviatorString("hello"));
    }
View Full Code Here

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

        Map<String, Object> env = new HashMap<String, Object>();
        env.put("s1", "hello");
        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
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.