public class Observable extends Object
update method
of each observer.
Note that the notifyObservers() method of this class is
unrelated to the notify() of Object.Observer| Constructor and Description |
|---|
Observable()
Constructs an Observable with zero Observers.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addObserver(Observer observer)
Adds an Observer.
|
int |
countObservers()
Returns the number of observers for this object.
|
void |
deleteObserver(Observer victim)
Deletes an Observer of this Observable.
|
void |
deleteObservers()
Deletes all Observers of this Observable.
|
boolean |
hasChanged()
True if
setChanged has been called more recently than
clearChanged. |
void |
notifyObservers()
If the Observable has actually changed then tell all Observers about it,
then reset state to unchanged.
|
void |
notifyObservers(Object obj)
If the Observable has actually changed then tell all Observers about it,
then reset state to unchanged.
|
public void addObserver(Observer observer)
observer - Observer to addNullPointerException - if observer is nullpublic int countObservers()
public void deleteObserver(Observer victim)
victim - Observer to deletepublic void deleteObservers()
public boolean hasChanged()
setChanged has been called more recently than
clearChanged.public void notifyObservers()
public void notifyObservers(Object obj)
obj - argument to Observer's update methodObserver.update(Observable, Object)