javax.swing.undo
Interface StateEditable


public interface StateEditable

The interface for objects whose state can be undone or redone by a StateEdit action.

The following example shows how to write a class that implements this interface.

 class Foo
   implements StateEditable
 {
   private String name;

   public void setName(String n) { name = n; }

   public void restoreState(Hashtable h)
   {
     if (h.containsKey("name"))
       setName((String) h.get("name"));
   }

   public void storeState(Hashtable s)
   {
     s.put("name", name);
   }
 }

See Also:
StateEdit

Field Summary
static String RCSID
          The ID of the Java source file in Sun’s Revision Control System (RCS).
 
Method Summary
 void restoreState(Hashtable<?,?> state)
          Performs an edit action, taking any editable state information from the specified hash table.
 void storeState(Hashtable<Object,Object> state)
          Stores any editable state information into the specified hash table.
 

Field Detail

RCSID

static final String RCSID
The ID of the Java source file in Sun’s Revision Control System (RCS). This certainly should not be part of the API specification. But in order to be API-compatible with Sun’s reference implementation, GNU Classpath also has to provide this field and match its value. The value used here has been in every JDK release at least from 1.2 to 1.5.

See Also:
Constant Field Values
Method Detail

restoreState

void restoreState(Hashtable<?,?> state)
Performs an edit action, taking any editable state information from the specified hash table.

Note to implementors of this interface: To increase efficiency, the StateEdit class StateEdit.removeRedundantState() removes redundant state information. Therefore, implementations of this interface must be prepared for the case where certain keys were stored into the table by storeState(java.util.Hashtable), but are not present anymore when the restoreState method gets called.

Parameters:
state - a hash table containing the relevant state information.

storeState

void storeState(Hashtable<Object,Object> state)
Stores any editable state information into the specified hash table.

Parameters:
state - a hash table for storing relevant state information.