org.gjt.lindfors.util
Class EventGeneratorSupport

java.lang.Object
  extended by org.gjt.lindfors.util.EventGeneratorSupport
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Visualizable

public abstract class EventGeneratorSupport
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable, Visualizable

Support class for objects implementing the EventGenerator interface. Contains implementations for addListener, removeListener, and hasListeners.

Every effort has been made to try to achieve thread-safety in EventGeneratorSupport class. Of course, this doesn't mean nasty race conditions and dead locks don't exist. I'm just not aware of them :)

For more detailed documentation, refer to the Util Library Tutorial and Util Library Specifications . See Also: The Event Generator Idiom by Bill Venners.

Since:
JDK1.1
Version:
$Revision: 1.4 $
Author:
Juha Lindfors
See Also:
EventGenerator, Serialized Form

Constructor Summary
EventGeneratorSupport()
          Constructs support object.
 
Method Summary
protected  void addListener(java.util.EventListener listener)
          Registers a new listener to this object.
 java.lang.Object clone()
          [PENDING]
protected  java.util.Enumeration getListeners()
          Returns the listeners registered to this object.
 boolean hasListeners()
          Checks if any registered listeners exist.
protected  void removeListener(java.util.EventListener listener)
          Unregisters a listener from this object.
 java.awt.Component toComponent()
          [PENDING]
 java.lang.String toString()
          Returns a string representation of this EventGeneratorSupport object.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EventGeneratorSupport

public EventGeneratorSupport()
Constructs support object.

Method Detail

hasListeners

public boolean hasListeners()
Checks if any registered listeners exist.

Returns:
true if one or more listeners exist, false otherwise

getListeners

protected java.util.Enumeration getListeners()
Returns the listeners registered to this object.

Returns:
enumeration of registered listener objects

addListener

protected void addListener(java.util.EventListener listener)
Registers a new listener to this object. Duplicate listeners are discarded.

This method is marked as protected and is supposed to be used only by the concrete implementations of generator support classes. The concrete subclasses must ensure only the correct type of listeners are allowed to register, as this method allows any listener to be added, therefore not being type safe.

Parameters:
listener - the listener object

removeListener

protected void removeListener(java.util.EventListener listener)
Unregisters a listener from this object. It is safe to attempt to unregister non-existant listeners.

Parameters:
listener - the listener object

toString

public java.lang.String toString()
Returns a string representation of this EventGeneratorSupport object.

The output will be similar to the following form:

          EventGeneratorSupport[Registered Listeners=1]
 

Overrides:
toString in class java.lang.Object

toComponent

public java.awt.Component toComponent()
[PENDING]

Specified by:
toComponent in interface Visualizable

clone

public java.lang.Object clone()
[PENDING]

Overrides:
clone in class java.lang.Object