dsto.dfc.databeans
Class DataObject

java.lang.Object
  extended by dsto.dfc.databeans.AbstractDataObject
      extended by dsto.dfc.databeans.DataObject
All Implemented Interfaces:
IDataObject, IDataObjectChildListener, Serializable, Cloneable
Direct Known Subclasses:
EntityRegistry, Registry, SubsetDataObject, SupersetDataObject

public class DataObject
extends AbstractDataObject
implements Serializable

A default implemention of IDataObject based on a java.util.Map. This may be used as is or extended.

Author:
Matthew Phillips
See Also:
Serialized Form

Field Summary
protected  Map<Object,Object> propertyToValue
          Maps from property names to values.
protected  TypeInfo typeInfo
           
 
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
DataObject()
           
DataObject(TypeInfo type)
          Create an instance with a specified type.
 
Method Summary
 TypeInfo getTypeInfo()
          Get the optional type information for this object.
 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 iterator()
          Create an iterator over all the values in the object.
 Iterator propertyIterator()
          Get an iterator that scans over all currently defined properties.
 void setTypeInfo(TypeInfo typeInfo)
           
 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.AbstractDataObject
addFirstPropertyListener, addPropertyListener, childPropertyChanged, 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, setValue, toString, unregisterValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

propertyToValue

protected Map<Object,Object> propertyToValue
Maps from property names to values. Subclasses may modify, but must ensure that values are registered/deregistered as required.


typeInfo

protected TypeInfo typeInfo
Constructor Detail

DataObject

public DataObject()

DataObject

public DataObject(TypeInfo type)
Create an instance with a specified type.

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)

iterator

public Iterator iterator()
Create an iterator over all the values in the 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
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

getTypeInfo

public 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
Specified by:
getTypeInfo in class AbstractDataObject
See Also:
TypeRegistry

setTypeInfo

public void setTypeInfo(TypeInfo typeInfo)

getValue

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

Specified by:
getValue in interface IDataObject
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
Specified by:
setValue in class AbstractDataObject
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)

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
Parameters:
name - The property name.
Returns:
boolean True if the property is transient.


Copyright © 2008 Commonwealth of Australia