org.apache.el.parser.AstDynamicExpression Java Examples

The following examples show how to use org.apache.el.parser.AstDynamicExpression. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExpressionBuilder.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
private Node build() throws ELException {
    Node n = createNodeInternal(this.expression);
    this.prepare(n);
    if (n instanceof AstDeferredExpression
            || n instanceof AstDynamicExpression) {
        n = n.jjtGetChild(0);
    }
    return n;
}
 
Example #2
Source File: ExpressionBuilder.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
private Node build() throws ELException {
    Node n = createNodeInternal(this.expression);
    this.prepare(n);
    if (n instanceof AstDeferredExpression
            || n instanceof AstDynamicExpression) {
        n = n.jjtGetChild(0);
    }
    return n;
}
 
Example #3
Source File: ExpressionBuilder.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
private Node build() throws ELException {
    Node n = createNodeInternal(this.expression);
    this.prepare(n);
    if (n instanceof AstDeferredExpression
            || n instanceof AstDynamicExpression) {
        n = n.jjtGetChild(0);
    }
    return n;
}
 
Example #4
Source File: ExpressionBuilder.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
private static final Node createNodeInternal(String expr)
        throws ELException {
    if (expr == null) {
        throw new ELException(MessageFactory.get("error.null"));
    }

    Node n = cache.get(expr);
    if (n == null) {
        try {
            n = (new ELParser(new StringReader(expr)))
                    .CompositeExpression();

            // validate composite expression
            int numChildren = n.jjtGetNumChildren();
            if (numChildren == 1) {
                n = n.jjtGetChild(0);
            } else {
                Class<?> type = null;
                Node child = null;
                for (int i = 0; i < numChildren; i++) {
                    child = n.jjtGetChild(i);
                    if (child instanceof AstLiteralExpression)
                        continue;
                    if (type == null)
                        type = child.getClass();
                    else {
                        if (!type.equals(child.getClass())) {
                            throw new ELException(MessageFactory.get(
                                    "error.mixed", expr));
                        }
                    }
                }
            }

            if (n instanceof AstDeferredExpression
                    || n instanceof AstDynamicExpression) {
                n = n.jjtGetChild(0);
            }
            cache.put(expr, n);
        } catch (Exception e) {
            throw new ELException(
                    MessageFactory.get("error.parseFail", expr), e);
        }
    }
    return n;
}
 
Example #5
Source File: ExpressionBuilder.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
private static final Node createNodeInternal(String expr)
        throws ELException {
    if (expr == null) {
        throw new ELException(MessageFactory.get("error.null"));
    }

    Node n = cache.get(expr);
    if (n == null) {
        try {
            n = (new ELParser(new StringReader(expr)))
                    .CompositeExpression();

            // validate composite expression
            int numChildren = n.jjtGetNumChildren();
            if (numChildren == 1) {
                n = n.jjtGetChild(0);
            } else {
                Class<?> type = null;
                Node child = null;
                for (int i = 0; i < numChildren; i++) {
                    child = n.jjtGetChild(i);
                    if (child instanceof AstLiteralExpression)
                        continue;
                    if (type == null)
                        type = child.getClass();
                    else {
                        if (!type.equals(child.getClass())) {
                            throw new ELException(MessageFactory.get(
                                    "error.mixed", expr));
                        }
                    }
                }
            }

            if (n instanceof AstDeferredExpression
                    || n instanceof AstDynamicExpression) {
                n = n.jjtGetChild(0);
            }
            cache.put(expr, n);
        } catch (Exception e) {
            throw new ELException(
                    MessageFactory.get("error.parseFail", expr), e);
        }
    }
    return n;
}