Android
java.util
public class

java.util.Observable

java.lang.Object
java.util.Observable

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

Known Direct Subclasses

Summary

Public Constructors

            Observable()
Constructs a new Observable object.

Public Methods

  synchronized        void  addObserver(Observer observer)
Adds the specified Observer to the list of observers.
  synchronized        int  countObservers()
Returns the number of Observers in the list of observers.
  synchronized        void  deleteObserver(Observer observer)
Removes the specified Observer from the list of observers.
  synchronized        void  deleteObservers()
Removes all Observers from the list of observers.
  synchronized        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 Methods

  synchronized        void  clearChanged()
Clears the changed flag for this Observable.
  synchronized        void  setChanged()
Sets the changed flag for this Observable.
Methods inherited from class java.lang.Object

Details

Public Constructors

public Observable()

Constructs a new Observable object.

Public Methods

public synchronized void addObserver(Observer observer)

Adds the specified Observer to the list of observers.

Parameters

observer the Observer to add

public synchronized int countObservers()

Returns the number of Observers in the list of observers.

Returns

  • the number of observers

public synchronized void deleteObserver(Observer observer)

Removes the specified Observer from the list of observers.

Parameters

observer the Observer to remove

public synchronized void deleteObservers()

Removes all Observers from the list of observers.

public synchronized boolean hasChanged()

Returns the changed flag for this Observable.

Returns

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

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)

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()

Protected Methods

protected synchronized void clearChanged()

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

protected synchronized void setChanged()

Sets the changed flag for this Observable. After calling setChanged(), hasChanged() will return true.
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:48