01: package jimm.datavision.gui.cmd;
02:
03: /**
04: * An abstract adapter class for performing a command. It exists as a
05: * convenience for creating command objects. The perform and undo methods
06: * in this class are empty. <code>redo</code> calls <code>perform</code>.
07: *
08: * The <code>getName</code> method provides read-only access to the name
09: * provided at construction time. The <code>setName</code> method does
10: * nothing.
11: *
12: * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
13: */
14: public abstract class CommandAdapter implements Command {
15:
16: protected String name;
17:
18: public CommandAdapter(String name) {
19: this .name = name;
20: }
21:
22: public String getName() {
23: return name;
24: }
25:
26: /** A command's name is immutable. */
27: public void setName(String name) {
28: }
29:
30: /** Performs the command. The default implementation does nothing. */
31: public void perform() {
32: }
33:
34: /** Undoes the command. The default implementation does nothing. */
35: public void undo() {
36: }
37:
38: /** Redoes the command by calling {@link #perform}. */
39: public void redo() {
40: perform();
41: }
42:
43: }
|