SPT Core API

com.sptci.echo.binding
Class Updater<V,M>

java.lang.Object
  extended by com.sptci.echo.binding.Updater<V,M>
Type Parameters:
V - The class name of the view component.
M - The class name of the model component.
Direct Known Subclasses:
ModelUpdater, ViewUpdater

public abstract class Updater<V,M>
extends Object

An abstract updater used to update UI containers or JavaBean objects from one another.

Copyright 2006 Sans Pareil Technologies, Inc.

Version:
$Id: Updater.java 4856 2009-08-11 15:22:46Z rakesh $
Author:
Rakesh Vidyadharan 2006-02-07

Field Summary
protected  M bean
          The java bean that contains the data to use to update the view.
protected static Logger logger
          The logger used to log errors/warnings to.
protected  V view
          The UI container that is to be updated.
 
Constructor Summary
protected Updater()
          Default constructor.
protected Updater(V view, M bean)
          Create a new instance with the specified UI container and java bean.
 
Method Summary
protected  Map<String,Object> beanValues()
          Fetch the values of all the fields in bean that have an accessor method conforming to JavaBean naming convention.
 M getBean()
          Returns bean.
 V getView()
          Returns view.
 void setBean(M bean)
          Set bean.
 void setView(V view)
          Set view.
abstract  void update()
          Update the fields of the desired component with the data contained in similarly named fields in the other component.
protected  Map<String,Object> viewValues()
          Fetch the values of all the fields in view.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final Logger logger
The logger used to log errors/warnings to.


view

protected V view
The UI container that is to be updated.


bean

protected M bean
The java bean that contains the data to use to update the view.

Constructor Detail

Updater

protected Updater()
Default constructor. Cannot be instantiated.


Updater

protected Updater(V view,
                  M bean)
Create a new instance with the specified UI container and java bean.

Parameters:
view - The view to use.
bean - The bean to use.
Method Detail

beanValues

protected Map<String,Object> beanValues()
                                 throws IllegalAccessException,
                                        InvocationTargetException,
                                        IntrospectionException
Fetch the values of all the fields in bean that have an accessor method conforming to JavaBean naming convention.

Returns:
Map A map with the field name as key and the field value as value.
Throws:
IllegalAccessException - If a custom security policy restricts access to the bean fields.
InvocationTargetException - If the accessor method for the field could not be invoked successfully.
IntrospectionException - If errors are encountered while introspecing the bean for accessors.
See Also:
ReflectionUtility.fetchFields(java.lang.Object), ReflectionUtility.fetchMethod( Object, String, Class[] )

viewValues

protected Map<String,Object> viewValues()
                                 throws IllegalAccessException,
                                        InvocationTargetException
Fetch the values of all the fields in view. Convert the values of the UI components to the mapping scheme used in bean generation.

Returns:
Map A map with the field name as key and the field value as value.
Throws:
IllegalAccessException - If a custom security policy restricts access to the bean fields.
InvocationTargetException - If the accessor method for the field could not be invoked successfully.
See Also:
Utility#getViewValue(Object), ReflectionUtility.fetchFields(java.lang.Object), ReflectionUtility.fetchMethod( Object, String, Class[] )

update

public abstract void update()
Update the fields of the desired component with the data contained in similarly named fields in the other component.


getView

public final V getView()
Returns view.

Returns:
The value/reference of/to view.

setView

public final void setView(V view)
Set view.

Parameters:
view - The value to set.

getBean

public final M getBean()
Returns bean.

Returns:
The value/reference of/to bean.

setBean

public final void setBean(M bean)
Set bean.

Parameters:
bean - The value to set.

SPT Core API