net.sourceforge.esw.util
Class SupportObject

java.lang.Object
  |
  +--net.sourceforge.esw.util.SupportObject
All Implemented Interfaces:
ISupportObject, java.io.Serializable
Direct Known Subclasses:
AService, DefaultHeartbeatGenerator, FilterEngine, Node, NodeTableAdapter, ReggieLookup

public class SupportObject
extends java.lang.Object
implements ISupportObject

Provides basic abilities to an data-centric Object.

This SupportObject implementation is the default implementation of the ISupportObject interface.

Defines several basic elements required for a data-centric Object. Those elements help a data Object fit within pieces of the Java Beans specification, and provide other useful things.

This ISupportObject instance provides support for bound and contrained properties on a Java Bean. Support for bound properties provide a way to notify interested parties when an attempt is made to change an instance's bound property. The VetoableChangeListener class allows applications to control the semantics of whether a change to a contrained property is permitted. See the current Java Beans specifications for more information.

There is also support for a property scratchpad containing key/value pairs which can be used to associate values with this ISupportObject instance. For any given ISupportObject instance, the property keys are unique (though values need not be).

This ISupportObject allows an optional identifier to be assigned to the ISupportObject instance. Identifiers can be used to distinguish, categorize, or label instances within a collection; however, identifiers need not be unique within a collection.

See Also:
Serialized Form

Field Summary
protected  java.lang.Object id
          The identifier for this SupportObject instance.
protected  java.util.HashMap properties
          The dynamic properties for this SupportObject instance.
protected  java.util.Hashtable propertyChildren
          Associates listeners with the property that concerns them.
protected  ListenerSupport propertyListeners
          Provides support for the PropertyChangeListeners for this SupportObject instance.
protected  java.util.Hashtable vetoableChildren
          Associates listeners with the property that concerns them.
protected  ListenerSupport vetoableListeners
          Provides support for the VetoableChangeListeners for this SupportObject instance.
 
Constructor Summary
SupportObject()
          Creates a new SupportObject instance.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener aListener)
          Adds a PropertyChangeListener to this ISupportObject instance.
 void addPropertyChangeListener(java.lang.String aPropertyName, java.beans.PropertyChangeListener aListener)
          Adds a PropertyChangeListener to this ISupportObject instance for the specified property.
 void addVetoableChangeListener(java.lang.String aPropertyName, java.beans.VetoableChangeListener aListener)
          Adds a VetoableChangeListener to this ISupportObject instance for the specified property.
 void addVetoableChangeListener(java.beans.VetoableChangeListener aListener)
          Adds a VetoableChangeListener to this ISupportObject instance.
 void firePropertyChange(java.beans.PropertyChangeEvent aEvent)
          Fires a PropertyChangeEvent from this ISupportObject instance.
 void firePropertyChange(java.lang.String aPropertyName, java.lang.Object aOldValue, java.lang.Object aNewValue)
          Fires a PropertyChangeEvent from this ISupportObject instance.
 void fireVetoableChange(java.beans.PropertyChangeEvent aEvent)
          Fires a vetoable PropertyChangeEvent from this ISupportObject instance.
 void fireVetoableChange(java.lang.String aPropertyName, java.lang.Object aOldValue, java.lang.Object aNewValue)
          Fires a vetoable PropertyChangeEvent from this ISupportObject instance.
 java.lang.Object getID()
          Returns the identifier for this ISupportObject instance.
 java.lang.Object getProperty(java.lang.Object aKey)
          Returns the value of the property specified by the given Object for this ISupportObject instance.
 int getPropertySize()
          Returns the number of properties associated with this ISupportObject instance.
 java.util.Iterator propertyKeys()
          Returns an Iterator instance over the property keys in this ISupportObject instance.
 java.lang.Object removeProperty(java.lang.Object aKey)
          Removes the property specified by the gien Object key for this ISupportObject instance, and returns the value mapped to the specified Object key.
 void removePropertyChangeListener(java.beans.PropertyChangeListener aListener)
          Removes the specified PropertyChangeListener from this ISupportObject instance.
 void removePropertyChangeListener(java.lang.String aPropertyName, java.beans.PropertyChangeListener aListener)
          Removes the specified PropertyChangeListener from this ISupportObject instance for the specified property.
 void removeVetoableChangeListener(java.lang.String aPropertyName, java.beans.VetoableChangeListener aListener)
          Removes the specified VetoableChangeListener from this ISupportObject instance for the specified property.
 void removeVetoableChangeListener(java.beans.VetoableChangeListener aListener)
          Removes the specified VetoableChangeListener from this ISupportObject instance.
 void setID(java.lang.Object aId)
          Sets this ISupportObject instance's identifier.
 void setProperty(java.lang.Object aKey, java.lang.Object aValue)
          Sets the specified key/value property on this ISupportObject instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

propertyListeners

protected transient ListenerSupport propertyListeners
Provides support for the PropertyChangeListeners for this SupportObject instance.

vetoableListeners

protected transient ListenerSupport vetoableListeners
Provides support for the VetoableChangeListeners for this SupportObject instance.

propertyChildren

protected java.util.Hashtable propertyChildren
Associates listeners with the property that concerns them. Maps property names to ListenerSupport objects.

vetoableChildren

protected java.util.Hashtable vetoableChildren
Associates listeners with the property that concerns them. Maps vetoable property names to ListenerSupport objects.

properties

protected java.util.HashMap properties
The dynamic properties for this SupportObject instance.

id

protected java.lang.Object id
The identifier for this SupportObject instance.
Constructor Detail

SupportObject

public SupportObject()
Creates a new SupportObject instance.
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener aListener)
Adds a PropertyChangeListener to this ISupportObject instance.
Specified by:
addPropertyChangeListener in interface ISupportObject
Parameters:
aListener - the PropertyChangeListener to be added.
See Also:
removePropertyChangeListener( PropertyChangeListener )

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String aPropertyName,
                                      java.beans.PropertyChangeListener aListener)
Adds a PropertyChangeListener to this ISupportObject instance for the specified property.
Specified by:
addPropertyChangeListener in interface ISupportObject
Parameters:
aPropertyName - the property to which to add the Listener.
aListener - the PropertyChangeListener to be added.
See Also:
removePropertyChangeListener( String, PropertyChangeListener )

addVetoableChangeListener

public void addVetoableChangeListener(java.beans.VetoableChangeListener aListener)
Adds a VetoableChangeListener to this ISupportObject instance.
Specified by:
addVetoableChangeListener in interface ISupportObject
Parameters:
aListener - the VetoableChangeListener to be added.
See Also:
removePropertyChangeListener( PropertyChangeListener )

addVetoableChangeListener

public void addVetoableChangeListener(java.lang.String aPropertyName,
                                      java.beans.VetoableChangeListener aListener)
Adds a VetoableChangeListener to this ISupportObject instance for the specified property.
Specified by:
addVetoableChangeListener in interface ISupportObject
Parameters:
aPropertyName - the property to which to add the Listener.
aListener - the VetoableChangeListener to be added.
See Also:
removePropertyChangeListener( String, PropertyChangeListener )

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener aListener)
Removes the specified PropertyChangeListener from this ISupportObject instance.
Specified by:
removePropertyChangeListener in interface ISupportObject
Parameters:
aListener - the PropertyChangeListener to be removed.
See Also:
addPropertyChangeListener( PropertyChangeListener )

removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String aPropertyName,
                                         java.beans.PropertyChangeListener aListener)
Removes the specified PropertyChangeListener from this ISupportObject instance for the specified property.
Specified by:
removePropertyChangeListener in interface ISupportObject
Parameters:
aPropertyName - the property to which to remove the Listener.
aListener - the PropertyChangeListener to be removed.
See Also:
addPropertyChangeListener( String, PropertyChangeListener )

removeVetoableChangeListener

public void removeVetoableChangeListener(java.beans.VetoableChangeListener aListener)
Removes the specified VetoableChangeListener from this ISupportObject instance.
Specified by:
removeVetoableChangeListener in interface ISupportObject
Parameters:
aListener - the VetoableChangeListener to be removed.
See Also:
addVetoableChangeListener( VetoableChangeListener )

removeVetoableChangeListener

public void removeVetoableChangeListener(java.lang.String aPropertyName,
                                         java.beans.VetoableChangeListener aListener)
Removes the specified VetoableChangeListener from this ISupportObject instance for the specified property.
Specified by:
removeVetoableChangeListener in interface ISupportObject
Parameters:
aPropertyName - the property to which to remove the Listener.
aListener - the VetoableChangeListener to be removed.
See Also:
addVetoableChangeListener( String, VetoableChangeListener )

setProperty

public void setProperty(java.lang.Object aKey,
                        java.lang.Object aValue)
Sets the specified key/value property on this ISupportObject instance.
Specified by:
setProperty in interface ISupportObject
Parameters:
aKey - The key of the property being added.
aValue - The value of the property being added. Examples:
   String key   = "name";
   String value = "Smith";
   dataObject.setProperty( key, value );
 
See Also:
getProperty( Object ), removeProperty( Object ), propertyKeys(), getPropertySize()

getProperty

public java.lang.Object getProperty(java.lang.Object aKey)
Returns the value of the property specified by the given Object for this ISupportObject instance.
Specified by:
getProperty in interface ISupportObject
Parameters:
aKey - the key identifying the value to return.
Returns:
the value of the specified Object key. Examples:
   String value = dataObject.getProperty( "name" );
 
See Also:
setProperty( Object, Object ), removeProperty( Object ), propertyKeys(), getPropertySize()

removeProperty

public java.lang.Object removeProperty(java.lang.Object aKey)
Removes the property specified by the gien Object key for this ISupportObject instance, and returns the value mapped to the specified Object key.
Specified by:
removeProperty in interface ISupportObject
Parameters:
aKey - The key of the key/value pair to remove
Returns:
the value of the aKey in the key/value pair Examples:
   String value = dataObject.removeProperty( "name" );
 
See Also:
setProperty( Object, Object ), getProperty( Object ), propertyKeys(), getPropertySize()

propertyKeys

public java.util.Iterator propertyKeys()
Returns an Iterator instance over the property keys in this ISupportObject instance.
Specified by:
propertyKeys in interface ISupportObject
Returns:
an Iterator of the keys in this ISupportObject instance. Examples:
   Iterator iterator = dataObject.propertyKeys();
   while ( iterator.hasNext() ) {
     Object aKey = iterator.next();
     // do something with the key...
   }
 
See Also:
setProperty( Object, Object ), getProperty( Object ), removeProperty( Object ), getPropertySize()

getPropertySize

public int getPropertySize()
Returns the number of properties associated with this ISupportObject instance.
Specified by:
getPropertySize in interface ISupportObject
Returns:
the number of properties in this ISupportObject instance. Examples:
   int numberOfProperties = dataObject.propertySize();
 
See Also:
setProperty( Object, Object ), getProperty( Object ), removeProperty( Object ), propertyKeys()

setID

public void setID(java.lang.Object aId)
Sets this ISupportObject instance's identifier. If an identifier is not specified, a numeric identifier will be provided. The ESW framework provides numeric identifiers which are unique within this instance of the Java Virtual Machine

Fires a IUtilResources.ID_PROPERTY property change event.

Specified by:
setID in interface ISupportObject
Parameters:
aId - the unique Id for this ISupportObject instance.
See Also:
getID( )

getID

public java.lang.Object getID()
Returns the identifier for this ISupportObject instance.
Specified by:
getID in interface ISupportObject
Returns:
the unique Id for this ISupportObject instance.
See Also:
setID( Object )

firePropertyChange

public void firePropertyChange(java.lang.String aPropertyName,
                               java.lang.Object aOldValue,
                               java.lang.Object aNewValue)
Fires a PropertyChangeEvent from this ISupportObject instance.
Specified by:
firePropertyChange in interface ISupportObject
Parameters:
aPropertyName - the property for which to fire the event.
aOldValue - the old value for the event.
aNewValue - the new value for the event.

firePropertyChange

public void firePropertyChange(java.beans.PropertyChangeEvent aEvent)
Fires a PropertyChangeEvent from this ISupportObject instance.
Specified by:
firePropertyChange in interface ISupportObject
Parameters:
aEvent - the event to fire.

fireVetoableChange

public void fireVetoableChange(java.lang.String aPropertyName,
                               java.lang.Object aOldValue,
                               java.lang.Object aNewValue)
                        throws java.beans.PropertyVetoException
Fires a vetoable PropertyChangeEvent from this ISupportObject instance.
Specified by:
fireVetoableChange in interface ISupportObject
Parameters:
aPropertyName - the property for which to fire the event.
aOldValue - the old value for the event.
aNewValue - the new value for the event.

fireVetoableChange

public void fireVetoableChange(java.beans.PropertyChangeEvent aEvent)
                        throws java.beans.PropertyVetoException
Fires a vetoable PropertyChangeEvent from this ISupportObject instance.
Specified by:
fireVetoableChange in interface ISupportObject
Parameters:
aEvent - the event to fire.


Copyright 2002 Free Software Foundation. All Rights Reserved.