1 | package de.ugoe.cs.eventbench.windows.commands;
|
---|
2 |
|
---|
3 | import java.security.InvalidParameterException;
|
---|
4 | import java.util.List;
|
---|
5 |
|
---|
6 | import de.ugoe.cs.eventbench.data.GlobalDataContainer;
|
---|
7 | import de.ugoe.cs.eventbench.windows.LogParser;
|
---|
8 | import de.ugoe.cs.eventbench.windows.WindowsEvent;
|
---|
9 | import de.ugoe.cs.util.console.Command;
|
---|
10 | import 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 | */
|
---|
21 | public 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 | }
|
---|