MCPcopy Index your code
hub / github.com/apache/tomcat / ExpressionBuilder

Class ExpressionBuilder

java/org/apache/el/lang/ExpressionBuilder.java:48–329  ·  view source on GitHub ↗

Builds compiled EL expressions from parsed AST nodes.

Source from the content-addressed store, hash-verified

46 * Builds compiled EL expressions from parsed AST nodes.
47 */
48public final class ExpressionBuilder implements NodeVisitor {
49
50 private static final SynchronizedStack<ELParser> parserCache = new SynchronizedStack<>();
51
52 private static final int CACHE_SIZE;
53 private static final String CACHE_SIZE_PROP = "org.apache.el.ExpressionBuilder.CACHE_SIZE";
54
55 static {
56 String cacheSizeStr = System.getProperty(CACHE_SIZE_PROP, "5000");
57 CACHE_SIZE = Integer.parseInt(cacheSizeStr);
58 }
59
60 private static final ConcurrentCache<String,Node> expressionCache = new ConcurrentCache<>(CACHE_SIZE);
61
62 private FunctionMapper fnMapper;
63
64 private VariableMapper varMapper;
65
66 private final String expression;
67
68 /**
69 * Creates a new ExpressionBuilder for the given expression and context.
70 *
71 * @param expression the EL expression string
72 * @param ctx the EL context
73 * @throws ELException if the expression is invalid
74 */
75 public ExpressionBuilder(String expression, ELContext ctx) throws ELException {
76 this.expression = expression;
77
78 FunctionMapper ctxFn = ctx.getFunctionMapper();
79 VariableMapper ctxVar = ctx.getVariableMapper();
80
81 if (ctxFn != null) {
82 this.fnMapper = new FunctionMapperFactory(ctxFn);
83 }
84 if (ctxVar != null) {
85 this.varMapper = new VariableMapperFactory(ctxVar);
86 }
87 }
88
89 /**
90 * Creates a parsed AST node for the given expression string.
91 *
92 * @param expr the expression string to parse
93 * @return the parsed AST node
94 * @throws ELException if parsing fails
95 */
96 public static Node createNode(String expr) throws ELException {
97 return createNodeInternal(expr);
98 }
99
100 private static Node createNodeInternal(String expr) throws ELException {
101 if (expr == null) {
102 throw new ELException(MessageFactory.get("error.null"));
103 }
104
105 Node n = expressionCache.get(expr);

Callers

nothing calls this directly

Calls 2

getPropertyMethod · 0.65
parseIntMethod · 0.45

Tested by

no test coverage detected