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

Method getValue

java/org/apache/el/parser/AstIdentifier.java:57–114  ·  view source on GitHub ↗
(EvaluationContext ctx)

Source from the content-addressed store, hash-verified

55 }
56
57 @Override
58 public Object getValue(EvaluationContext ctx) throws ELException {
59 // Lambda parameters
60 if (ctx.isLambdaArgument(this.image)) {
61 return ctx.getLambdaArgument(this.image);
62 }
63
64 // Variable mapper
65 VariableMapper varMapper = ctx.getVariableMapper();
66 if (varMapper != null) {
67 ValueExpression expr = varMapper.resolveVariable(this.image);
68 if (expr != null) {
69 return expr.getValue(ctx.getELContext());
70 }
71 }
72
73 // EL Resolvers
74 ctx.setPropertyResolved(false);
75 Object result;
76 /*
77 * Putting the Boolean into the ELContext is part of a performance optimisation for ScopedAttributeELResolver.
78 * When looking up "foo", the resolver can't differentiate between ${ foo } and ${ foo.bar }. This is important
79 * because the expensive class lookup only needs to be performed in the later case. This flag tells the resolver
80 * if the lookup can be skipped.
81 */
82 if (parent instanceof AstValue) {
83 ctx.putContext(this.getClass(), Boolean.FALSE);
84 } else {
85 ctx.putContext(this.getClass(), Boolean.TRUE);
86 }
87 try {
88 result = ctx.getELResolver().getValue(ctx, null, this.image);
89 } finally {
90 // Always reset the flag to false so the optimisation is not applied
91 // inappropriately
92 ctx.putContext(this.getClass(), Boolean.FALSE);
93 }
94
95 if (ctx.isPropertyResolved()) {
96 return result;
97 }
98
99 // Import
100 result = ctx.getImportHandler().resolveClass(this.image);
101 if (result != null) {
102 return new ELClass((Class<?>) result);
103 }
104 result = ctx.getImportHandler().resolveStatic(this.image);
105 if (result != null) {
106 try {
107 return ((Class<?>) result).getField(this.image).get(null);
108 } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
109 throw new ELException(e);
110 }
111 }
112
113 throw new PropertyNotFoundException(MessageFactory.get("error.resolver.unhandled.null", this.image));
114 }

Callers

nothing calls this directly

Calls 15

resolveVariableMethod · 0.95
getValueMethod · 0.95
getMethod · 0.95
resolveStaticMethod · 0.80
getValueMethod · 0.65
getMethod · 0.65
isLambdaArgumentMethod · 0.45
getLambdaArgumentMethod · 0.45
getVariableMapperMethod · 0.45
getELContextMethod · 0.45
setPropertyResolvedMethod · 0.45
putContextMethod · 0.45

Tested by

no test coverage detected