org.apache.commons.betwixt.expression
Class MethodUpdater

java.lang.Object
  extended by org.apache.commons.betwixt.expression.MethodUpdater
All Implemented Interfaces:
Updater

public class MethodUpdater
extends Object
implements Updater

MethodUpdater updates the current bean context by calling a WriteMethod with the String value from the XML attribute or element.

Version:
$Revision: 1.7 $
Author:
James Strachan

Field Summary
private static Log log
          Logger
private  Method method
          The method to call on the bean
private  Class valueType
          The type of the first parameter of the method
 
Constructor Summary
MethodUpdater()
          Base constructor
MethodUpdater(Method method)
          Convenience constructor sets method property
 
Method Summary
 Method getMethod()
          Gets the method which will be invoked by the update
protected  void handleException(Context context, Exception e)
          Strategy method to allow derivations to handle exceptions differently.
static void setLog(Log aLog)
          Programmatically set log
 void setMethod(Method method)
          Sets the constant value of this expression
 String toString()
          Returns something useful for logging.
 void update(Context context, Object newValue)
          Updates the current bean context with the given String value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private static Log log
Logger


method

private Method method
The method to call on the bean


valueType

private Class valueType
The type of the first parameter of the method

Constructor Detail

MethodUpdater

public MethodUpdater()
Base constructor


MethodUpdater

public MethodUpdater(Method method)
Convenience constructor sets method property

Parameters:
method - the Method to be invoked on the context's bean in the update
Method Detail

setLog

public static void setLog(Log aLog)
Programmatically set log

Parameters:
aLog - the implementation to which this class should log

update

public void update(Context context,
                   Object newValue)
Updates the current bean context with the given String value

Specified by:
update in interface Updater
Parameters:
context - the Context to be updated
newValue - the update to this new value

getMethod

public Method getMethod()
Gets the method which will be invoked by the update

Returns:
the Method to be invoked by the update

setMethod

public void setMethod(Method method)
Sets the constant value of this expression

Parameters:
method - the Method to be invoked by the update

handleException

protected void handleException(Context context,
                               Exception e)
Strategy method to allow derivations to handle exceptions differently.

Parameters:
context - the Context being updated when this exception occured
e - the Exception that occured during the update

toString

public String toString()
Returns something useful for logging.

Overrides:
toString in class Object
Returns:
something useful for logging