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:
Apache Commons Team, Apache Software Foundation

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
 

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


Copyright © 2002-2008 The Apache Software Foundation. All Rights Reserved.