dsto.dfc.databeans
Class DataBean

java.lang.Object
  extended by dsto.dfc.databeans.AbstractDataObject
      extended by dsto.dfc.databeans.AbstractDataBean
          extended by dsto.dfc.databeans.DataBean
All Implemented Interfaces:
IDataBean, IDataObject, IDataObjectChildListener, Cloneable
Direct Known Subclasses:
AbstractPropertyFilterSet, AbstractProtocol, JavaDataBean

public class DataBean
extends AbstractDataBean

Default implementation of IDataBean using Java collections classes for storage.

Version:
$Revision: 1.22 $
Author:
mpp

Field Summary
protected  Set alwaysTransient
           
protected  HashSet transientProperties
           
protected  TypeInfo typeInfo
           
protected  HashMap 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
DataBean()
           
DataBean(Dictionary dictionary)
          Create an instance copied from a java.util.Dictionary.
DataBean(Map map)
          Create a databean initialised from the contents of a java.util.Map.
DataBean(TypeInfo type)
          Create an instance with a specified type.
 
Method Summary
 void childPropertyChanged(Object childProperty, PropertyEvent e)
          Invoked when a child property value has changed.
 String[] getPropertyNames()
          Databean's only have strings as their property names.
 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 propertyIterator()
          Get an iterator that scans over all currently defined properties.
 void setAlwaysTransient(String name)
          Flag a property as always transient regardless of any changes that would normally make it non-transient.
 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.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, 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, setValue
 

Field Detail

values

protected HashMap values

transientProperties

protected HashSet transientProperties

alwaysTransient

protected Set alwaysTransient

typeInfo

protected TypeInfo typeInfo
Constructor Detail

DataBean

public DataBean()

DataBean

public DataBean(Map map)
Create a databean initialised from the contents of a java.util.Map.


DataBean

public DataBean(Dictionary dictionary)
Create an instance copied from a java.util.Dictionary.


DataBean

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

Method Detail

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)

setAlwaysTransient

public void setAlwaysTransient(String name)
Flag a property as always transient regardless of any changes that would normally make it non-transient.


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 AbstractDataObject
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)

getValue

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

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).

Parameters:
name - The property name.
Returns:
boolean True if the property is transient.

propertyIterator

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

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

getPropertyNames

public String[] getPropertyNames()
Description copied from interface: IDataBean
Databean's only have strings as their property names. This is a shortcut to get the property names for which getValue () would return a non-null value.


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