public class TObservable extends Object
Constructor and Description |
---|
TObservable()
Constructs a new
Observable object. |
Modifier and Type | Method and Description |
---|---|
void |
addObserver(TObserver observer)
Adds the specified observer to the list of observers.
|
protected void |
clearChanged()
Clears the changed flag for this
Observable . |
int |
countObservers()
Returns the number of observers registered to this
Observable . |
void |
deleteObserver(TObserver observer)
Removes the specified observer from the list of observers.
|
void |
deleteObservers()
Removes all observers from the list of observers.
|
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 void |
setChanged()
Sets the changed flag for this
Observable . |
public void addObserver(TObserver observer)
observer
- the Observer to add.protected void clearChanged()
Observable
. After calling
clearChanged()
, hasChanged()
will return false
.public int countObservers()
Observable
.public void deleteObserver(TObserver observer)
observer
- the observer to remove.public void deleteObservers()
public boolean hasChanged()
Observable
.true
when the changed flag for this Observable
is
set, false
otherwise.public void notifyObservers()
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)
hasChanged()
returns true
, calls the update()
method for every Observer in the list of observers using the specified
argument. Afterwards calls clearChanged()
.data
- the argument passed to update()
.protected void setChanged()
Observable
. After calling
setChanged()
, hasChanged()
will return true
.Copyright © 2019. All rights reserved.