dsto.dfc.databeans
Class FancyDataObject

java.lang.Object
  extended by dsto.dfc.databeans.AbstractDataObject
      extended by dsto.dfc.databeans.SimpleDataObject
          extended by dsto.dfc.databeans.FancyDataObject
All Implemented Interfaces:
IDataObject, IDataObjectChildListener, Cloneable
Direct Known Subclasses:
Entity, EntityList, TypeInfo

public class FancyDataObject
extends SimpleDataObject

Extends SimpleDataObject to allow properties to be added dynamically to the fixed base set supported by the class. If a property that is not a field of the object is set, then the property is added dynamically.

Note: this class has been designed add little extra cost for normal property accesses, so it can be cheaply used in place of SimpleDataObject wherever extended properties might be needed, even if they're not currently required.

Author:
Matthew Phillips

Field Summary
 
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
FancyDataObject()
           
 
Method Summary
 void childPropertyChanged(Object childProperty, PropertyEvent e)
          Invoked when a child property value has changed.
 Object getValue(Object name)
          Get the value of a given property.
 boolean isTransient(Object name)
          Test a property is transient (ie will not be preserved if the object is saved).
 Iterator propertyIterator()
          Get an iterator that scans over all currently defined properties.
 void setValue(Object name, Object value, int mode)
          Set the value of a given property.
 IDataObject shallowClone()
          Shallow clone the object prior to being recusively "deep" cloned.
 
Methods inherited from class dsto.dfc.databeans.SimpleDataObject
getFieldNames, getTypeInfo, 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
 

Constructor Detail

FancyDataObject

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

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 SimpleDataObject
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,
                     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
Overrides:
setValue in class SimpleDataObject
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)

propertyIterator

public Iterator propertyIterator()
Description copied from interface: IDataObject
Get an iterator that scans over all currently defined properties.

Specified by:
propertyIterator in interface IDataObject
Overrides:
propertyIterator in class SimpleDataObject
Returns:
An iterator that yields all defined property values (ie that would get a non-null result from IDataObject.getValue(Object)).
See Also:
IDataObject.getValue(Object), PropertyValueIterator

isTransient

public boolean isTransient(Object name)
Description copied from interface: IDataObject
Test a property is transient (ie will not be preserved if the object is saved).

Specified by:
isTransient in interface IDataObject
Overrides:
isTransient in class SimpleDataObject
Parameters:
name - The property name.
Returns:
boolean True if the property is transient.

childPropertyChanged

public void childPropertyChanged(Object childProperty,
                                 PropertyEvent e)
Description copied from class: AbstractDataObject
Invoked when a child property value has changed.

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


Copyright © 2008 Commonwealth of Australia