Class Observable

java.lang.Object
org.apache.ofbiz.base.util.Observable

public final class Observable extends Object
An observable object.

This class is similar to java.util.Observable but it has some differences:

  • It has improved concurrency
  • It cannot be subclassed
  • The notifyObservers method does not clear the changed flag
  • Protected methods have been made public
  • Constructor Details

    • Observable

      public Observable()
    • Observable

      public Observable(Observable observable)
  • Method Details

    • addObserver

      public void addObserver(Observer observer)
      Adds an observer to the set of observers for this object.
      Parameters:
      observer - the observer to be added.
    • clearChanged

      public void clearChanged()
      Clears the changed flag.
    • deleteObserver

      public void deleteObserver(Observer observer)
      Deletes an observer from the set of observers of this object. Passing null to this method will have no effect.
      Parameters:
      observer - the observer to be deleted.
    • deleteObservers

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

      public boolean hasChanged()
      Returns true if this object has changed.
    • notifyObservers

      public void notifyObservers()
      Notify all of the observers.

      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)
    • notifyObservers

      public void notifyObservers(Object arg)
      Notify all of the observers.

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

    • setChanged

      public void setChanged()
      Sets the changed flag to true.