Thomas Fritsch wrote:
>
> // Stripped-down example for undo/redoable class:
....
> // Implementation of StateEditable is simple again
// Implementation od StateEditable is not so simple

> public void storeState(Hashtable savedState) {
> if (a != null)
> savedState.put("a", a);
> savedState.put("b", new Integer(b));
> savedState.put("c", new Float(c));
> //...
> }
> public void restoreState(Hashtable savedState) {
> a = (String) savedState.get("a");
> b = ((Integer) savedState.get("b")).intValue();
> c = ((Double) savedState.get("c")).doubleValue();
> //...
> }
public void restoreState(Hashtable savedState) {
// Be careful, because StateEdit may have optimized
// the Hashtable by removing the redundant entries
// which didn't change during the edit:
if (savedState.containsKey("a"))
a = (String) savedState.get("a");
if (savedState.containsKey("b"))
b = ((Integer) savedState.get("b")).intValue();
if (savedState.containsKey("c"))
c = ((Double) savedState.get("c")).doubleValue();
}
....
--
Thomas<dot>Fritsch<squiggle>ops<dot>de