source: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/jfc/commands/CMDparseDirJFC.java @ 396

Last change on this file since 396 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.5 KB
Line 
1package de.ugoe.cs.eventbench.jfc.commands;
2
3import java.io.File;
4import java.security.InvalidParameterException;
5import java.util.Collection;
6import java.util.List;
7
8import de.ugoe.cs.eventbench.CommandHelpers;
9import de.ugoe.cs.eventbench.data.GlobalDataContainer;
10import de.ugoe.cs.eventbench.jfc.JFCLogParser;
11import de.ugoe.cs.eventbench.jfc.data.JFCEvent;
12import de.ugoe.cs.eventbench.jfc.data.JFCTargetComparator;
13import de.ugoe.cs.util.console.Command;
14import de.ugoe.cs.util.console.Console;
15
16/**
17 * <p>
18 * Command that tries to parse all files in a folder as if they were log files
19 * generated by the JFCMonitor. The result is one set of sequences for all files
20 * (not one set of sequences for each file!).
21 * </p>
22 *
23 * @author Steffen Herbold
24 * @version 1.0
25 */
26public class CMDparseDirJFC implements Command {
27
28        /*
29         * (non-Javadoc)
30         *
31         * @see de.ugoe.cs.util.console.Command#run(java.util.List)
32         */
33        @Override
34        public void run(List<Object> parameters) {
35                String path;
36                String sequencesName = "sequences";
37
38                try {
39                        path = (String) parameters.get(0);
40                        if (parameters.size() >= 2) {
41                                sequencesName = (String) parameters.get(1);
42                        }
43                } catch (Exception e) {
44                        throw new InvalidParameterException();
45                }
46
47                File folder = new File(path);
48                if (!folder.isDirectory()) {
49                        Console.printerrln(path + " is not a directory");
50                        return;
51                }
52
53                JFCTargetComparator.setMutable(true);
54                JFCLogParser parser = new JFCLogParser();
55
56                String absolutPath = folder.getAbsolutePath();
57                for (String filename : folder.list()) {
58                        String source = absolutPath + "/" + filename;
59                        Console.traceln("Processing file: " + source);
60
61                        parser.parseFile(source);
62                }
63
64                Collection<List<JFCEvent>> sequences = parser.getSequences();
65                Console.traceln("Pre-computing event target equalities.");
66                // compare all Events to a dummy event to make sure they are known by
67                // the JFCTargetComparator
68                JFCEvent dummyEvent = new JFCEvent("dummy");
69                for (List<JFCEvent> sequence : sequences) {
70                        for (JFCEvent event : sequence) {
71                                event.equals(dummyEvent);
72                        }
73                }
74                JFCTargetComparator.setMutable(false);
75
76                if (GlobalDataContainer.getInstance().addData(sequencesName, sequences)) {
77                        CommandHelpers.dataOverwritten(sequencesName);
78                }
79
80        }
81
82        /*
83         * (non-Javadoc)
84         *
85         * @see de.ugoe.cs.util.console.Command#help()
86         */
87        @Override
88        public void help() {
89                Console.println("Usage: parseDirJFC <path> {<sequencesName>}");
90        }
91
92}
Note: See TracBrowser for help on using the repository browser.