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
RevLine 
[52]1package de.ugoe.cs.eventbench.windows.commands;
[1]2
3import java.security.InvalidParameterException;
[203]4import java.util.Collection;
[1]5import java.util.List;
[229]6import java.util.SortedSet;
[1]7
[240]8import de.ugoe.cs.eventbench.CommandHelpers;
[1]9import de.ugoe.cs.eventbench.data.GlobalDataContainer;
[297]10import de.ugoe.cs.eventbench.windows.MFCLogParser;
[413]11import de.ugoe.cs.eventbench.windows.data.MFCTargetComparator;
[229]12import de.ugoe.cs.eventbench.windows.data.WindowTree;
[198]13import de.ugoe.cs.eventbench.windows.data.WindowsEvent;
[1]14import de.ugoe.cs.util.console.Command;
15import de.ugoe.cs.util.console.Console;
16
[171]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 */
[1]26public class CMDparseXML implements Command {
27
[183]28        /*
29         * (non-Javadoc)
30         *
[171]31         * @see de.ugoe.cs.util.console.Command#help()
32         */
[1]33        @Override
34        public void help() {
[183]35                Console.println("Usage: parseXML <filename> {<sequencesName>} {<countMessageOccurences>}");
[1]36        }
37
[183]38        /*
39         * (non-Javadoc)
40         *
[171]41         * @see de.ugoe.cs.util.console.Command#run(java.util.List)
42         */
[1]43        @Override
44        public void run(List<Object> parameters) {
45                String filename;
[183]46                String sequencesName = "sequences";
[1]47                boolean countMessageOccurences = false;
[171]48
[1]49                try {
50                        filename = (String) parameters.get(0);
[183]51                        if (parameters.size() >= 2) {
52                                sequencesName = (String) parameters.get(1);
53                        }
54                        if (parameters.size() >= 3) {
[171]55                                countMessageOccurences = Boolean
[183]56                                                .parseBoolean((String) parameters.get(2));
[1]57                        }
58                } catch (Exception e) {
59                        throw new InvalidParameterException();
60                }
[171]61
[297]62                MFCLogParser parser = new MFCLogParser(countMessageOccurences);
[1]63                parser.parseFile(filename);
[171]64
[203]65                Collection<List<WindowsEvent>> sequences = parser.getSequences();
[413]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               
[229]78                SortedSet<String> targets = WindowTree.getInstance().getTargets();
[171]79
[183]80                if (GlobalDataContainer.getInstance().addData(sequencesName, sequences)) {
[240]81                        CommandHelpers.dataOverwritten(sequencesName);
[171]82                }
[240]83                if (GlobalDataContainer.getInstance().addData(
84                                sequencesName + "_targets", targets)) {
85                        CommandHelpers.dataOverwritten(sequencesName + "_targets");
[229]86                }
[1]87        }
88
89}
Note: See TracBrowser for help on using the repository browser.