dsto.dfc.databeans
Class JavaDataBean

java.lang.Object
  extended by dsto.dfc.databeans.AbstractDataObject
      extended by dsto.dfc.databeans.AbstractDataBean
          extended by dsto.dfc.databeans.DataBean
              extended by dsto.dfc.databeans.JavaDataBean
All Implemented Interfaces:
IDataBean, IDataObject, IDataObjectChildListener, PropertyChangeListener, Cloneable, EventListener

public class JavaDataBean
extends DataBean
implements PropertyChangeListener

Wraps a JavaBean as an IDataBean. The initial values of the JavaBean are considered to be the (transient) defaults until they are observed to change. New properties that do not overlap the set provided by the bean may be added as needed.

This class may either wrap an existing bean, or be subclassed. If this class is subclassed, it is vital that the subclass call initDataBean(Class) as the last thing in its constructor.

Version:
$Revision$
Author:
mpp

Field Summary
 
Fields inherited from class dsto.dfc.databeans.DataBean
alwaysTransient, transientProperties, typeInfo, values
 
Fields inherited from class dsto.dfc.databeans.AbstractDataObject
listeners
 
Fields inherited from interface dsto.dfc.databeans.IDataObject
OVERRIDE, PERSISTENT, PERSISTENT_OVERRIDE, TRANSIENT, TRANSIENT_OVERRIDE
 
Constructor Summary
JavaDataBean()
          Create a default instance.
JavaDataBean(Object bean)
          Constructor for JavaDataBean.
 
Method Summary
 Object getBean()
           
 Object getValue(Object name)
          Get the value of a given property.
protected  void initDataBean(Class beanClass)
          Subclasses must call this from their constructor after they have initialised their properties to finish initialisation of databean state.
 void propertyChange(PropertyChangeEvent e)
           
protected  Object readProperty(PropertyDescriptor property)
           
 void setBean(Object newBean)
           
 void setValue(Object name, Object value)
          Synonym for setValue (name, value, PERSISTENT_OVERRIDE).
 void setValue(String name, Object value, int mode)
           
 IDataObject shallowClone()
          Shallow clone the object prior to being recusively "deep" cloned.
protected  void writeProperty(PropertyDescriptor property, Object value)
           
 
Methods inherited from class dsto.dfc.databeans.DataBean
childPropertyChanged, getPropertyNames, getTypeInfo, isTransient, propertyIterator, setAlwaysTransient, setTypeInfo, setValue
 
Methods inherited from class dsto.dfc.databeans.AbstractDataBean
setValue, setValue, setValue, setValue, setValue, setValue, setValue
 
Methods inherited from class dsto.dfc.databeans.AbstractDataObject
addFirstPropertyListener, addPropertyListener, firePropertyChangedEvent, firePropertyChangedEvent, firePropertyChangedEvent, firePropertyChangedEvent, firePropertyChangedEvent, firePropertyChangedEvent, getBeanValue, getBooleanValue, getBooleanValue, getCharValue, getCharValue, getDoubleValue, getDoubleValue, getFloatValue, getFloatValue, getIntValue, getIntValue, getLongValue, getLongValue, getObjectValue, getPropertyListeners, getShortValue, getStringValue, registerValue, removePropertyListener, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, toString, unregisterValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface dsto.dfc.databeans.IDataBean
getBeanValue, getBooleanValue, getCharValue, getDoubleValue, getFloatValue, getIntValue, getLongValue, getObjectValue, getStringValue, setValue, setValue, setValue, setValue, setValue, setValue
 
Methods inherited from interface dsto.dfc.databeans.IDataObject
addPropertyListener, getPropertyListeners, removePropertyListener
 

Constructor Detail

JavaDataBean

public JavaDataBean()
             throws IllegalArgumentException
Create a default instance. Use setBean () to set the bean before use.

Throws:
IllegalArgumentException

JavaDataBean

public JavaDataBean(Object bean)
             throws IllegalArgumentException
Constructor for JavaDataBean.

Throws:
IllegalArgumentException
Method Detail

initDataBean

protected final void initDataBean(Class beanClass)
Subclasses must call this from their constructor after they have initialised their properties to finish initialisation of databean state.

Parameters:
beanClass - The class of the bean: must be the result of using JavaBean.class not getClass ().

shallowClone

public IDataObject shallowClone()
                         throws UnsupportedOperationException
Description copied from interface: IDataObject
Shallow clone the object prior to being recusively "deep" cloned. This should return a new instance of the same class as the object suitable for receiving a series of setValue () calls to add copied properties from the original. Only state that would not be copied by the copying of all properties needs to be cloned by this method.

NOTE: Clients should not need to call this method: use DataObjects.deepClone(IDataObject) instead.

Specified by:
shallowClone in interface IDataObject
Overrides:
shallowClone in class DataBean
Returns:
A new object of the same type, with the same values as the original.
Throws:
UnsupportedOperationException - if the object or child object could not be cloned.
See Also:
DataObjects.deepClone(IDataObject)

getBean

public Object getBean()

setBean

public void setBean(Object newBean)
             throws IllegalArgumentException
Throws:
IllegalArgumentException

getValue

public Object getValue(Object name)
Description copied from interface: IDataObject
Get the value of a given property.

Specified by:
getValue in interface IDataObject
Overrides:
getValue in class DataBean
Parameters:
name - The property "name" (may be any object).
Returns:
the value of a given property or null if the property is not defined.
See Also:
IDataObject.setValue(Object, Object), IDataObject.propertyIterator()

setValue

public void setValue(Object name,
                     Object value)
              throws IllegalArgumentException
Description copied from class: AbstractDataObject
Synonym for setValue (name, value, PERSISTENT_OVERRIDE).

Specified by:
setValue in interface IDataObject
Overrides:
setValue in class AbstractDataObject
Parameters:
name - The property "name" (may be any object).
value - The property value.
Throws:
IllegalArgumentException
See Also:
IDataObject.setValue(Object, Object, int), IDataObject.getValue(Object), PropertyListener, PropertyEvent

setValue

public void setValue(String name,
                     Object value,
                     int mode)

readProperty

protected Object readProperty(PropertyDescriptor property)
                       throws IllegalArgumentException
Throws:
IllegalArgumentException

writeProperty

protected void writeProperty(PropertyDescriptor property,
                             Object value)
                      throws IllegalArgumentException
Throws:
IllegalArgumentException

propertyChange

public void propertyChange(PropertyChangeEvent e)
Specified by:
propertyChange in interface PropertyChangeListener


Copyright © 2008 Commonwealth of Australia