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

Last change on this file since 204 was 203, checked in by sherbold, 13 years ago
  • Changed data type for handling of sequence-sets. Before, List<List<Event<?>>> was used, now Collection<List<Event<?>>> is used.
File size: 2.1 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.data.Event;
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>Command to create a replay file from stored sessions.</p>
16 * @author Steffen Herbold
17 * @version 1.0
18 */
19public class CMDgenerateReplayfile implements Command {
20
21        /* (non-Javadoc)
22         * @see de.ugoe.cs.util.console.Command#help()
23         */
24        @Override
25        public void help() {
26                Console.println("Usage: generateReplayfile <filename> {<sequences>}");         
27        }
28
29        /* (non-Javadoc)
30         * @see de.ugoe.cs.util.console.Command#run(java.util.List)
31         */
32        @SuppressWarnings("unchecked")
33        @Override
34        public void run(List<Object> parameters) {
35                if( parameters.size() < 1 ) {
36                        throw new InvalidParameterException();
37                }
38                String filename = (String) parameters.get(0);
39                String sequencesName = "sequences";
40                if( parameters.size()==2 ) {
41                        sequencesName = (String) parameters.get(1);
42                }
43               
44                Collection<List<ReplayableEvent<?>>> sequences = null;
45                Object dataObject = GlobalDataContainer.getInstance().getData(sequencesName);
46                       
47                try {
48                        sequences = (Collection<List<ReplayableEvent<?>>>) dataObject;
49                        ReplayGenerator generator = new ReplayGenerator();
50                        if( sequences!=null && sequences.size()>0 && sequences.iterator().next().get(0) instanceof Event ) {
51                                generator.createLogfileMultipleSessions(sequences, filename);
52                        } else {
53                                Console.printerrln("Loaded data not are not sequences!");
54                                if( sequencesName.equals("sequences") ) {
55                                        Console.traceln("Illegal use of \"sequences\" parameter in the GlobalDataContainer.");
56                                        Console.traceln("The parameter should always be of type Collection<List<Event>>!");
57                                }
58                        }
59                }
60                catch(ClassCastException e) {
61                        Console.printerrln("Sequences not found");
62                }
63               
64        }
65
66}
Note: See TracBrowser for help on using the repository browser.