com.rolemodelsoft.drawlet.util
Class BasicObservable

java.lang.Object
  |
  +--com.rolemodelsoft.drawlet.util.BasicObservable
Direct Known Subclasses:
SingleDrawingModel

public abstract class BasicObservable
extends java.lang.Object
implements Observable, java.io.Serializable

This provides basic default functionality for Observables that maintain and notify their Observers. It is an abstract class as there is nothing to observe until subclasses provide some content. Note that the list of observers is serializable.

See Also:
Serialized Form

Field Summary
protected  java.lang.Object observerList
          The list of Observers.
 
Constructor Summary
BasicObservable()
           
 
Method Summary
 void addObserver(Observer observer)
          Adds an observer to the observer list.
 void deleteObserver(Observer observer)
          Deletes an observer from the observer list.
 void deleteObservers()
          Deletes all observers from the observer list.
 Observer[] getObservers()
          Answers the array of current Observers.
protected  void notifyObserver(java.lang.Object observer, java.lang.Object arg)
          Notifies a particular observer that a change in the receiver occurred.
 void notifyObservers()
          Notifies all observers that an observable change occurred.
 void notifyObservers(java.lang.Object arg)
          Notifies all observers that an observable change occurs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

observerList

protected java.lang.Object observerList
The list of Observers. Could be null, a single Observer, or a Vector of Observers.
Constructor Detail

BasicObservable

public BasicObservable()
Method Detail

addObserver

public void addObserver(Observer observer)
Adds an observer to the observer list.
Specified by:
addObserver in interface Observable
Parameters:
observer - the observer to be added.

deleteObserver

public void deleteObserver(Observer observer)
Deletes an observer from the observer list.
Specified by:
deleteObserver in interface Observable
Parameters:
observer - the observer to be deleted

deleteObservers

public void deleteObservers()
Deletes all observers from the observer list. Though this is public, caution should be used before anything other than "this" invokes it.
Specified by:
deleteObservers in interface Observable

getObservers

public Observer[] getObservers()
Answers the array of current Observers.
Specified by:
getObservers in interface Observable
Returns:
an array of Observers.

notifyObserver

protected void notifyObserver(java.lang.Object observer,
                              java.lang.Object arg)
Notifies a particular observer that a change in the receiver occurred.
Parameters:
observer - the particular observer to be notified.
arg - info to pass along to the observer being notified.

notifyObservers

public void notifyObservers()
Notifies all observers that an observable change occurred. Though this is public, caution should be used before anything other than "this" invokes it.
Specified by:
notifyObservers in interface Observable

notifyObservers

public void notifyObservers(java.lang.Object arg)
Notifies all observers that an observable change occurs. Though this is public, caution should be used before anything other than "this" invokes it.
Specified by:
notifyObservers in interface Observable
Parameters:
arg - info to pass along to those being notified.