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.data.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 | /*
|
---|
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 | }
|
---|