KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jimm > datavision > gui > cmd > CommandAdapter


1 package jimm.datavision.gui.cmd;
2
3 /**
4  * An abstract adapter class for performing a command. It exists as a
5  * convenience for creating command objects. The perform and undo methods
6  * in this class are empty. <code>redo</code> calls <code>perform</code>.
7  *
8  * The <code>getName</code> method provides read-only access to the name
9  * 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 JavaDoc name;
17
18 public CommandAdapter(String JavaDoc name) {
19     this.name = name;
20 }
21
22 public String JavaDoc getName() { return name; }
23
24 /** A command's name is immutable. */
25 public void setName(String JavaDoc name) { }
26
27 /** Performs the command. The default implementation does nothing. */
28 public void perform() { }
29
30 /** Undoes the command. The default implementation does nothing. */
31 public void undo() { }
32
33 /** Redoes the command by calling {@link #perform}. */
34 public void redo() {
35     perform();
36 }
37
38 }
39
Popular Tags