1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package com.enspire.gemini.commands;
25
26 import java.util.LinkedList;
27 import java.util.List;
28
29 /***
30 * The basic implementation of <code>CommandExecutor</code>. Keeps executed
31 * commands in a <code>List</code>.
32 * @author Dragan Djuric <dragand@dev.java.net>
33 * @since 1.0
34 */
35 public class CommandExecutorImpl implements CommandExecutor {
36
37 private List executed = new LinkedList();
38
39 /***
40 * @see com.enspire.gemini.commands.CommandExecutor#execute(com.enspire.gemini.commands.Command)
41 */
42 public void execute(Command command) {
43 command.execute();
44 executed.add(command);
45 }
46
47 /***
48 * @see com.enspire.gemini.commands.CommandExecutor#undo()
49 */
50 public void undo() {
51 for (int i = executed.size() - 1; i > -1; i--) {
52 Command command = (Command)executed.get(i);
53 command.undo();
54 executed.remove(i);
55 }
56 }
57
58 }