|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.coffeecrew.mobile.oop.util.Observable
public class Observable
This class is intended to be used if you want your object to be observable.
It reimplements java.util.Observable
so you can also work with
the observer pattern using J2ME. This class also works in a J2SE environment
and can be used as a replacement for java.util.Observable
Constructor Summary | |
---|---|
Observable()
Creates a new instance of Observable with zero observers attached |
Method Summary | |
---|---|
void |
addObserver(Observer observer)
Adds an observer to this object which should be informed if the state of this object changes. |
protected void |
clearChanged()
Should be called if the state of the object is no longer changed or if all attached observer have been notified about the state change. |
int |
countObservers()
Returns the number of observers that are attached to this object |
void |
deleteObserver(Observer observer)
Deletes the specified observer from the list of observers so no more updates will be delivered to the observer |
void |
deleteObservers()
Removes all currently attached observers from this object |
boolean |
hasChanged()
If any attribute within the object changed this method returns true |
void |
notifyObservers()
Notifies attached observers that the state of this objet has changed |
void |
notifyObservers(java.lang.Object arg)
Notifies attached observers that the state of this objet has changed |
protected void |
setChanged()
Mark the object as having changed it's state. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Observable()
Method Detail |
---|
public void addObserver(Observer observer)
synchronize
this, because the
java.util.Vector
already synchronizes adding of elements.
observer
- The observer which should be added.protected void clearChanged()
public int countObservers()
public void deleteObserver(Observer observer)
observer
- The observer to be deletedpublic void deleteObservers()
public boolean hasChanged()
setChanged()
,
clearChanged()
public void notifyObservers()
notifyObservers(Object)
public void notifyObservers(java.lang.Object arg)
arg
- Argument to the observers update methodprotected void setChanged()
hasChanged()
returns true
after execution
hasChanged()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |