source: trunk/quest-plugin-mfc/src/main/java/de/ugoe/cs/quest/plugin/mfc/commands/CMDparseXML.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: 2.2 KB
RevLine 
[434]1package de.ugoe.cs.quest.plugin.mfc.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;
[566]8import de.ugoe.cs.quest.eventcore.Event;
[619]9import de.ugoe.cs.quest.eventcore.guimodel.GUIModel;
[434]10import de.ugoe.cs.quest.plugin.mfc.MFCLogParser;
11import de.ugoe.cs.quest.ui.GlobalDataContainer;
[1]12import de.ugoe.cs.util.console.Command;
13
[171]14/**
15 * <p>
[619]16 * Command to parse an XML file with sessions monitored by EventBench's MFCUsageMonitor.
[171]17 * </p>
18 *
19 * @author Steffen Herbold
20 * @version 1.0
21 */
[1]22public class CMDparseXML implements Command {
23
[619]24    /*
25     * (non-Javadoc)
26     *
27     * @see de.ugoe.cs.util.console.Command#help()
28     */
29    @Override
[664]30    public String help() {
31        return "parseXML <filename> {<sequencesName>} {<countMessageOccurences>}";
[619]32    }
[1]33
[619]34    /*
35     * (non-Javadoc)
36     *
37     * @see de.ugoe.cs.util.console.Command#run(java.util.List)
38     */
39    @Override
40    public void run(List<Object> parameters) {
41        String filename;
42        String sequencesName = "sequences";
43        boolean countMessageOccurences = false;
[171]44
[619]45        try {
46            filename = (String) parameters.get(0);
47            if (parameters.size() >= 2) {
48                sequencesName = (String) parameters.get(1);
49            }
50            if (parameters.size() >= 3) {
51                countMessageOccurences = Boolean.parseBoolean((String) parameters.get(2));
52            }
53        }
54        catch (Exception e) {
55            throw new InvalidParameterException();
56        }
[171]57
[619]58        MFCLogParser parser = new MFCLogParser(countMessageOccurences);
59        parser.parseFile(filename);
[171]60
[619]61        Collection<List<Event>> sequences = parser.getSequences();
[171]62
[619]63        GUIModel targets = parser.getGuiModel();
[1]64
[619]65        if (GlobalDataContainer.getInstance().addData(sequencesName, sequences)) {
66            CommandHelpers.dataOverwritten(sequencesName);
67        }
68        if (GlobalDataContainer.getInstance().addData(sequencesName + "_targets", targets)) {
69            CommandHelpers.dataOverwritten(sequencesName + "_targets");
70        }
71    }
72
[1]73}
Note: See TracBrowser for help on using the repository browser.