1
2
3
4
5
6
7 package org.asyrinx.joey.gen.model.command;
8
9 import java.util.ArrayList;
10 import java.util.Iterator;
11 import java.util.List;
12
13 import org.asyrinx.joey.gen.model.Element;
14
15 /***
16 * @author akima
17 */
18 public class CompositeCommand extends Command {
19
20 /***
21 *
22 */
23 public CompositeCommand() {
24 super();
25 }
26
27
28
29
30
31
32 public void execute(Element element) {
33 for (Iterator i = this.iterator(); i.hasNext();) {
34 final Command command = (Command) i.next();
35 command.execute(element);
36 }
37 }
38
39 private final List commands = new ArrayList();
40
41 /***
42 * @param o
43 * @return
44 */
45 public boolean add(Command o) {
46 return commands.add(o);
47 }
48
49 /***
50 *
51 */
52 public void clear() {
53 commands.clear();
54 }
55
56 /***
57 * @param o
58 * @return
59 */
60 public boolean contains(Command o) {
61 return commands.contains(o);
62 }
63
64 /***
65 * @param index
66 * @return
67 */
68 public Command get(int index) {
69 return (Command) commands.get(index);
70 }
71
72 /***
73 * @param o
74 * @return
75 */
76 public int indexOf(Command o) {
77 return commands.indexOf(o);
78 }
79
80 /***
81 * @return
82 */
83 public boolean isEmpty() {
84 return commands.isEmpty();
85 }
86
87 /***
88 * @return
89 */
90 public Iterator iterator() {
91 return commands.iterator();
92 }
93
94 /***
95 * @param o
96 * @return
97 */
98 public boolean remove(Command o) {
99 return commands.remove(o);
100 }
101
102 /***
103 * @return
104 */
105 public int size() {
106 return commands.size();
107 }
108
109 }