org.apache.commons.betwixt.expression
Class TypedUpdater

java.lang.Object
  extended by org.apache.commons.betwixt.expression.TypedUpdater
All Implemented Interfaces:
Updater
Direct Known Subclasses:
DynaBeanUpdater, MethodUpdater

public abstract class TypedUpdater
extends java.lang.Object
implements Updater

Abstracts common features for strongly typed Updater's. Strongly type Updater's perform conversions based on this the expected type before the bean update is invoked.

Since:
0.7
Author:
Jakarta Commons Team, Apache Software Foundation

Field Summary
private static org.apache.commons.logging.Log log
          Logger
private  java.lang.Class valueType
          The type of the first parameter of the method
 
Constructor Summary
TypedUpdater()
           
 
Method Summary
protected abstract  void executeUpdate(Context context, java.lang.Object bean, java.lang.Object value)
          Updates the bean with the given value.
 java.lang.Class getValueType()
          Gets the type expected.
protected  void handleException(Context context, java.lang.Exception e)
          Strategy method to allow derivations to handle exceptions differently.
 void setValueType(java.lang.Class valueType)
          Sets the type expected.
 void update(Context context, java.lang.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, toString, wait, wait, wait
 

Field Detail

log

private static final org.apache.commons.logging.Log log
Logger


valueType

private java.lang.Class valueType
The type of the first parameter of the method

Constructor Detail

TypedUpdater

public TypedUpdater()
Method Detail

update

public void update(Context context,
                   java.lang.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

getValueType

public java.lang.Class getValueType()
Gets the type expected. The value passed into update(org.apache.commons.betwixt.expression.Context, java.lang.Object) will be converted on the basis of this type before being passed to executeUpdate(org.apache.commons.betwixt.expression.Context, java.lang.Object, java.lang.Object).

Returns:
Class giving expected type, not null

setValueType

public void setValueType(java.lang.Class valueType)
Sets the type expected. The value passed into update(org.apache.commons.betwixt.expression.Context, java.lang.Object) will be converted on the basis of this type before being passed to executeUpdate(org.apache.commons.betwixt.expression.Context, java.lang.Object, java.lang.Object).

Parameters:
valueType - Class giving expected type, not null

executeUpdate

protected abstract void executeUpdate(Context context,
                                      java.lang.Object bean,
                                      java.lang.Object value)
                               throws java.lang.Exception
Updates the bean with the given value.

Parameters:
bean -
value - value after type conversion
Throws:
java.lang.Exception

handleException

protected void handleException(Context context,
                               java.lang.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