Class TObservable

java.lang.Object
org.teavm.classlib.java.util.TObservable

public class TObservable extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new Observable object.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds the specified observer to the list of observers.
    protected void
    Clears the changed flag for this Observable.
    int
    Returns the number of observers registered to this Observable.
    void
    Removes the specified observer from the list of observers.
    void
    Removes all observers from the list of observers.
    boolean
    Returns the changed flag for this Observable.
    void
    If hasChanged() returns true, calls the update() method for every observer in the list of observers using null as the argument.
    void
    If hasChanged() returns true, calls the update() method for every Observer in the list of observers using the specified argument.
    protected void
    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
  • Constructor Details

    • TObservable

      public TObservable()
      Constructs a new Observable object.
  • Method Details

    • addObserver

      public void addObserver(TObserver observer)
      Adds the specified observer to the list of observers. If it is already registered, it is not added a second time.
      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 registered to this Observable.
      Returns:
      the number of observers.
    • deleteObserver

      public void deleteObserver(TObserver observer)
      Removes the specified observer from the list of observers. Passing null won't do anything.
      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.