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

Last change on this file since 188 was 183, checked in by sherbold, 13 years ago
  • changed commands for reading sequences to accept a parameter that defines the storage name for these sequences; default: "sequences"
File size: 1.7 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        /*
24         * (non-Javadoc)
25         *
26         * @see de.ugoe.cs.util.console.Command#help()
27         */
28        @Override
29        public void help() {
30                Console.println("Usage: parseXML <filename> {<sequencesName>} {<countMessageOccurences>}");
31        }
32
33        /*
34         * (non-Javadoc)
35         *
36         * @see de.ugoe.cs.util.console.Command#run(java.util.List)
37         */
38        @Override
39        public void run(List<Object> parameters) {
40                String filename;
41                String sequencesName = "sequences";
42                boolean countMessageOccurences = false;
43
44                try {
45                        filename = (String) parameters.get(0);
46                        if (parameters.size() >= 2) {
47                                sequencesName = (String) parameters.get(1);
48                        }
49                        if (parameters.size() >= 3) {
50                                countMessageOccurences = Boolean
51                                                .parseBoolean((String) parameters.get(2));
52                        }
53                } catch (Exception e) {
54                        throw new InvalidParameterException();
55                }
56
57                LogParser parser = new LogParser(countMessageOccurences);
58                parser.parseFile(filename);
59
60                List<List<WindowsEvent>> sequences = parser.getSequences();
61
62                if (GlobalDataContainer.getInstance().addData(sequencesName, sequences)) {
63                        Console.traceln("Old data \"" + sequencesName + "\" overwritten");
64                }
65        }
66
67}
Note: See TracBrowser for help on using the repository browser.