becker.util
Class Observers

java.lang.Object
  extended by becker.util.Observers
All Implemented Interfaces:
IObservable

public class Observers
extends Object
implements IObservable

An instance of Observers is usually used by a class implementing IObservable to store its list of observers. Each time the class changes, it should call notifyObservers. This, in turn, calls the update method for each of the observers stored in the list.

Author:
Byron Weber Becker
See Also:
IObservable, IObserver

Constructor Summary
Observers()
          Construct a new list of observers.
 
Method Summary
 void addObserver(IObserver observer)
          Add another observer to the list.
 void notifyObservers(Object theObserved, Object changeInfo)
          Notify each of the observers on the list that something has happened to the object they are observing.
 void removeObserver(IObserver observer)
          Remove a specific observer from the list.
 void removeObservers()
          Remove all the observers from the list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Observers

public Observers()
Construct a new list of observers.

Method Detail

addObserver

public void addObserver(IObserver observer)
Add another observer to the list.

Specified by:
addObserver in interface IObservable
Parameters:
observer - The observer to add.

removeObserver

public void removeObserver(IObserver observer)
Remove a specific observer from the list.

Specified by:
removeObserver in interface IObservable
Parameters:
observer - The observer to remove.

removeObservers

public void removeObservers()
Remove all the observers from the list.

Specified by:
removeObservers in interface IObservable

notifyObservers

public void notifyObservers(Object theObserved,
                            Object changeInfo)
Notify each of the observers on the list that something has happened to the object they are observing.

Parameters:
theObserved - The object that changed.
changeInfo - Additional information about what changed. May be null.