Package com.googlecode.aviator.lexer.token

Examples of com.googlecode.aviator.lexer.token.StringToken


            final Number value = (Number) operand.getValue(null);
            token = new NumberToken(value, value.toString());
            break;
        case String:
            final String str = (String) operand.getValue(null);
            token = new StringToken(str, -1);
            break;
        case Pattern:
            token = new PatternToken(((AviatorPattern) operand).getPattern().pattern(), -1);
            break;
        }
View Full Code Here


    }


    @Test
    public void testOnConstant_String() throws Exception {
        this.codeGenerator.onConstant(new StringToken("hello", 0));
        Expression exp = this.codeGenerator.getResult();
        Object result = exp.execute();
        assertEquals("hello", result);
    }
View Full Code Here

    }


    @Test
    public void testOnMatch() throws Exception {
        codeGenerator.onConstant(new StringToken("killme2008@gmail.com", 0));
        codeGenerator.onConstant(new PatternToken("^[\\w\\-]([\\.\\w])+[\\w]+@([\\w\\-]+\\.)+[a-z]{2,4}$", 1));
        codeGenerator.onMatch(null);
        Object result = eval(new HashMap<String, Object>());
        assertEquals(Boolean.TRUE, result);
    }
View Full Code Here


    @Test
    public void testOnMethod_withTwoArguments() throws Exception {
        codeGenerator.onMethodName(new Variable("string.substring", -1));
        codeGenerator.onConstant(new StringToken("hello", -1));
        codeGenerator.onMethodParameter(null);
        codeGenerator.onConstant(new NumberToken(2L, "2"));
        codeGenerator.onMethodParameter(null);
        codeGenerator.onConstant(new NumberToken(5L, "5"));
        codeGenerator.onMethodParameter(null);
View Full Code Here

                else {
                    sb.append(peek);
                }
            }
            nextChar();
            return new StringToken(sb.toString(), startIndex);
        }

        Token<Character> token = new CharToken(peek, iterator.getIndex());
        nextChar();
        return token;
View Full Code Here

TOP

Related Classes of com.googlecode.aviator.lexer.token.StringToken

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.