Class ExpressionInspector
- java.lang.Object
-
- org.omnifaces.el.ExpressionInspector
-
public final class ExpressionInspector extends Object
This class contains methods that inspect expressions to reveal information about them.
Examples
Determine the bean instance and the property value behind a
ValueExpression
.ValueExpression valueExpression = component.getValueExpression("value"); ValueReference valueReference = ExpressionInspector.getValueReference(context.getELContext(), valueExpression); Object bean = methodReference.getBase(); Object property = methodReference.getProperty();
Determine the bean instance and the concrete getter
Method
behind aValueExpression
.ValueExpression valueExpression = component.getValueExpression("value"); MethodReference methodReference = ExpressionInspector.getMethodReference(context.getELContext(), valueExpression); Object bean = methodReference.getBase(); Method method = methodReference.getMethod();
Determine the bean instance and the concrete action
Method
behind aMethodExpression
.MethodExpression methodExpression = commandComponent.getActionExpression(); MethodReference methodReference = ExpressionInspector.getMethodReference(context.getELContext(), methodExpression); Object bean = methodReference.getBase(); Method method = methodReference.getMethod();
- Since:
- 1.4
- Author:
- Arjan Tijms
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static MethodReference
getMethodReference(ELContext context, MethodExpression methodExpression)
Gets a MethodReference from a MethodExpression.static MethodReference
getMethodReference(ELContext context, ValueExpression valueExpression)
Gets a MethodReference from a ValueExpression.static ValueReference
getValueReference(ELContext context, ValueExpression valueExpression)
Gets the ValueReference from a ValueExpression, without any checks whether the property is actually a property or if it isn't a "MethodSuffix".
-
-
-
Method Detail
-
getValueReference
public static ValueReference getValueReference(ELContext context, ValueExpression valueExpression)
Gets the ValueReference from a ValueExpression, without any checks whether the property is actually a property or if it isn't a "MethodSuffix". The property is stored as it appears in the expression, and may thus not actually exists. It's up to the caller how to interpret this.- Parameters:
context
- the context of this evaluationvalueExpression
- the value expression being evaluated- Returns:
- a ValueReference holding the final base and property where the value expression evaluated to.
-
getMethodReference
public static MethodReference getMethodReference(ELContext context, ValueExpression valueExpression)
Gets a MethodReference from a ValueExpression. If the ValueExpression refers to a method, this will contain the actual method. If it refers to a property, this will contain the corresponding getter method.Note that in case the expression refers to a method, the method reference contains the method with the name the expression refers to, with a matching number of arguments and a match of types. Overloads with the same amount of parameters are supported, but if the actual arguments match with the types of multiple overloads (e.g. actual argument Long, overloads for Number and Long) a random method will be chosen.
- Parameters:
context
- the context of this evaluationvalueExpression
- the value expression being evaluated- Returns:
- a MethodReference holding the final base and Method where the value expression evaluated to.
-
getMethodReference
public static MethodReference getMethodReference(ELContext context, MethodExpression methodExpression)
Gets a MethodReference from a MethodExpression.- Parameters:
context
- the context of this evaluationmethodExpression
- the method expression being evaluated- Returns:
- a MethodReference holding the final base and Method where the method expression evaluated to.
- Since:
- 2.5
-
-