java.util
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.
See Also: Observer
UNKNOWN: updated to 1.4
Constructor Summary | |
---|---|
Observable()
Constructs an Observable with zero Observers. |
Method Summary | |
---|---|
void | addObserver(Observer observer)
Adds an Observer. |
protected void | clearChanged()
Reset this Observable's state to unchanged. |
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. |
protected void | setChanged()
Marks this Observable as having changed. |
Parameters: observer Observer to add
Throws: NullPointerException if observer is null
notifyObservers
once all observers have been notified.
See Also: notifyObservers
Returns: number of Observers for this
Parameters: victim Observer to delete
setChanged
has been called more recently than
clearChanged
.
Returns: whether or not this Observable has changed
See Also: notifyObservers Observer
Parameters: obj argument to Observer's update method
See Also: Observer