source: trunk/autoquest-plugin-mfc/src/main/java/de/ugoe/cs/autoquest/plugin/mfc/commands/CMDparseXML.java @ 927

Last change on this file since 927 was 927, checked in by sherbold, 12 years ago
  • added copyright under the Apache License, Version 2.0
File size: 2.8 KB
Line 
1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
15package de.ugoe.cs.autoquest.plugin.mfc.commands;
16
17import java.util.Collection;
18import java.util.List;
19
20import de.ugoe.cs.autoquest.CommandHelpers;
21import de.ugoe.cs.autoquest.eventcore.Event;
22import de.ugoe.cs.autoquest.eventcore.guimodel.GUIModel;
23import de.ugoe.cs.autoquest.plugin.mfc.MFCLogParser;
24import de.ugoe.cs.util.console.Command;
25import de.ugoe.cs.util.console.GlobalDataContainer;
26
27/**
28 * <p>
29 * Command to parse an XML file with sessions monitored by EventBench's MFCUsageMonitor.
30 * </p>
31 *
32 * @author Steffen Herbold
33 * @version 1.0
34 */
35public class CMDparseXML implements Command {
36
37    /*
38     * (non-Javadoc)
39     *
40     * @see de.ugoe.cs.util.console.Command#help()
41     */
42    @Override
43    public String help() {
44        return "parseXML <filename> {<sequencesName>} {<countMessageOccurences>}";
45    }
46
47    /*
48     * (non-Javadoc)
49     *
50     * @see de.ugoe.cs.util.console.Command#run(java.util.List)
51     */
52    @Override
53    public void run(List<Object> parameters) {
54        String filename;
55        String sequencesName = "sequences";
56        boolean countMessageOccurences = false;
57
58        try {
59            filename = (String) parameters.get(0);
60            if (parameters.size() >= 2) {
61                sequencesName = (String) parameters.get(1);
62            }
63            if (parameters.size() >= 3) {
64                countMessageOccurences = Boolean.parseBoolean((String) parameters.get(2));
65            }
66        }
67        catch (Exception e) {
68            throw new IllegalArgumentException();
69        }
70
71        MFCLogParser parser = new MFCLogParser(countMessageOccurences);
72        parser.parseFile(filename);
73
74        Collection<List<Event>> sequences = parser.getSequences();
75
76        GUIModel targets = parser.getGuiModel();
77
78        if (GlobalDataContainer.getInstance().addData(sequencesName, sequences)) {
79            CommandHelpers.dataOverwritten(sequencesName);
80        }
81        if (GlobalDataContainer.getInstance().addData(sequencesName + "_targets", targets)) {
82            CommandHelpers.dataOverwritten(sequencesName + "_targets");
83        }
84    }
85
86}
Note: See TracBrowser for help on using the repository browser.