Build 1.0_r1(from source)

java.util
Class Observable

java.lang.Object
  extended by java.util.Observable
Direct Known Subclasses:
ContentQueryMap, Gmail.LabelMap

public class Observable
extends Object

Observable is used to notify a group of Observer objects when a change occurs.


Field Summary
(package private)  boolean changed
           
(package private)  Vector<Observer> observers
           
 
Constructor Summary
Observable()
          Constructs a new Observable object.
 
Method Summary
 void addObserver(Observer observer)
          Adds the specified Observer to the list of observers.
protected  void clearChanged()
          Clears the changed flag for this Observable.
 int countObservers()
          Returns the number of Observers in the list of observers.
 void deleteObserver(Observer observer)
          Removes the specified Observer from the list of observers.
 void deleteObservers()
          Removes all Observers from the list of observers.
 boolean hasChanged()
          Returns the changed flag for this Observable.
 void notifyObservers()
          If hasChanged() returns true, calls the update() method for every Observer in the list of observers using null as the argument.
 void notifyObservers(Object data)
          If hasChanged() returns true, calls the update() method for every Observer in the list of observers using the specified argument.
protected  void setChanged()
          Sets the changed flag for this Observable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

observers

Vector<Observer> observers

changed

boolean changed
Constructor Detail

Observable

public Observable()
Constructs a new Observable object.

Method Detail

addObserver

public void addObserver(Observer observer)
Adds the specified Observer to the list of observers.

Parameters:
observer - the Observer to add

clearChanged

protected void clearChanged()
Clears the changed flag for this Observable. After calling clearChanged(), hasChanged() will return false.


countObservers

public int countObservers()
Returns the number of Observers in the list of observers.

Returns:
the number of observers

deleteObserver

public void deleteObserver(Observer observer)
Removes the specified Observer from the list of observers.

Parameters:
observer - the Observer to remove

deleteObservers

public void deleteObservers()
Removes all Observers from the list of observers.


hasChanged

public boolean hasChanged()
Returns the changed flag for this Observable.

Returns:
true when the changed flag for this Observable is set, false otherwise

notifyObservers

public void notifyObservers()
If hasChanged() returns true, calls the update() method for every Observer in the list of observers using null as the argument. Afterwards calls clearChanged(). Equivalent to calling notifyObservers(null)


notifyObservers

public void notifyObservers(Object data)
If hasChanged() returns true, calls the update() method for every Observer in the list of observers using the specified argument. Afterwards calls clearChanged().

Parameters:
data - the argument passed to update()

setChanged

protected void setChanged()
Sets the changed flag for this Observable. After calling setChanged(), hasChanged() will return true.


Build 1.0_r1(from source)

Please submit a feedback, bug or feature