Class EvntListenerList

java.lang.Object
org.bzdev.util.EvntListenerList

public class EvntListenerList extends Object
Class implementing a list of event listeners . This class has the same behavior as the class EventListenerList. It is provided so that several modules (e.g., org.bzdev.devqsim and org.bzdev.drama) will not have a dependency on the module java.desktop.
See Also:
  • Constructor Details

    • EvntListenerList

      public EvntListenerList()
      Constructor.
  • Method Details

    • add

      public <T extends EventListener> void add(Class<T> t, T l)
      Add a listener to the list The listener l's class or one of its superclasses must match the class t. The full list is comprised of a collection of sublists, each distinguished by a class t that serves as a key naming a sublist.
      Type Parameters:
      T - the type of the class provided by the first argument
      Parameters:
      t - the class for the listener
      l - the listener, whose type or supertype must match the one provided by the argument t
    • getListenerCount

      public int getListenerCount()
      Get the number of listeners
      Returns:
      the number of listeners
    • getListenerCount

      public int getListenerCount(Class<?> t)
      Get the number of listeners for a particular key Each listener will have the key t as the listener's class or a superclass. The full list is comprised of a collection of sublists, each distinguished by a class t that serves as a key naming a sublist.
      Parameters:
      t - the class or a superclass serving as a key for listeners
      Returns:
      the number of listeners
    • getListenerList

      public Object[] getListenerList()
      Returns the internal list of alternating listener classes and listeners. The array returned is the internal array used by this class.

      Please see EventListenerList for additional documentation.

      Returns:
      an array whose even elements (starting from 0) contain the class for a listener and whose odd values contain the corresponding listener
    • getListeners

      public <T extends EventListener> T[] getListeners(Class<T> t)
      Get an array of listeners of a particular type. The full list is comprised of a collection of sublists, each distinguished by a class t that serves as a key naming a sublist.
      Type Parameters:
      T - the type for the class t
      Parameters:
      t - the class (or superclass) of a listener that is used as a key
      Returns:
      a list of the listeners matching the key
    • remove

      public <T extends EventListener> void remove(Class<T> t, T l)
      Remove a listener from a listener list. If the same listener was added twice, the most recently added listener is the one that is removed. The listener l's class or one of its superclasses must match the class t. The full list is comprised of a collection of sublists, each distinguished by a class t that serves as a key naming a sublist.
      Type Parameters:
      T - the type for the class t
      Parameters:
      t - the class for the listener
      l - the listener, whose type or supertype must match the one provided by the argument t
    • toString

      public String toString()
      Get a string representation of this object.
      Overrides:
      toString in class Object
      Returns:
      the string