1
1
/*
2
+ * Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation.
2
3
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
3
4
*
4
5
* This program and the accompanying materials are made available under the
38
39
import jakarta .el .MethodExpression ;
39
40
import jakarta .el .MethodInfo ;
40
41
import jakarta .el .MethodNotFoundException ;
42
+ import jakarta .el .MethodReference ;
41
43
import jakarta .el .PropertyNotFoundException ;
42
44
import jakarta .el .VariableMapper ;
43
45
77
79
public final class MethodExpressionImpl extends MethodExpression implements Externalizable {
78
80
79
81
private Class <?> expectedType ;
80
- private String expr ;
81
- private FunctionMapper fnMapper ;
82
- private VariableMapper varMapper ;
82
+ private String expression ;
83
+ private FunctionMapper functionMapper ;
84
+ private VariableMapper variableMapper ;
83
85
private Class <?>[] paramTypes ;
84
86
85
87
private transient Node node ;
@@ -98,10 +100,10 @@ public MethodExpressionImpl() {
98
100
*/
99
101
public MethodExpressionImpl (String expr , Node node , FunctionMapper fnMapper , VariableMapper varMapper , Class <?> expectedType , Class <?>[] paramTypes ) {
100
102
super ();
101
- this .expr = expr ;
103
+ this .expression = expr ;
102
104
this .node = node ;
103
- this .fnMapper = fnMapper ;
104
- this .varMapper = varMapper ;
105
+ this .functionMapper = fnMapper ;
106
+ this .variableMapper = varMapper ;
105
107
this .expectedType = expectedType ;
106
108
this .paramTypes = paramTypes ;
107
109
}
@@ -156,7 +158,7 @@ public boolean equals(Object obj) {
156
158
*/
157
159
@ Override
158
160
public String getExpressionString () {
159
- return expr ;
161
+ return expression ;
160
162
}
161
163
162
164
/**
@@ -176,7 +178,16 @@ public String getExpressionString() {
176
178
*/
177
179
@ Override
178
180
public MethodInfo getMethodInfo (ELContext context ) throws PropertyNotFoundException , MethodNotFoundException , ELException {
179
- return getNode ().getMethodInfo (new EvaluationContext (context , fnMapper , varMapper ), paramTypes );
181
+ return getNode ().getMethodInfo (new EvaluationContext (context , functionMapper , variableMapper ), paramTypes );
182
+ }
183
+
184
+ @ Override
185
+ public MethodReference getMethodReference (ELContext context ) {
186
+ EvaluationContext ctx = new EvaluationContext (context , functionMapper , variableMapper );
187
+ ctx .notifyBeforeEvaluation (getExpressionString ());
188
+ MethodReference methodReference = getNode ().getMethodReference (ctx );
189
+ ctx .notifyAfterEvaluation (getExpressionString ());
190
+ return methodReference ;
180
191
}
181
192
182
193
/**
@@ -185,7 +196,7 @@ public MethodInfo getMethodInfo(ELContext context) throws PropertyNotFoundExcept
185
196
*/
186
197
private Node getNode () throws ELException {
187
198
if (node == null ) {
188
- node = ExpressionBuilder .createNode (expr );
199
+ node = ExpressionBuilder .createNode (expression );
189
200
}
190
201
191
202
return node ;
@@ -231,12 +242,12 @@ public int hashCode() {
231
242
*/
232
243
@ Override
233
244
public Object invoke (ELContext context , Object [] params ) throws PropertyNotFoundException , MethodNotFoundException , ELException {
234
- EvaluationContext ctx = new EvaluationContext (context , fnMapper , varMapper );
235
- ctx .notifyBeforeEvaluation (expr );
245
+ EvaluationContext ctx = new EvaluationContext (context , functionMapper , variableMapper );
246
+ ctx .notifyBeforeEvaluation (expression );
236
247
237
248
Object obj = getNode ().invoke (ctx , paramTypes , params );
238
249
239
- ctx .notifyAfterEvaluation (expr );
250
+ ctx .notifyAfterEvaluation (expression );
240
251
return obj ;
241
252
}
242
253
@@ -247,30 +258,25 @@ public Object invoke(ELContext context, Object[] params) throws PropertyNotFound
247
258
*/
248
259
@ Override
249
260
public void readExternal (ObjectInput in ) throws IOException , ClassNotFoundException {
250
- expr = in .readUTF ();
261
+ expression = in .readUTF ();
251
262
String type = in .readUTF ();
252
263
253
264
if (!"" .equals (type )) {
254
265
expectedType = forName (type );
255
266
}
256
267
257
268
paramTypes = toTypeArray (((String []) in .readObject ()));
258
- fnMapper = (FunctionMapper ) in .readObject ();
259
- varMapper = (VariableMapper ) in .readObject ();
269
+ functionMapper = (FunctionMapper ) in .readObject ();
270
+ variableMapper = (VariableMapper ) in .readObject ();
260
271
}
261
272
262
- /*
263
- * (non-Javadoc)
264
- *
265
- * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
266
- */
267
273
@ Override
268
274
public void writeExternal (ObjectOutput out ) throws IOException {
269
- out .writeUTF (expr );
275
+ out .writeUTF (expression );
270
276
out .writeUTF (expectedType != null ? expectedType .getName () : "" );
271
277
out .writeObject (toTypeNameArray (paramTypes ));
272
- out .writeObject (fnMapper );
273
- out .writeObject (varMapper );
278
+ out .writeObject (functionMapper );
279
+ out .writeObject (variableMapper );
274
280
}
275
281
276
282
@ Override
0 commit comments