dsto.dfc.databeans
Class ListDataObject

java.lang.Object
  extended by dsto.dfc.collections.BasicMonitoredCollection
      extended by dsto.dfc.collections.BasicMonitoredList
          extended by dsto.dfc.collections.DfcMonitoredList
              extended by dsto.dfc.databeans.ListDataObject
All Implemented Interfaces:
CollectionListener, DfcMonitoredListListener, MonitoredCollection, MonitoredList, IDataObject, IDataObjectChildListener, Copyable, Serializable, Cloneable, Iterable, Collection, EventListener, List
Direct Known Subclasses:
StackDataObject

public class ListDataObject
extends DfcMonitoredList
implements IDataObject, IDataObjectChildListener, DfcMonitoredListListener

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

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

Nested Class Summary
 
Nested classes/interfaces inherited from class dsto.dfc.collections.BasicMonitoredList
BasicMonitoredList.ListIteratorWrapper
 
Nested classes/interfaces inherited from class dsto.dfc.collections.BasicMonitoredCollection
BasicMonitoredCollection.CollectionIteratorWrapper
 
Field Summary
 
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
ListDataObject()
           
ListDataObject(List list)
           
 
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.
 Object clone()
          Create a completely separate copy of this object and any mutable objects owned by the object.
 void elementMoved(CollectionEvent e)
          Fired when an element in the list has moved (changed indexes).
 void elementsAdded(CollectionEvent e)
           
 void elementsRemoved(CollectionEvent e)
           
protected  void firePropertyChangedEvent(int index, 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).
protected  int nameToIndex(Object name)
          Translate a property name into an index into the list.
 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).
 Object set(int index, Object newValue)
          Override set () to generate a single property change event rather than two (old -> null, null -> new).
 void setValue(Object name, Object value)
          Set the value of a given property.
 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.DfcMonitoredList
addDfcMonitoredListListener, fireElementMoved, move, removeDfcMonitoredListListener
 
Methods inherited from class dsto.dfc.collections.BasicMonitoredList
add, add, addAll, addAll, clear, get, getBackingList, indexOf, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, subList
 
Methods inherited from class dsto.dfc.collections.BasicMonitoredCollection
addCollectionListener, contains, containsAll, emptyClone, fireElementsAdded, fireElementsRemoved, isEmpty, iterator, 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.List
contains, containsAll, equals, hashCode, isEmpty, iterator, retainAll, size, toArray, toArray
 

Constructor Detail

ListDataObject

public ListDataObject()

ListDataObject

public ListDataObject(List list)
Method Detail

clone

public Object clone()
             throws CloneNotSupportedException
Description copied from interface: Copyable
Create a completely separate copy of this object and any mutable objects owned by the object.

NOTE: subclasses should not remove the CloneNotSupportedException throws clause if they themselves support subclassing: removing the CloneNotSupportedException declaration stops subclasses from indicating that a clone was not possible.

Specified by:
clone in interface Copyable
Overrides:
clone in class BasicMonitoredCollection
Throws:
CloneNotSupportedException - if the clone failed or is not possible.

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)
Description copied from interface: IDataObject
Set the value of a given property. If the object supports it, a property change event should be emitted. This is usually a 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 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.

nameToIndex

protected int nameToIndex(Object name)
                   throws NumberFormatException
Translate a property name into an index into the list. Accepts either Integer's or objects whose toString () value parses as an integer.

Parameters:
name - The property name.
Returns:
The index into the list.
Throws:
NumberFormatException - if name is neither an Integer or a string that parses with Integer.parseInt(java.lang.String).

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

set

public Object set(int index,
                  Object newValue)
Override set () to generate a single property change event rather than two (old -> null, null -> new).

Specified by:
set in interface List
Overrides:
set in class BasicMonitoredList

elementsAdded

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

elementsRemoved

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

elementMoved

public void elementMoved(CollectionEvent e)
Description copied from interface: DfcMonitoredListListener
Fired when an element in the list has moved (changed indexes).

Specified by:
elementMoved in interface DfcMonitoredListListener
Parameters:
e - The move event. startIndex is the element's old index, endIndex is the new index.

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(int index,
                                        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