Package org.teavm.classlib.java.util
Class TObservable
java.lang.Object
org.teavm.classlib.java.util.TObservable
- Author:
- shannah
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addObserver(TObserver observer)
Adds the specified observer to the list of observers.protected void
Clears the changed flag for thisObservable
.int
Returns the number of observers registered to thisObservable
.void
deleteObserver(TObserver observer)
Removes the specified observer from the list of observers.void
Removes all observers from the list of observers.boolean
Returns the changed flag for thisObservable
.void
IfhasChanged()
returnstrue
, calls theupdate()
method for every observer in the list of observers using null as the argument.void
notifyObservers(Object data)
IfhasChanged()
returnstrue
, calls theupdate()
method for every Observer in the list of observers using the specified argument.protected void
Sets the changed flag for thisObservable
.
-
Constructor Details
-
TObservable
public TObservable()Constructs a newObservable
object.
-
-
Method Details
-
addObserver
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 thisObservable
. After callingclearChanged()
,hasChanged()
will returnfalse
. -
countObservers
public int countObservers()Returns the number of observers registered to thisObservable
.- Returns:
- the number of observers.
-
deleteObserver
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 thisObservable
.- Returns:
true
when the changed flag for thisObservable
is set,false
otherwise.
-
notifyObservers
public void notifyObservers()IfhasChanged()
returnstrue
, calls theupdate()
method for every observer in the list of observers using null as the argument. Afterwards, callsclearChanged()
.Equivalent to calling
notifyObservers(null)
. -
notifyObservers
IfhasChanged()
returnstrue
, calls theupdate()
method for every Observer in the list of observers using the specified argument. Afterwards callsclearChanged()
.- Parameters:
data
- the argument passed toupdate()
.
-
setChanged
protected void setChanged()Sets the changed flag for thisObservable
. After callingsetChanged()
,hasChanged()
will returntrue
.
-