source: trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/ui/commands/CMDgenerateReplayfile.java @ 664

Last change on this file since 664 was 664, checked in by sherbold, 12 years ago
  • modified Command.help(): the help now returns a string with its usage instead of writing directly to the console
  • modified listCommands: now writes the help string of each command instead of just the name; this way, the parameters are displayed directly
  • moved listCommands from quest-ui-core to java-utils
File size: 1.7 KB
RevLine 
[434]1package de.ugoe.cs.quest.ui.commands;
[1]2
3import java.security.InvalidParameterException;
[203]4import java.util.Collection;
[1]5import java.util.List;
6
[432]7import de.ugoe.cs.quest.CommandHelpers;
8import de.ugoe.cs.quest.ReplayGenerator;
9import de.ugoe.cs.quest.SequenceInstanceOf;
[547]10import de.ugoe.cs.quest.eventcore.Event;
[434]11import de.ugoe.cs.quest.ui.GlobalDataContainer;
[1]12import de.ugoe.cs.util.console.Command;
13
[171]14/**
[209]15 * <p>
16 * Command to create a replay file from stored sessions.
17 * </p>
18 *
[171]19 * @author Steffen Herbold
20 * @version 1.0
21 */
[1]22public class CMDgenerateReplayfile implements Command {
23
[209]24        /*
25         * (non-Javadoc)
26         *
[171]27         * @see de.ugoe.cs.util.console.Command#help()
28         */
[1]29        @Override
[664]30        public String help() {
31                return "generateReplayfile <filename> <sequences>";
[1]32        }
33
[209]34        /*
35         * (non-Javadoc)
36         *
[171]37         * @see de.ugoe.cs.util.console.Command#run(java.util.List)
38         */
[1]39        @SuppressWarnings("unchecked")
40        @Override
41        public void run(List<Object> parameters) {
[241]42                String filename;
43                String sequencesName;
44                try {
45                        filename = (String) parameters.get(0);
46                        sequencesName = (String) parameters.get(1);
47                } catch (Exception e) {
[1]48                        throw new InvalidParameterException();
49                }
[209]50
[547]51                Collection<List<Event>> sequences = null;
[209]52                Object dataObject = GlobalDataContainer.getInstance().getData(
53                                sequencesName);
54                if (dataObject == null) {
[240]55                        CommandHelpers.objectNotFoundMessage(sequencesName);
[209]56                        return;
[1]57                }
[209]58                if (!SequenceInstanceOf.isCollectionOfSequences(dataObject)) {
[240]59                        CommandHelpers.objectNotType(sequencesName,
60                                        "Collection<List<Event<?>>>");
[209]61                        return;
[1]62                }
[209]63
[547]64                sequences = (Collection<List<Event>>) dataObject;
[209]65                ReplayGenerator generator = new ReplayGenerator();
66                generator.createLogfileMultipleSessions(sequences, filename);
[1]67        }
68
69}
Note: See TracBrowser for help on using the repository browser.