public class

MethodExpression

extends Object
implements Expression
java.lang.Object
   ↳ org.apache.commons.betwixt.expression.MethodExpression

Class Overview

MethodExpression evaluates a method on the current bean context.

Summary

Fields
protected static Object[] NULL_ARGUMENTS null arguments
protected static Class[] NULL_CLASSES null classes
Public Constructors
MethodExpression()
Base constructor
MethodExpression(Method method)
Convenience constructor sets method property
Public Methods
Object evaluate(Context context)
Evaluate by calling the read method on the current bean
Method getMethod()
Gets the method used to evaluate this expression.
void setMethod(Method method)
Sets the method used to evaluate this expression
String toString()
Returns something useful for logging.
void update(Context context, String newValue)
Do nothing.
Protected Methods
Method findAlternateMethod(Class type, Method method)
Tries to find an alternate method for the given type using interfaces which gets around the problem of inner classes, such as on Map.Entry implementations.
Object[] getArguments()
Allows derived objects to create arguments for the method call
void handleException(Context context, Exception e)

Log error to context's logger.

void handleException(Context context, Exception e, Method m)

Log error to context's logger.

[Expand]
Inherited Methods
From class java.lang.Object
From interface org.apache.commons.betwixt.expression.Expression

Fields

protected static Object[] NULL_ARGUMENTS

null arguments

protected static Class[] NULL_CLASSES

null classes

Public Constructors

public MethodExpression ()

Base constructor

public MethodExpression (Method method)

Convenience constructor sets method property

Parameters
method the Method whose return value when invoked on the bean will the value of this expression

Public Methods

public Object evaluate (Context context)

Evaluate by calling the read method on the current bean

Parameters
context the context against which this expression will be evaluated
Returns
  • the value returned by the method when it's invoked on the context's bean, so long as the method can be invoked. Otherwise, null.

public Method getMethod ()

Gets the method used to evaluate this expression.

Returns
  • the method whose value (when invoked against the context's bean) will be used to evaluate this expression.

public void setMethod (Method method)

Sets the method used to evaluate this expression

Parameters
method method whose value (when invoked against the context's bean) will be used to evaluate this expression

public String toString ()

Returns something useful for logging.

Returns
  • something useful for logging

public void update (Context context, String newValue)

Do nothing.

Parameters
context update this Context
newValue the new value for this expression
See Also

Protected Methods

protected Method findAlternateMethod (Class type, Method method)

Tries to find an alternate method for the given type using interfaces which gets around the problem of inner classes, such as on Map.Entry implementations.

Parameters
type the Class whose methods are to be searched
method the Method for which an alternative is to be search for
Returns
  • the alternative Method, if one can be found. Otherwise null.

protected Object[] getArguments ()

Allows derived objects to create arguments for the method call

Returns

protected void handleException (Context context, Exception e)

Log error to context's logger.

Allows derived objects to handle exceptions differently.

Parameters
context the Context being evaluated when the exception occured
e the exception to handle

protected void handleException (Context context, Exception e, Method m)

Log error to context's logger.

Allows derived objects to handle exceptions differently.

Parameters
context the Context being evaluated when the exception occured
e the exception to handle