Package org.apache.beehive.netui.script.el

Examples of org.apache.beehive.netui.script.el.ParsedExpression


    }

// 3.
    final public ParsedExpression parse() throws ParseException {
        Token t = null;
        ParsedExpression pe = new ParsedExpression();
        Term term = null;
        label_1:
        while(true) {
            switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
                case NON_EXPRESSION_TEXT:
                case START_EXPRESSION:
                case ESCAPED_START_EXPRESSION:
                    ;
                    break;
                default:
                    jj_la1[0] = jj_gen;
                    break label_1;
            }
            switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
                case NON_EXPRESSION_TEXT:
                    term = parseLiteralTerm();
                    pe.addTerm(term);
                    break;
                case START_EXPRESSION:
                    jj_consume_token(START_EXPRESSION);
                    term = parseExpression();
                    jj_consume_token(END_EXPRESSION);
                    pe.addTerm(term);
                    break;
                case ESCAPED_START_EXPRESSION:
                    jj_consume_token(ESCAPED_START_EXPRESSION);
                    term = parseExpression();
                    jj_consume_token(END_EXPRESSION);
                    pe.addTerm(new LiteralTerm("\\"));
                    pe.addTerm(term);
                    break;
                default:
                    jj_la1[1] = jj_gen;
                    jj_consume_token(-1);
                    throw new ParseException();
View Full Code Here


    /* do not construct */
    private ParseUtils() {}

    public static final ParsedExpression parse(String exprStr) {
        ParsedExpression pe = (ParsedExpression) PARSED_CACHE.get(exprStr);

        if(pe != null)
            return pe;

        try {
            NetUIELParser learn = new NetUIELParser(new StringReader(exprStr));

            ParsedExpression expr = learn.parse();
            expr.seal();

            /* infrequent; this should only happen when there is a cache miss */
            synchronized(PARSED_CACHE) {
                PARSED_CACHE.put(exprStr, expr);
            }
View Full Code Here

            throw new ExpressionParseException(msg, tm);
        }
    }

    public static final Object evaluate(String exprStr, NetUIVariableResolver vr) {
        ParsedExpression expr = parse(exprStr);
        assert expr != null;
        return expr.evaluate(vr);
    }
View Full Code Here

        assert expr != null;
        return expr.evaluate(vr);
    }

    public static final void update(String exprStr, Object value, NetUIVariableResolver vr) {
        ParsedExpression expr = parse(exprStr);
        assert expr != null;
        expr.update(value, vr);
    }
View Full Code Here

    }

// 3.
    final public ParsedExpression parse() throws ParseException {
        Token t = null;
        ParsedExpression pe = new ParsedExpression();
        Term term = null;
        label_1:
        while(true) {
            switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
                case NON_EXPRESSION_TEXT:
                case START_EXPRESSION:
                case ESCAPED_START_EXPRESSION:
                    ;
                    break;
                default:
                    jj_la1[0] = jj_gen;
                    break label_1;
            }
            switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
                case NON_EXPRESSION_TEXT:
                    term = parseLiteralTerm();
                    pe.addTerm(term);
                    break;
                case START_EXPRESSION:
                    jj_consume_token(START_EXPRESSION);
                    term = parseExpression();
                    jj_consume_token(END_EXPRESSION);
                    pe.addTerm(term);
                    break;
                case ESCAPED_START_EXPRESSION:
                    jj_consume_token(ESCAPED_START_EXPRESSION);
                    term = parseExpression();
                    jj_consume_token(END_EXPRESSION);
                    pe.addTerm(new LiteralTerm("\\"));
                    pe.addTerm(term);
                    break;
                default:
                    jj_la1[1] = jj_gen;
                    jj_consume_token(-1);
                    throw new ParseException();
View Full Code Here

     * Parse the givne String into a {@link ParsedExpression}.
     * @param expression the expression
     * @return the parsed expression
     */
    public static ParsedExpression parse(String expression) {
        ParsedExpression pe = (ParsedExpression)PARSED_CACHE.get(expression);

        if(pe != null)
            return pe;

        try {
            NetUIELParser learn = new NetUIELParser(new StringReader(expression));

            ParsedExpression expr = learn.parse();
            expr.seal();

            /* infrequent; this should only happen when there is a cache miss */
            synchronized(PARSED_CACHE) {
                PARSED_CACHE.put(expression, expr);
            }
View Full Code Here

            throw new ExpressionParseException(msg, tm);
        }
    }

    public static Object evaluate(String exprStr, NetUIVariableResolver vr) {
        ParsedExpression expr = parse(exprStr);
        assert expr != null;
        return expr.evaluate(vr);
    }
View Full Code Here

        assert expr != null;
        return expr.evaluate(vr);
    }

    public static void update(String exprStr, Object value, NetUIVariableResolver vr) {
        ParsedExpression expr = parse(exprStr);
        assert expr != null;
        expr.update(value, vr);
    }
View Full Code Here

TOP

Related Classes of org.apache.beehive.netui.script.el.ParsedExpression

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.