Tree objects base class with support for firing events and merging.
It also prescribes that each subclass MUST have copy constuctor
calling its superclass copy constructor. The copy constructor MUST be then called
during cloning.
All TreeObject subclasses should not have public contructors and therefore
should be created just by factory methods.
Pending: validation on request, invalidation
author: Libor Kramolis author: Petr Kuzel version: 0.1
getEventManager() Get assigned event manager.
Whole document should have only one and same EventManager.
final public boolean
hasPropertyChangeListeners(String propertyName) Check if there are any listeners for a specific property.
Parameters: propertyName - the property name.
Add a PropertyChangeListener for a specific property to the listener list.
Parameters: propertyname - Name of the property to listen on. Parameters: listener - The listener to add.
public boolean equals(Object object, boolean deep)(Code)
firePropertyChange
final protected void firePropertyChange(TreeEvent evt)(Code)
Fire an existing TreeEvent to any registered listeners.
No event is fired if the given event's old and new values are
equal and non-null.
Parameters: evt - The TreeEvent object.
firePropertyChange
final protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)(Code)
Report a bound property update to any registered listeners.
No event is fired if old and new are equal and non-null.
Parameters: propertyName - The programmatic name of the property that was changed. Parameters: oldValue - The old value of the property. Parameters: newValue - The new value of the property.
Get assigned event manager.
Whole document should have only one and same EventManager. When there is not
available manager, it returns null.
assigned event manager (may be null).
hasPropertyChangeListeners
final public boolean hasPropertyChangeListeners(String propertyName)(Code)
Check if there are any listeners for a specific property.
Parameters: propertyName - the property name. true if there are ore or more listeners for the given property
Update algorithm pattern that reuses original tree instances:
// 1. optimalization
if (this == treeObject) return;
// 2. can merge just my instances (so no cross implemetation merge allowed)
if (getClass().isAssignablFrom(treeObject.getClass())) throw CannotMergeException;
// 3. let superclass do its merge
super.merge(treeObject);
// 4. cast to myself (see step 2)
{getClass()} peer = ({getClass()}) treeObject;
// 5. merge all fields at THIS CLASS HIEARCHY LEVEL but
// fields that references object "parents"
// use setters that just fires property changes, i.e. such that never fails
// due to read-only or other constrains checks
foreach field in suitableClassFields
if field is simple
set{field}Impl( peer.get{field}() )
if field is collection or TreeObject
{field}.merge(peer.{field})
next field
Parameters: treeobject - merge peer throws: CannotMergeException - if can not merge with given node (invalid class)
Removes a PropertyChangeListener for a specific property from the listener list.
Parameters: propertyname - Name of the property that was listened on. Parameters: listener - The listener to remove.