public class

EventListenerAggregate

extends Object
java.lang.Object
   ↳ sun.awt.EventListenerAggregate

Class Overview

A class that assists in managing EventListeners of the specified type. Its instance holds an array of listeners of the same type and allows to perform the typical operations on the listeners. This class is thread-safe.

Summary

Public Constructors
EventListenerAggregate(Class listenerClass)
Constructs an EventListenerAggregate object.
Public Methods
synchronized void add(EventListener listener)
Adds the listener to this aggregate.
synchronized EventListener[] getListenersCopy()
Returns an array of all the listeners contained in this aggregate.
synchronized EventListener[] getListenersInternal()
Returns an array of all the listeners contained in this aggregate.
synchronized boolean isEmpty()
Returns true if this aggregate contains no listeners, false otherwise.
synchronized boolean remove(EventListener listener)
Removes a listener that is equal to the given one from this aggregate.
synchronized int size()
Returns the number of lisetners in this aggregate.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public EventListenerAggregate (Class listenerClass)

Constructs an EventListenerAggregate object.

Parameters
listenerClass the type of the listeners to be managed by this object
Throws
NullPointerException if listenerClass is null
ClassCastException if listenerClass is not assignable to java.util.EventListener

Public Methods

public synchronized void add (EventListener listener)

Adds the listener to this aggregate.

Parameters
listener the listener to be added
Throws
ClassCastException if listener is not an instatce of listenerClass specified in the constructor

public synchronized EventListener[] getListenersCopy ()

Returns an array of all the listeners contained in this aggregate. The array is a copy of the data structure in which listeners are stored internally. The runtime type of the returned array is "array of listenerClass" (listenerClass has been specified as a parameter to the constructor of this class).

Returns
  • a copy of all the listeners contained in this aggregate (an empty array if there are no listeners)

public synchronized EventListener[] getListenersInternal ()

Returns an array of all the listeners contained in this aggregate. The array is the data structure in which listeners are stored internally. The runtime type of the returned array is "array of listenerClass" (listenerClass has been specified as a parameter to the constructor of this class).

Returns
  • all the listeners contained in this aggregate (an empty array if there are no listeners)

public synchronized boolean isEmpty ()

Returns true if this aggregate contains no listeners, false otherwise.

Returns
  • true if this aggregate contains no listeners, false otherwise

public synchronized boolean remove (EventListener listener)

Removes a listener that is equal to the given one from this aggregate. equals() method is used to compare listeners.

Parameters
listener the listener to be removed
Returns
  • true if this aggregate contained the specified listener; false otherwise
Throws
ClassCastException if listener is not an instatce of listenerClass specified in the constructor

public synchronized int size ()

Returns the number of lisetners in this aggregate.

Returns
  • the number of lisetners in this aggregate