dsto.dfc.databeans
Class SetDataObject

java.lang.Object
  extended by dsto.dfc.collections.BasicMonitoredCollection
      extended by dsto.dfc.collections.BasicMonitoredSet
          extended by dsto.dfc.databeans.SetDataObject
All Implemented Interfaces:
CollectionListener, MonitoredCollection, MonitoredSet, IDataObject, IDataObjectChildListener, Copyable, Serializable, Cloneable, Iterable, Collection, EventListener, Set

public class SetDataObject
extends BasicMonitoredSet
implements IDataObject, IDataObjectChildListener, CollectionListener

An extension of the DFC monitored set that supports access via the IDataObject interface. Any IDataObject's in the set are automatically monitored and the appropriate property events fired. The property values of the set are the values themselves.

Version:
$Revision$
Author:
mpp
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class dsto.dfc.collections.BasicMonitoredCollection
BasicMonitoredCollection.CollectionIteratorWrapper
 
Field Summary
protected  HashSet transientProperties
           
 
Fields inherited from class dsto.dfc.collections.BasicMonitoredCollection
collection, collectionListeners
 
Fields inherited from interface dsto.dfc.databeans.IDataObject
OVERRIDE, PERSISTENT, PERSISTENT_OVERRIDE, TRANSIENT, TRANSIENT_OVERRIDE
 
Constructor Summary
SetDataObject()
           
SetDataObject(Set set)
           
 
Method Summary
 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)
          Called when a child data object's property changes.
 void elementsAdded(CollectionEvent e)
           
 void elementsRemoved(CollectionEvent e)
           
protected  void firePropertyChangedEvent(Object source, Object oldValue, Object newValue, boolean transientProperty)
           
protected  void firePropertyChangedEvent(Object property, PropertyPath basePath, Object oldValue, Object newValue, boolean transientProperty)
           
 Collection getPropertyListeners()
          Return a non-modifiable list of registered property listeners.
 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.
protected  void registerValue(Object value)
           
 void removePropertyListener(PropertyListener l)
          Reverse the effect of IDataObject.addPropertyListener(PropertyListener).
 void setValue(Object name, Object value)
          This is a little weird for sets, where nominally name and value must be the same.
 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.
protected  void unregisterValue(Object value)
           
 
Methods inherited from class dsto.dfc.collections.BasicMonitoredCollection
add, addAll, addCollectionListener, clear, clone, contains, containsAll, emptyClone, fireElementsAdded, fireElementsRemoved, isEmpty, iterator, remove, removeAll, removeCollectionListener, retainAll, size, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface dsto.dfc.collections.MonitoredCollection
addCollectionListener, removeCollectionListener
 
Methods inherited from interface java.util.Set
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Field Detail

transientProperties

protected HashSet transientProperties
Constructor Detail

SetDataObject

public SetDataObject()

SetDataObject

public SetDataObject(Set set)
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
See Also:
TypeRegistry

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

unregisterValue

protected void unregisterValue(Object value)

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

setValue

public void setValue(Object name,
                     Object value)
This is a little weird for sets, where nominally name and value must be the same. However, operations like deep cloning assume that they can do "setValue (oldProperty, newValue)" since properties are immutable, so we allow this even though technically we shouldn't. Note that setValue (X, null) removes X from the set as would likely be expected.

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

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

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.

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

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

removePropertyListener

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

Specified by:
removePropertyListener in interface IDataObject

elementsAdded

public void elementsAdded(CollectionEvent e)
Specified by:
elementsAdded in interface CollectionListener

elementsRemoved

public void elementsRemoved(CollectionEvent e)
Specified by:
elementsRemoved in interface CollectionListener

childPropertyChanged

public void childPropertyChanged(Object childProperty,
                                 PropertyEvent e)
Description copied from interface: IDataObjectChildListener
Called when a child data object's property changes.

Specified by:
childPropertyChanged in interface IDataObjectChildListener
Parameters:
childProperty - The property the child is registered under.
e - The property change event emitted by the child.

firePropertyChangedEvent

protected void firePropertyChangedEvent(Object source,
                                        Object oldValue,
                                        Object newValue,
                                        boolean transientProperty)

firePropertyChangedEvent

protected void firePropertyChangedEvent(Object property,
                                        PropertyPath basePath,
                                        Object oldValue,
                                        Object newValue,
                                        boolean transientProperty)


Copyright © 2008 Commonwealth of Australia