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

Method getTarget

java/org/apache/el/parser/AstValue.java:63–121  ·  view source on GitHub ↗
(EvaluationContext ctx)

Source from the content-addressed store, hash-verified

61 }
62
63 private Target getTarget(EvaluationContext ctx) throws ELException {
64 // evaluate expr-a to value-a
65 Object base = this.children[0].getValue(ctx);
66
67 // if our base is null (we know there are more properties to evaluate)
68 if (base == null) {
69 throw new PropertyNotFoundException(
70 MessageFactory.get("error.unreachable.base", this.children[0].getImage()));
71 }
72
73 // set up our start/end
74 Object property = null;
75 int propCount = this.jjtGetNumChildren();
76
77 int i = 1;
78 // Evaluate any properties or methods before our target
79 ELResolver resolver = ctx.getELResolver();
80 while (i < propCount) {
81 if (i + 2 < propCount && this.children[i + 1] instanceof AstMethodParameters) {
82 // Method call not at end of expression
83 base = resolver.invoke(ctx, base, this.children[i].getValue(ctx), null,
84 ((AstMethodParameters) this.children[i + 1]).getParameters(ctx));
85 i += 2;
86 } else if (i + 2 == propCount && this.children[i + 1] instanceof AstMethodParameters) {
87 // Method call at end of expression
88 ctx.setPropertyResolved(false);
89 property = this.children[i].getValue(ctx);
90 if (property == null) {
91 throw new PropertyNotFoundException(
92 MessageFactory.get("error.unreachable.property", this.children[i].getImage()));
93 }
94 i += 2;
95 } else if (i + 1 < propCount) {
96 // Object with property not at end of expression
97 property = this.children[i].getValue(ctx);
98 ctx.setPropertyResolved(false);
99 base = resolver.getValue(ctx, base, property);
100 i++;
101 } else {
102 // Object with property at end of expression
103 ctx.setPropertyResolved(false);
104 property = this.children[i].getValue(ctx);
105 if (property == null) {
106 throw new PropertyNotFoundException(
107 MessageFactory.get("error.unreachable.property", this.children[i].getImage()));
108 }
109 i++;
110 }
111 if (base == null) {
112 throw new PropertyNotFoundException(
113 MessageFactory.get("error.unreachable.property", this.children[propCount - 1].getImage()));
114 }
115 }
116
117 Target t = new Target();
118 t.base = base;
119 t.property = property;
120 return t;

Callers 7

getTypeMethod · 0.95
isReadOnlyMethod · 0.95
setValueMethod · 0.95
getMethodInfoMethod · 0.95
invokeMethod · 0.95
getMethodReferenceMethod · 0.95
getValueReferenceMethod · 0.95

Calls 9

getMethod · 0.95
invokeMethod · 0.95
getValueMethod · 0.95
getValueMethod · 0.65
getImageMethod · 0.65
jjtGetNumChildrenMethod · 0.65
getParametersMethod · 0.65
getELResolverMethod · 0.45
setPropertyResolvedMethod · 0.45

Tested by

no test coverage detected