1 | package de.ugoe.cs.eventbench.jfc.commands;
|
---|
2 |
|
---|
3 | import java.security.InvalidParameterException;
|
---|
4 | import java.util.Collection;
|
---|
5 | import java.util.List;
|
---|
6 |
|
---|
7 | import de.ugoe.cs.eventbench.CommandHelpers;
|
---|
8 | import de.ugoe.cs.eventbench.data.GlobalDataContainer;
|
---|
9 | import de.ugoe.cs.eventbench.jfc.JFCLogParser;
|
---|
10 | import de.ugoe.cs.eventbench.jfc.data.JFCEvent;
|
---|
11 | import de.ugoe.cs.util.console.Command;
|
---|
12 | import de.ugoe.cs.util.console.Console;
|
---|
13 |
|
---|
14 | /**
|
---|
15 | * <p>
|
---|
16 | * Command to parse an XML file with sessions monitored by EventBench's
|
---|
17 | * JFCMonitor.
|
---|
18 | * </p>
|
---|
19 | *
|
---|
20 | * @author Steffen Herbold
|
---|
21 | * @version 1.0
|
---|
22 | */
|
---|
23 | public class CMDparseJFC implements Command {
|
---|
24 |
|
---|
25 | /*
|
---|
26 | * (non-Javadoc)
|
---|
27 | *
|
---|
28 | * @see de.ugoe.cs.util.console.Command#run(java.util.List)
|
---|
29 | */
|
---|
30 | @Override
|
---|
31 | public void run(List<Object> parameters) {
|
---|
32 | String filename;
|
---|
33 | String sequencesName = "sequences";
|
---|
34 |
|
---|
35 | try {
|
---|
36 | filename = (String) parameters.get(0);
|
---|
37 | if (parameters.size() >= 2) {
|
---|
38 | sequencesName = (String) parameters.get(1);
|
---|
39 | }
|
---|
40 | } catch (Exception e) {
|
---|
41 | throw new InvalidParameterException();
|
---|
42 | }
|
---|
43 |
|
---|
44 | JFCLogParser parser = new JFCLogParser();
|
---|
45 |
|
---|
46 | parser.parseFile(filename);
|
---|
47 |
|
---|
48 | Collection<List<JFCEvent>> sequences = parser.getSequences();
|
---|
49 |
|
---|
50 | if (GlobalDataContainer.getInstance().addData(sequencesName, sequences)) {
|
---|
51 | CommandHelpers.dataOverwritten(sequencesName);
|
---|
52 | }
|
---|
53 | }
|
---|
54 |
|
---|
55 | /*
|
---|
56 | * (non-Javadoc)
|
---|
57 | *
|
---|
58 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
59 | */
|
---|
60 | @Override
|
---|
61 | public void help() {
|
---|
62 | Console.println("Usage: parseJFC <filename> {<sequencesName>}");
|
---|
63 | }
|
---|
64 |
|
---|
65 | }
|
---|