source: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDgenerateReplayfile.java @ 234

Last change on this file since 234 was 209, checked in by sherbold, 13 years ago
  • greatly improved type checking and consistency of type checking for objects checked out of the GlobalDataContainer?
File size: 1.9 KB
Line 
1package de.ugoe.cs.eventbench.commands;
2
3import java.security.InvalidParameterException;
4import java.util.Collection;
5import java.util.List;
6
7import de.ugoe.cs.eventbench.ReplayGenerator;
8import de.ugoe.cs.eventbench.SequenceInstanceOf;
9import de.ugoe.cs.eventbench.data.GlobalDataContainer;
10import de.ugoe.cs.eventbench.data.ReplayableEvent;
11import de.ugoe.cs.util.console.Command;
12import de.ugoe.cs.util.console.Console;
13
14/**
15 * <p>
16 * Command to create a replay file from stored sessions.
17 * </p>
18 *
19 * @author Steffen Herbold
20 * @version 1.0
21 */
22public class CMDgenerateReplayfile implements Command {
23
24        /*
25         * (non-Javadoc)
26         *
27         * @see de.ugoe.cs.util.console.Command#help()
28         */
29        @Override
30        public void help() {
31                Console.println("Usage: generateReplayfile <filename> {<sequences>}");
32        }
33
34        /*
35         * (non-Javadoc)
36         *
37         * @see de.ugoe.cs.util.console.Command#run(java.util.List)
38         */
39        @SuppressWarnings("unchecked")
40        @Override
41        public void run(List<Object> parameters) {
42                if (parameters.size() < 1) {
43                        throw new InvalidParameterException();
44                }
45                String filename = (String) parameters.get(0);
46                String sequencesName = "sequences";
47                if (parameters.size() == 2) {
48                        sequencesName = (String) parameters.get(1);
49                }
50
51                Collection<List<ReplayableEvent<?>>> sequences = null;
52                Object dataObject = GlobalDataContainer.getInstance().getData(
53                                sequencesName);
54                if (dataObject == null) {
55                        Console.println("Object " + sequencesName
56                                        + " not found in storage.");
57                        return;
58                }
59                if (!SequenceInstanceOf.isCollectionOfSequences(dataObject)) {
60                        Console.println("Object " + sequencesName
61                                        + "not of type Collection<List<Event<?>>>.");
62                        return;
63                }
64
65                sequences = (Collection<List<ReplayableEvent<?>>>) dataObject;
66                ReplayGenerator generator = new ReplayGenerator();
67                generator.createLogfileMultipleSessions(sequences, filename);
68        }
69
70}
Note: See TracBrowser for help on using the repository browser.