public class Observable extends Object
| 构造器和说明 |
|---|
Observable() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addObserver(Observer o)
Adds an observer to the set of observers for this object, provided that it is not the same as some observer
already in the set.
|
protected void |
clearChanged()
Indicates that this object has no longer changed, or that it has already notified all of its observers of its
most recent change, so that the
hasChanged method will now return false. |
int |
countObservers()
Returns the number of observers of this
Observable object. |
void |
deleteObserver(Observer o)
Deletes an observer from the set of observers of this object.
|
void |
deleteObservers()
Clears the observer list so that this object no longer has any observers.
|
boolean |
hasChanged()
Tests if this object has changed.
|
void |
notifyObservers()
If this object has changed, as indicated by the
hasChanged method, then notify all of its observers and
then call the clearChanged method to indicate that this object has no longer changed. |
protected void |
setChanged()
Marks this
Observable object as having been changed; the hasChanged method will now return true. |
public void addObserver(Observer o)
o - an observer to be added.NullPointerException - if the parameter o is null.public void deleteObserver(Observer o)
null to this method will have no
effect.o - the observer to be deleted.public void notifyObservers()
hasChanged method, then notify all of its observers and
then call the clearChanged method to indicate that this object has no longer changed.
Each observer has its update method called with one argument: this observable object.
public void deleteObservers()
protected void setChanged()
Observable object as having been changed; the hasChanged method will now return true.protected void clearChanged()
hasChanged method will now return false. This method is called
automatically by the notifyObservers methods.public boolean hasChanged()
true if and only if the setChanged method has been called more recently than the clearChanged method on this object; false otherwise.public int countObservers()
Observable object.Copyright © 2018–2022 Alibaba Group. All rights reserved.