|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Observable
scphEditor.CloneableObservable
public class CloneableObservable
This class re-implements java.util.Observable so it can be cloned safely. But there can be two meanings for cloning an observable:
This class does not implement java.lang.Cloneable! Reason: you might not want to support cloning in some of your subclasses. But this class provides a correctly-written protected clone() method, so your subclasses and the subclasses of your subclasses can rely on it. In other words, this class does not open up access until you want to, and provides proper support when you do open up access.
This class subclasses Observable, so that Observer objects cannot tell the difference. But all Observable methods accessing the observer list are overriden and re-implemented from scratch. Only the change methods are retained.
cloneObserverList(boolean)
,
Observable
Constructor Summary | |
---|---|
CloneableObservable()
Default constructor. |
|
CloneableObservable(boolean cloneObserverList)
Constructor specifying the copy policy for the observer list. |
Method Summary | |
---|---|
void |
addObserver(java.util.Observer o)
Adds an observer. |
protected java.lang.Object |
clone()
Clones this object. |
boolean |
cloneObserverList()
Gives the observer-list cloning policy. |
boolean |
cloneObserverList(boolean newPolicy)
Changes the observer-list cloning policy. |
int |
countObservers()
Gives the number of observers of this object. |
void |
deleteObserver(java.util.Observer o)
Deletes an observer. |
void |
deleteObservers()
Clears the observer list. |
void |
notifyObservers()
If this object is marked as changed (hasChanged() returns true), mark itself as unchanged (with clearChanged()), and then notify all of its observers. |
void |
notifyObservers(java.lang.Object arg)
If this object is marked as changed (hasChanged() returns true), mark itself as unchanged (with clearChanged()), and then notify all of its observers. |
Methods inherited from class java.util.Observable |
---|
clearChanged, hasChanged, setChanged |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CloneableObservable()
public CloneableObservable(boolean cloneObserverList)
cloneObserverList
- true if you want a clone to duplicate the
observer list of the original; false if you want the observer
list of a clone to be empty.Method Detail |
---|
protected java.lang.Object clone()
clone
in class java.lang.Object
public boolean cloneObserverList()
public boolean cloneObserverList(boolean newPolicy)
newPolicy
- true if you want a clone to duplicate the
observer list of the original; false if you want the observer
list of a clone to be empty.
public void addObserver(java.util.Observer o)
addObserver
in class java.util.Observable
o
- the observer.public void deleteObserver(java.util.Observer o)
deleteObserver
in class java.util.Observable
o
- the observer.public void deleteObservers()
deleteObservers
in class java.util.Observable
public void notifyObservers()
notifyObservers
in class java.util.Observable
Observable.hasChanged()
,
Observable.clearChanged()
,
Observer.update(java.util.Observable, java.lang.Object)
public void notifyObservers(java.lang.Object arg)
notifyObservers
in class java.util.Observable
arg
- the second parameter to be passed to update() methods of
observers.Observable.hasChanged()
,
Observable.clearChanged()
,
Observer.update(java.util.Observable, java.lang.Object)
public int countObservers()
countObservers
in class java.util.Observable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |