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

Last change on this file since 171 was 171, checked in by sherbold, 13 years ago
  • code documentation and formatting
File size: 1.5 KB
Line 
1package de.ugoe.cs.eventbench.windows.commands;
2
3import java.security.InvalidParameterException;
4import java.util.List;
5
6import de.ugoe.cs.eventbench.data.GlobalDataContainer;
7import de.ugoe.cs.eventbench.windows.LogParser;
8import de.ugoe.cs.eventbench.windows.WindowsEvent;
9import de.ugoe.cs.util.console.Command;
10import de.ugoe.cs.util.console.Console;
11
12/**
13 * <p>
14 * Command to parse an XML file with sessions monitored by EventBench's
15 * MFCUsageMonitor.
16 * </p>
17 *
18 * @author Steffen Herbold
19 * @version 1.0
20 */
21public class CMDparseXML implements Command {
22
23        /* (non-Javadoc)
24         * @see de.ugoe.cs.util.console.Command#help()
25         */
26        @Override
27        public void help() {
28                Console.println("Usage: parseXML <filename> {<countMessageOccurences}");
29        }
30
31        /* (non-Javadoc)
32         * @see de.ugoe.cs.util.console.Command#run(java.util.List)
33         */
34        @Override
35        public void run(List<Object> parameters) {
36                String filename;
37                boolean countMessageOccurences = false;
38
39                try {
40                        filename = (String) parameters.get(0);
41                        if (parameters.size() == 2) {
42                                countMessageOccurences = Boolean
43                                                .parseBoolean((String) parameters.get(1));
44                        }
45                } catch (Exception e) {
46                        throw new InvalidParameterException();
47                }
48
49                LogParser parser = new LogParser(countMessageOccurences);
50                parser.parseFile(filename);
51
52                List<List<WindowsEvent>> sequences = parser.getSequences();
53
54                if (GlobalDataContainer.getInstance().addData("sequences", sequences)) {
55                        Console.traceln("Old data \"" + "sequences" + "\" overwritten");
56                }
57        }
58
59}
Note: See TracBrowser for help on using the repository browser.