com.bbn.openmap.event
Class ListenerSupport<E>

java.lang.Object
  extended by java.util.concurrent.CopyOnWriteArrayList<E>
      extended by com.bbn.openmap.event.ListenerSupport<E>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<E>, java.util.RandomAccess
Direct Known Subclasses:
CenterSupport, EOMGListenerSupport, LayerConfigurationListenerSupport, LayerSupport, MapMouseSupport, OverviewMapHandler.ControlledMapSupport, PaintListenerSupport, PanSupport, ProgressSupport, ProjectionSupport, SymbolChooser.SymbolTreeHolder, WindowSupport, ZoomSupport

public class ListenerSupport<E>
extends java.util.concurrent.CopyOnWriteArrayList<E>
implements java.io.Serializable

This is an utility class that can be used by beans that need support for handling listeners and firing events. You can use an subclass of this class as a member field of your bean and delegate work to it. It handles the work for a listener support subclass managing the Vector of listeners. It knows nothing about firing events to the listeners.

See Also:
Serialized Form

Field Summary
protected  java.lang.Object source
           
 
Constructor Summary
ListenerSupport(java.lang.Object sourceBean)
          Construct a ListenerSupport object.
 
Method Summary
 boolean add(E o)
          Wrapper functions to make the iterator methods' synchronization work.
 void add(int i, E o)
           
 boolean addAll(int index, java.util.Collection<? extends E> c)
           
 void clear()
           
protected  java.lang.Object getSource()
          Get the source of the events.
 java.util.Iterator<E> iterator()
          Return an iterator over a clone of the listeners.
 java.util.ListIterator<E> listIterator()
          Return an ListIterator over a clone of the listeners, initialized to the end of the list.
 E remove(int index)
           
 boolean remove(java.lang.Object o)
           
 E set(int index, E element)
           
protected  void setSource(java.lang.Object src)
          Set the source of the events.
 int size()
           
 
Methods inherited from class java.util.concurrent.CopyOnWriteArrayList
addAll, addAllAbsent, addIfAbsent, clone, contains, containsAll, equals, get, hashCode, indexOf, indexOf, isEmpty, lastIndexOf, lastIndexOf, listIterator, removeAll, retainAll, subList, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

source

protected java.lang.Object source
Constructor Detail

ListenerSupport

public ListenerSupport(java.lang.Object sourceBean)
Construct a ListenerSupport object.

Parameters:
sourceBean - The bean to be given as the source for any events.
Method Detail

setSource

protected void setSource(java.lang.Object src)
Set the source of the events.


getSource

protected java.lang.Object getSource()
Get the source of the events.


iterator

public java.util.Iterator<E> iterator()
Return an iterator over a clone of the listeners.

Specified by:
iterator in interface java.lang.Iterable<E>
Specified by:
iterator in interface java.util.Collection<E>
Specified by:
iterator in interface java.util.List<E>
Overrides:
iterator in class java.util.concurrent.CopyOnWriteArrayList<E>

listIterator

public java.util.ListIterator<E> listIterator()
Return an ListIterator over a clone of the listeners, initialized to the end of the list.

Specified by:
listIterator in interface java.util.List<E>
Overrides:
listIterator in class java.util.concurrent.CopyOnWriteArrayList<E>

add

public boolean add(E o)
Wrapper functions to make the iterator methods' synchronization work.

Specified by:
add in interface java.util.Collection<E>
Specified by:
add in interface java.util.List<E>
Overrides:
add in class java.util.concurrent.CopyOnWriteArrayList<E>

add

public void add(int i,
                E o)
Specified by:
add in interface java.util.List<E>
Overrides:
add in class java.util.concurrent.CopyOnWriteArrayList<E>

addAll

public boolean addAll(int index,
                      java.util.Collection<? extends E> c)
Specified by:
addAll in interface java.util.List<E>
Overrides:
addAll in class java.util.concurrent.CopyOnWriteArrayList<E>

clear

public void clear()
Specified by:
clear in interface java.util.Collection<E>
Specified by:
clear in interface java.util.List<E>
Overrides:
clear in class java.util.concurrent.CopyOnWriteArrayList<E>

remove

public E remove(int index)
Specified by:
remove in interface java.util.List<E>
Overrides:
remove in class java.util.concurrent.CopyOnWriteArrayList<E>

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection<E>
Specified by:
remove in interface java.util.List<E>
Overrides:
remove in class java.util.concurrent.CopyOnWriteArrayList<E>

set

public E set(int index,
             E element)
Specified by:
set in interface java.util.List<E>
Overrides:
set in class java.util.concurrent.CopyOnWriteArrayList<E>

size

public int size()
Specified by:
size in interface java.util.Collection<E>
Specified by:
size in interface java.util.List<E>
Overrides:
size in class java.util.concurrent.CopyOnWriteArrayList<E>


Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details