Package org.apache.ofbiz.base.util
Class Observable
- java.lang.Object
-
- org.apache.ofbiz.base.util.Observable
-
public final class Observable extends java.lang.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 Summary
Constructors Constructor Description Observable()
Observable(Observable observable)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addObserver(Observer observer)
Adds an observer to the set of observers for this object.void
clearChanged()
Clears the changed flag.void
deleteObserver(Observer observer)
Deletes an observer from the set of observers of this object.void
deleteObservers()
Clears the observer list so that this object no longer has any observers.boolean
hasChanged()
Returnstrue
if this object has changed.void
notifyObservers()
Notify all of the observers.void
notifyObservers(java.lang.Object arg)
Notify all of the observers.void
setChanged()
Sets the changed flag totrue
.
-
-
-
Constructor Detail
-
Observable
public Observable()
-
Observable
public Observable(Observable observable)
-
-
Method Detail
-
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. Passingnull
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()
Returnstrue
if this object has changed.
-
notifyObservers
public void notifyObservers()
Notify all of the observers.Each
Observer
has itsupdate
method called with two arguments: this observable object andnull
. In other words, this method is equivalent to:notifyObservers(null)
-
notifyObservers
public void notifyObservers(java.lang.Object arg)
Notify all of the observers.Each observer has its
update
method called with two arguments: this observable object and thearg
argument.
-
setChanged
public void setChanged()
Sets the changed flag totrue
.
-
-