source: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/jfc/commands/CMDparseJFC.java @ 393

Last change on this file since 393 was 392, checked in by sherbold, 13 years ago
  • JFC pre-processors (commands preprocessDirJFC, preprocessJFC) now generate UTF-8 XML files instead of UTF-16.
  • de.ugoe.cs.eventbench.jfc.JFCLogParser adapted to read UTF-8 XML files instead of UTF-16.
  • parseDirJFC and parseJFC commands now both pre-compute all JFC event target equalities and furthermore compare all loaded events to a dummy event before the precomputation to make sure the events are known by de.ugoe.cs.eventbench.jfc.data.JFCTargetComparator.
  • Property svn:mime-type set to text/plain
File size: 2.0 KB
Line 
1package de.ugoe.cs.eventbench.jfc.commands;
2
3import java.security.InvalidParameterException;
4import java.util.Collection;
5import java.util.List;
6
7import de.ugoe.cs.eventbench.CommandHelpers;
8import de.ugoe.cs.eventbench.data.GlobalDataContainer;
9import de.ugoe.cs.eventbench.jfc.JFCLogParser;
10import de.ugoe.cs.eventbench.jfc.data.JFCEvent;
11import de.ugoe.cs.eventbench.jfc.data.JFCTargetComparator;
12import de.ugoe.cs.util.console.Command;
13import de.ugoe.cs.util.console.Console;
14
15/**
16 * <p>
17 * Command to parse an XML file with sessions monitored by EventBench's
18 * JFCMonitor.
19 * </p>
20 *
21 * @author Steffen Herbold
22 * @version 1.0
23 */
24public class CMDparseJFC implements Command {
25
26        /*
27         * (non-Javadoc)
28         *
29         * @see de.ugoe.cs.util.console.Command#run(java.util.List)
30         */
31        @Override
32        public void run(List<Object> parameters) {
33                String filename;
34                String sequencesName = "sequences";
35
36                try {
37                        filename = (String) parameters.get(0);
38                        if (parameters.size() >= 2) {
39                                sequencesName = (String) parameters.get(1);
40                        }
41                } catch (Exception e) {
42                        throw new InvalidParameterException();
43                }
44                JFCTargetComparator.setMutable(true);
45                JFCLogParser parser = new JFCLogParser();
46
47                parser.parseFile(filename);
48                Collection<List<JFCEvent>> sequences = parser.getSequences();
49
50                Console.traceln("Pre-computing event target equalities.");
51                // compare all Events to a dummy event to make sure they are known by
52                // the JFCTargetComparator
53                JFCEvent dummyEvent = new JFCEvent("dummy");
54                for (List<JFCEvent> sequence : sequences) {
55                        for (JFCEvent event : sequence) {
56                                event.equals(dummyEvent);
57                        }
58                }
59                JFCTargetComparator.setMutable(false);
60
61                if (GlobalDataContainer.getInstance().addData(sequencesName, sequences)) {
62                        CommandHelpers.dataOverwritten(sequencesName);
63                }
64        }
65
66        /*
67         * (non-Javadoc)
68         *
69         * @see de.ugoe.cs.util.console.Command#help()
70         */
71        @Override
72        public void help() {
73                Console.println("Usage: parseJFC <filename> {<sequencesName>}");
74        }
75
76}
Note: See TracBrowser for help on using the repository browser.