|
QJCC homepage | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.Observable biz.chitec.quarterback.util.Controllable
"Brain" class. Mixture of Observable and Map. A controllable holds objects and flags. Moreover, it's an Observable, so it holds (GUI) object references of (GUI) objects that want to be informed of changes of the state of this Controllable.
Anyone can put (or change) objects into the Controllable (though most times this will be done through one of the Controllers of the Controllable). If appropriate, anyone can call notifyObservers() which will propagate the new state(s) of the Controllable to all registered Controllers by calling their update() method.
Controllers can check by calling hasChanged() if the state of a certain property has changed since the last notifyObservers(). A property can be obtained by calling get().
It must be noted that get() returns (a pointer to) the object actually stored by the Controllable. If a controller wants to make changes to this object, it is very strongly recommended to make a copy of it first. Otherwise, the object stored in the Controllable will be changed, which will cause predictable but almost certainly unwanted results. Once again: MAKE A COPY BEFORE CHANGING THE RESULT OF get()! If you change the object (and know what you do!) you can normalize the Controller's state by calling setChanged() for the changed object explicitily.
Controllables can be stacked: If get() would return null (no object found) and there is a father-Controllable, get() of that one is called. Note that changes are (in the moment) not propagated through the Controllable hierarchy.
A Controllable supports also "flags", these can be set or reset using (re)setFlag() and checked using getFlag(). Flags are always cleared after a notifyObservers(). Flags are not propagated through the hierarchy.
Field Summary | |
protected Controllable |
father
|
protected java.util.Map |
mychanges
|
protected java.util.Map |
mydata
|
protected java.util.Map |
myflags
|
protected boolean |
notifying
|
protected boolean |
renotify
|
protected java.util.List |
sons
|
Fields inherited from class java.util.Observable |
|
Constructor Summary | |
Controllable()
init the Controllable. |
Method Summary | |
boolean |
containsKey(java.lang.String key)
Return whether there is a property "key" or not. |
boolean |
containsKey(java.lang.String key,
boolean askfather)
Return whether there is a property "key" or not. |
protected void |
fatherChanged(java.lang.String key)
|
java.lang.Object |
get(java.lang.String key)
return a stored object. |
Controllable |
getFather()
|
boolean |
getFlag(java.lang.String key)
return the state of a flag. |
boolean |
hasChanged(java.lang.String key)
return if the state of a certain property has changed. |
protected void |
informSonsOfChange(java.lang.String key)
|
void |
invalidateFather()
|
java.util.Iterator |
keys()
returns all available keys. |
void |
notifyObservers()
notify all observers. |
void |
notifyObservers(java.lang.Object arg)
notify all observers. |
java.lang.Object |
put(java.lang.String key,
java.lang.Object value)
put a property into the Controllable. |
java.lang.Object |
remove(java.lang.String key)
remove a property from the Controllable. |
protected void |
removeSon(Controllable s)
|
void |
resetFlag(java.lang.String key)
reset a flag explicitly. |
void |
setChanged(java.lang.String key)
set the changed flag for an object explicitily. |
void |
setFather(Controllable f)
set a father which is asked when a value is not found in this controllable |
void |
setFlag(java.lang.String key)
set a flag. |
protected void |
setSon(Controllable s)
|
java.lang.String |
toString()
|
Methods inherited from class java.util.Observable |
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, setChanged |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.util.Map mydata
protected java.util.Map mychanges
protected java.util.Map myflags
protected java.util.List sons
protected boolean notifying
protected boolean renotify
protected Controllable father
Constructor Detail |
public Controllable()
Method Detail |
protected void setSon(Controllable s)
protected void removeSon(Controllable s)
public void setFather(Controllable f)
public void invalidateFather()
public Controllable getFather()
protected void fatherChanged(java.lang.String key)
protected void informSonsOfChange(java.lang.String key)
public java.lang.Object put(java.lang.String key, java.lang.Object value)
public void setFlag(java.lang.String key)
public void resetFlag(java.lang.String key)
public void setChanged(java.lang.String key)
public java.lang.Object get(java.lang.String key)
public boolean getFlag(java.lang.String key)
public boolean hasChanged(java.lang.String key)
public boolean containsKey(java.lang.String key)
key
- The key to ask for.
public boolean containsKey(java.lang.String key, boolean askfather)
key
- The key to search.askfather
- Flag to indicate whether father should be asked.
public java.util.Iterator keys()
public void notifyObservers()
public void notifyObservers(java.lang.Object arg)
public java.lang.Object remove(java.lang.String key)
public java.lang.String toString()
|
QJCC homepage | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |