dsto.dfc.databeans
Class AbstractDataObject

java.lang.Object
  extended by dsto.dfc.databeans.AbstractDataObject
All Implemented Interfaces:
IDataObject, IDataObjectChildListener, Cloneable
Direct Known Subclasses:
AbstractDataBean, DataObject, DataObjectLink, DataObjectView, SimpleDataObject

public abstract class AbstractDataObject
extends Object
implements IDataObject, IDataObjectChildListener, Cloneable

Abstract base class for IDataObject's. Provides event listener support and support for listening to child objects and re-firing property changes.

NOTE: this class implements java.lang.Cloneable only in order to be able to invoke clone () internally - the clone () method is left protected. Use DataObjects.deepClone(IDataObject) to clone a tree of objects.

Version:
$Revision$
Author:
mpp

Field Summary
protected  EventListenerList listeners
           
 
Fields inherited from interface dsto.dfc.databeans.IDataObject
OVERRIDE, PERSISTENT, PERSISTENT_OVERRIDE, TRANSIENT, TRANSIENT_OVERRIDE
 
Constructor Summary
AbstractDataObject()
           
 
Method Summary
 void addFirstPropertyListener(PropertyListener l)
          Add listener to the front of the list, so it will get events before all other current listeners.
 void addPropertyListener(PropertyListener l)
          Add a listener that will be notified when changes to the properties on this or child objects are made.
 void childPropertyChanged(Object childProperty, PropertyEvent e)
          Invoked when a child property value has changed.
 void firePropertyChangedEvent(Object property, boolean newValue, boolean isTransient)
          Shortcut to fire property changed event when a boolean value has definitely changed.
 void firePropertyChangedEvent(Object property, boolean oldValue, boolean newValue, boolean isTransient)
           
 void firePropertyChangedEvent(Object property, int oldValue, int newValue, boolean isTransient)
           
 void firePropertyChangedEvent(Object property, Object oldValue, Object newValue, boolean isTransient)
           
 void firePropertyChangedEvent(Object property, PropertyPath basePath, Object oldValue, Object newValue, boolean isTransient)
           
 void firePropertyChangedEvent(PropertyPath path, Object oldValue, Object newValue, boolean isTransient)
           
 IDataBean getBeanValue(String name)
           
 boolean getBooleanValue(Object name)
           
 boolean getBooleanValue(String name)
           
 char getCharValue(Object name)
           
 char getCharValue(String name)
           
 double getDoubleValue(Object name)
           
 double getDoubleValue(String name)
           
 float getFloatValue(Object name)
           
 float getFloatValue(String name)
           
 int getIntValue(Object name)
           
 int getIntValue(String name)
           
 long getLongValue(Object name)
           
 long getLongValue(String name)
           
 IDataObject getObjectValue(String name)
           
 Collection getPropertyListeners()
          Return a non-modifiable list of registered property listeners.
 short getShortValue(String name)
           
 String getStringValue(String name)
           
abstract  TypeInfo getTypeInfo()
          Get the optional type information for this object.
protected  void registerValue(Object property, Object value)
          Register a child value of this object.
 void removePropertyListener(PropertyListener l)
          Reverse the effect of IDataObject.addPropertyListener(PropertyListener).
 void setValue(Object name, boolean value)
           
 void setValue(Object name, char value)
           
 void setValue(Object name, double value)
           
 void setValue(Object name, float value)
           
 void setValue(Object name, int value)
           
 void setValue(Object name, long value)
           
 void setValue(Object name, Object value)
          Synonym for setValue (name, value, PERSISTENT_OVERRIDE).
abstract  void setValue(Object name, Object value, int mode)
          Set the value of a given property.
 void setValue(String name, boolean value)
           
 void setValue(String name, char value)
           
 void setValue(String name, double value)
           
 void setValue(String name, float value)
           
 void setValue(String name, int value)
           
 void setValue(String name, long value)
           
 void setValue(String name, short value)
           
 IDataObject shallowClone()
          Shallow clone the object prior to being recusively "deep" cloned.
 String toString()
          Generates a human-readable rendering of the object's properties.
protected  void unregisterValue(Object value)
          Undo the effect of registerValue(Object, Object).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface dsto.dfc.databeans.IDataObject
getValue, isTransient, propertyIterator
 

Field Detail

listeners

protected EventListenerList listeners
Constructor Detail

AbstractDataObject

public AbstractDataObject()
Method Detail

shallowClone

public IDataObject shallowClone()
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
Returns:
A new object of the same type, with the same values as the original.
See Also:
DataObjects.deepClone(IDataObject)

getTypeInfo

public abstract TypeInfo getTypeInfo()
Description copied from interface: IDataObject
Get the optional type information for this object. If the object has none, this will be null.

Specified by:
getTypeInfo in interface IDataObject
See Also:
TypeRegistry

setValue

public void setValue(Object name,
                     Object value)
Synonym for setValue (name, value, PERSISTENT_OVERRIDE).

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

setValue

public abstract void setValue(Object name,
                              Object value,
                              int mode)
Description copied from interface: IDataObject
Set the value of a given property. If the object supports it, a property change event should be emitted.

Specified by:
setValue in interface IDataObject
Parameters:
name - A property name.
value - The new value. On most objects using null removes the property.
mode - The mode for the value. This is a bitwise OR of TRANSIENT and/or OVERRIDE. Using TRANSIENT specifies the value is to be marked transient (ie isTransient (name) will return true). Not all data object implementations support dynamic transience. OVERRIDE must be set if an existing value is to be overwritten: if not set and a value is already defined, then nothing is changed. The IDataObject.setValue (name, value) call corresponds to IDataBean.setValue (name, value, OVERRIDE).
See Also:
IDataObject.setValue(Object, Object)

setValue

public void setValue(Object name,
                     boolean value)

getBooleanValue

public boolean getBooleanValue(Object name)

setValue

public void setValue(Object name,
                     int value)

getIntValue

public int getIntValue(Object name)

setValue

public void setValue(Object name,
                     long value)

getLongValue

public long getLongValue(Object name)

setValue

public void setValue(Object name,
                     float value)

getFloatValue

public float getFloatValue(Object name)

setValue

public void setValue(Object name,
                     double value)

getDoubleValue

public double getDoubleValue(Object name)

setValue

public void setValue(Object name,
                     char value)

getCharValue

public char getCharValue(Object name)

setValue

public void setValue(String name,
                     boolean value)

getBooleanValue

public boolean getBooleanValue(String name)

setValue

public void setValue(String name,
                     short value)

getShortValue

public short getShortValue(String name)

setValue

public void setValue(String name,
                     int value)

getIntValue

public int getIntValue(String name)

setValue

public void setValue(String name,
                     long value)

getLongValue

public long getLongValue(String name)

setValue

public void setValue(String name,
                     float value)

getFloatValue

public float getFloatValue(String name)

setValue

public void setValue(String name,
                     double value)

getDoubleValue

public double getDoubleValue(String name)

setValue

public void setValue(String name,
                     char value)

getCharValue

public char getCharValue(String name)

getBeanValue

public IDataBean getBeanValue(String name)

getObjectValue

public IDataObject getObjectValue(String name)

addPropertyListener

public void addPropertyListener(PropertyListener l)
Description copied from interface: IDataObject
Add a listener that will be notified when changes to the properties on this or child objects are made.

Specified by:
addPropertyListener in interface IDataObject
See Also:
IDataObject.removePropertyListener(PropertyListener), IDataObject.getPropertyListeners()

addFirstPropertyListener

public void addFirstPropertyListener(PropertyListener l)
Add listener to the front of the list, so it will get events before all other current listeners. Since depending on listener order is usually a dodgy practice (and someone else could always use this call), use at your own risk.


removePropertyListener

public void removePropertyListener(PropertyListener l)
Description copied from interface: IDataObject
Reverse the effect of IDataObject.addPropertyListener(PropertyListener).

Specified by:
removePropertyListener in interface IDataObject

getPropertyListeners

public Collection getPropertyListeners()
Description copied from interface: IDataObject
Return a non-modifiable list of registered property listeners.

Specified by:
getPropertyListeners in interface IDataObject
See Also:
IDataObject.addPropertyListener(PropertyListener)

registerValue

protected void registerValue(Object property,
                             Object value)
Register a child value of this object. The child value will be monitored for property changes if it is an IDataObject and childPropertyChanged(Object, PropertyEvent) called whenever it changes.

Parameters:
property - The name of the child.
value - The child value.
See Also:
DataObjects.registerChildValue(IDataObjectChildListener, Object, Object), unregisterValue(Object)

unregisterValue

protected void unregisterValue(Object value)
Undo the effect of registerValue(Object, Object).

See Also:
DataObjects.unregisterChildValue(IDataObjectChildListener, Object)

childPropertyChanged

public void childPropertyChanged(Object childProperty,
                                 PropertyEvent e)
Invoked when a child property value has changed.

Specified by:
childPropertyChanged in interface IDataObjectChildListener
Parameters:
childProperty - The property name on this object that the child is accessible by.
e - The change event from the child.
See Also:
registerValue(Object, Object)

firePropertyChangedEvent

public void firePropertyChangedEvent(Object property,
                                     PropertyPath basePath,
                                     Object oldValue,
                                     Object newValue,
                                     boolean isTransient)

firePropertyChangedEvent

public void firePropertyChangedEvent(Object property,
                                     Object oldValue,
                                     Object newValue,
                                     boolean isTransient)

firePropertyChangedEvent

public void firePropertyChangedEvent(PropertyPath path,
                                     Object oldValue,
                                     Object newValue,
                                     boolean isTransient)

firePropertyChangedEvent

public void firePropertyChangedEvent(Object property,
                                     boolean newValue,
                                     boolean isTransient)
Shortcut to fire property changed event when a boolean value has definitely changed.


firePropertyChangedEvent

public void firePropertyChangedEvent(Object property,
                                     boolean oldValue,
                                     boolean newValue,
                                     boolean isTransient)

firePropertyChangedEvent

public void firePropertyChangedEvent(Object property,
                                     int oldValue,
                                     int newValue,
                                     boolean isTransient)

toString

public String toString()
Generates a human-readable rendering of the object's properties.

Overrides:
toString in class Object

getStringValue

public String getStringValue(String name)


Copyright © 2008 Commonwealth of Australia