java.util
Class Observable

java.lang.Object
  |
  +--java.util.Observable

public class Observable
extends Object

Untamed:


Field Summary
private  boolean changed
           
private  Vector obs
           
 
Constructor Summary
Observable()
          Enabled: Construct an Observable with zero Observers.
 
Method Summary
 void addObserver(Observer o)
          Enabled: 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()
          Enabled: Returns the number of observers of this Observable object.
 void deleteObserver(Observer o)
          Enabled: Deletes an observer from the set of observers of this object.
 void deleteObservers()
          Enabled: Clears the observer list so that this object no longer has any observers.
 boolean hasChanged()
          Enabled: Tests if this object has changed.
 void notifyObservers()
          Enabled: 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.
 void notifyObservers(Object arg)
          Enabled: 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

changed

private boolean changed

obs

private Vector obs
Constructor Detail

Observable

public Observable()
Enabled: Construct an Observable with zero Observers.

Method Detail

addObserver

public void addObserver(Observer o)
Enabled: 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. The order in which notifications will be delivered to multiple observers is not specified. See the class comment.

Parameters:
o - an observer to be added.
Throws:
NullPointerException - if the parameter o is null.

deleteObserver

public void deleteObserver(Observer o)
Enabled: Deletes an observer from the set of observers of this object.

Parameters:
o - the observer to be deleted.

notifyObservers

public void notifyObservers()
Enabled: 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.

Each observer has its update method called with two arguments: this observable object and null. In other words, this method is equivalent to:

notifyObservers(null)

See Also:
java.util.Observable#clearChanged(), java.util.Observable#hasChanged(), java.util.Observer#update(java.util.Observable, java.lang.Object)

notifyObservers

public void notifyObservers(Object arg)
Enabled: 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.

Each observer has its update method called with two arguments: this observable object and the arg argument.

Parameters:
arg - any object.
See Also:
java.util.Observable#clearChanged(), java.util.Observable#hasChanged(), java.util.Observer#update(java.util.Observable, java.lang.Object)

deleteObservers

public void deleteObservers()
Enabled: Clears the observer list so that this object no longer has any observers.


setChanged

protected void setChanged()
Marks this Observable object as having been changed; the hasChanged method will now return true.


clearChanged

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. This method is called automatically by the notifyObservers methods.

See Also:
java.util.Observable#notifyObservers(), java.util.Observable#notifyObservers(java.lang.Object)

hasChanged

public boolean hasChanged()
Enabled: Tests if this object has changed.

Returns:
true if and only if the setChanged method has been called more recently than the clearChanged method on this object; false otherwise.
See Also:
java.util.Observable#clearChanged(), java.util.Observable#setChanged()

countObservers

public int countObservers()
Enabled: Returns the number of observers of this Observable object.

Returns:
the number of observers of this object.


comments?