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

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