source: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/windows/commands/CMDparseXML.java

Last change on this file was 413, checked in by sherbold, 13 years ago
  • changed equals method of de.ugoe.cs.eventbench.windows.data.WindowsEvent? to be able to better identify equal widgets throughout multiple sessions. To this aim, the class de.ugoe.cs.eventbench.windows.data.MFCTargetComparator has been introduced to compare the target strings of WindowsEvents?.
  • changed parseXML to set up the MFCTargetComparator
File size: 2.5 KB
Line 
1package de.ugoe.cs.eventbench.windows.commands;
2
3import java.security.InvalidParameterException;
4import java.util.Collection;
5import java.util.List;
6import java.util.SortedSet;
7
8import de.ugoe.cs.eventbench.CommandHelpers;
9import de.ugoe.cs.eventbench.data.GlobalDataContainer;
10import de.ugoe.cs.eventbench.windows.MFCLogParser;
11import de.ugoe.cs.eventbench.windows.data.MFCTargetComparator;
12import de.ugoe.cs.eventbench.windows.data.WindowTree;
13import de.ugoe.cs.eventbench.windows.data.WindowsEvent;
14import de.ugoe.cs.util.console.Command;
15import de.ugoe.cs.util.console.Console;
16
17/**
18 * <p>
19 * Command to parse an XML file with sessions monitored by EventBench's
20 * MFCUsageMonitor.
21 * </p>
22 *
23 * @author Steffen Herbold
24 * @version 1.0
25 */
26public class CMDparseXML implements Command {
27
28        /*
29         * (non-Javadoc)
30         *
31         * @see de.ugoe.cs.util.console.Command#help()
32         */
33        @Override
34        public void help() {
35                Console.println("Usage: parseXML <filename> {<sequencesName>} {<countMessageOccurences>}");
36        }
37
38        /*
39         * (non-Javadoc)
40         *
41         * @see de.ugoe.cs.util.console.Command#run(java.util.List)
42         */
43        @Override
44        public void run(List<Object> parameters) {
45                String filename;
46                String sequencesName = "sequences";
47                boolean countMessageOccurences = false;
48
49                try {
50                        filename = (String) parameters.get(0);
51                        if (parameters.size() >= 2) {
52                                sequencesName = (String) parameters.get(1);
53                        }
54                        if (parameters.size() >= 3) {
55                                countMessageOccurences = Boolean
56                                                .parseBoolean((String) parameters.get(2));
57                        }
58                } catch (Exception e) {
59                        throw new InvalidParameterException();
60                }
61
62                MFCLogParser parser = new MFCLogParser(countMessageOccurences);
63                parser.parseFile(filename);
64
65                Collection<List<WindowsEvent>> sequences = parser.getSequences();
66               
67                Console.traceln("Pre-computing event target equalities.");
68                // compare all Events to a dummy event to make sure they are known by
69                // the MFCTargetComparator
70                WindowsEvent dummyEvent = new WindowsEvent("dummy");
71                for (List<WindowsEvent> sequence : sequences) {
72                        for (WindowsEvent event : sequence) {
73                                event.equals(dummyEvent);
74                        }
75                }
76                MFCTargetComparator.setMutable(false);
77               
78                SortedSet<String> targets = WindowTree.getInstance().getTargets();
79
80                if (GlobalDataContainer.getInstance().addData(sequencesName, sequences)) {
81                        CommandHelpers.dataOverwritten(sequencesName);
82                }
83                if (GlobalDataContainer.getInstance().addData(
84                                sequencesName + "_targets", targets)) {
85                        CommandHelpers.dataOverwritten(sequencesName + "_targets");
86                }
87        }
88
89}
Note: See TracBrowser for help on using the repository browser.