Expression that refers to a method on an object.
The ExpressionFactory#createMethodExpression method can be used to parse an expression string and return a
concrete instance of MethodExpression that encapsulates the parsed expression. The
FunctionMapper is used at parse time, not evaluation time, so one is not needed to evaluate an expression
using this class. However, the ELContext is needed at evaluation time.
The getMethodInfo and invoke methods will evaluate the expression each time they are called. The
ELResolver in the ELContext is used to resolve the top-level variables and to determine the
behavior of the . and [] operators. For any of the two methods, the
ELResolver#getValue method is used to resolve all properties up to but excluding the last one. This provides
the base object on which the method appears. If the base object is null, a
NullPointerException must be thrown. At the last resolution, the final property is then
coerced to a String, which provides the name of the method to be found. A method matching the name and
expected parameters provided at parse time is found and it is either queried or invoked (depending on the method
called on this MethodExpression).
See the notes about comparison, serialization and immutability in the Expression javadocs.
javax.el.ELResolver , javax.el.Expression , javax.el.ExpressionFactory , javax.el.MethodExpression
| Modifier and Type | Field and Description |
|---|---|
| private Class | |
| private String | |
| private FunctionMapper | |
| private transient Node | |
| private Class | |
| private VariableMapper |
| Access | Constructor and Description |
|---|---|
| public | |
| public | MethodExpressionImpl(String
the expression expr, Node the node node, FunctionMapper the function mapper fnMapper, VariableMapper the variable mapper varMapper, Class<?> expected return type of method expectedType, Class<?>[] the method parameters paramTypes)
|
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if obj equals this Expression; false otherwise.the obj)Object to test for equality.Implements abstract javax. Expression.
|
| public String | Returns: The original expression String.Implements abstract javax. Expression, unmodified.
|
| public MethodInfo | Returns: an instance ofMethodInfo containing information about the method the expression evaluated to.The context of this evaluation context)Implements abstract javax. |
| private Node | |
| public int | Returns: The hash code for thisExpression.Implements abstract javax. Expression.
|
| public Object | Returns: the result of the method invocation (null if the method has a void return type).The context of this evaluation. context, Object[] The parameters to pass to the method, or params)null if no parameters.Implements abstract javax. |
| public boolean | isLiteralText()
Implements abstract javax. |
| public boolean | isParametersProvided()
Return whether this MethodExpression was created with parameters.
|
| public void | readExternal(ObjectInput
the stream to read data from in order to restore the object in)Implements java. |
| public void | writeExternal(ObjectOutput
the stream to write the object to out)Implements java. |
| expectedType | back to summary |
|---|---|
| private Class<?> expectedType | |
| expr | back to summary |
|---|---|
| private String expr | |
| fnMapper | back to summary |
|---|---|
| private FunctionMapper fnMapper | |
| node | back to summary |
|---|---|
| private transient Node node | |
| paramTypes | back to summary |
|---|---|
| private Class<?>[] paramTypes | |
| varMapper | back to summary |
|---|---|
| private VariableMapper varMapper | |
| MethodExpressionImpl | back to summary |
|---|---|
| public MethodExpressionImpl() | |
| MethodExpressionImpl | back to summary |
|---|---|
public MethodExpressionImpl(String expr, Node node, FunctionMapper fnMapper, VariableMapper varMapper, Class<?> expectedType, Class<?>[] paramTypes)
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Implements abstract javax. Determines whether the specified object is equal to this
The result is
Note that two expressions can be equal if their expression Strings are different. For example,
| |
| getExpressionString | back to summary |
|---|---|
| public String getExpressionString() Implements abstract javax. Returns the original String used to create this This is used for debugging purposes but also for the purposes of comparison (e.g. to ensure the expression in a configuration file has not changed).
This method does not provide sufficient information to re-create an expression. Two different expressions can have
exactly the same expression string but different function mappings. Serialization should be used to save and restore
the state of an
| |
| getMethodInfo | back to summary |
|---|---|
| public MethodInfo getMethodInfo(ELContext context) throws PropertyNotFoundException, MethodNotFoundException, ELException Implements abstract javax. Evaluates the expression relative to the provided context, and returns information about the actual referenced method.
| |
| getNode | back to summary |
|---|---|
private Node getNode() throws ELException
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Implements abstract javax. Returns the hash code for this
See the note in the
| |
| invoke | back to summary |
|---|---|
| public Object invoke(ELContext context, Object[] params) throws PropertyNotFoundException, MethodNotFoundException, ELException Implements abstract javax. Evaluates the expression relative to the provided context, invokes the method that was found using the supplied parameters, and returns the result of the method invocation.
| |
| isLiteralText | back to summary |
|---|---|
| public boolean isLiteralText() Implements abstract javax. Doc from javax. Returns whether this expression was created from only literal text. This method must return
| |
| isParametersProvided | back to summary |
|---|---|
| public boolean isParametersProvided() Overrides javax. Doc from javax. Return whether this MethodExpression was created with parameters. This method must return
| |
| readExternal | back to summary |
|---|---|
| public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException Implements java. Doc from java. The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.
| |
| writeExternal | back to summary |
|---|---|
| public void writeExternal(ObjectOutput out) throws IOException Implements java. Doc from java. The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.
| |