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

Last change on this file since 359 was 353, checked in by sherbold, 13 years ago
  • added commands parseDirJFC and preprocessDirJFC
  • adapted de.ugoe.cs.eventbench.jfc.JFCLogParser such that one instance of the parser can correctly process multiple files
  • Property svn:mime-type set to text/plain
File size: 2.0 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.util.console.Command;
13import de.ugoe.cs.util.console.Console;
14
15/**
16 * <p>
17 * Command that tries to parse all files in a folder as if they were log files
18 * generated by the JFCMonitor. The result is one set of sequences for all files
19 * (not one set of sequences for each file!).
20 * </p>
21 *
22 * @author Steffen Herbold
23 * @version 1.0
24 */
25public class CMDparseDirJFC implements Command {
26
27        /*
28         * (non-Javadoc)
29         *
30         * @see de.ugoe.cs.util.console.Command#run(java.util.List)
31         */
32        @Override
33        public void run(List<Object> parameters) {
34                String path;
35                String sequencesName = "sequences";
36
37                try {
38                        path = (String) parameters.get(0);
39                        if (parameters.size() >= 2) {
40                                sequencesName = (String) parameters.get(1);
41                        }
42                } catch (Exception e) {
43                        throw new InvalidParameterException();
44                }
45
46                File folder = new File(path);
47                if (!folder.isDirectory()) {
48                        Console.printerrln(path + " is not a directory");
49                }
50
51                JFCLogParser parser = new JFCLogParser();
52
53                String absolutPath = folder.getAbsolutePath();
54                for (String filename : folder.list()) {
55                        String source = absolutPath + "/" + filename;
56                        Console.traceln("Processing file: " + source);
57
58                        parser.parseFile(source);
59                }
60
61                Collection<List<JFCEvent>> sequences = parser.getSequences();
62
63                if (GlobalDataContainer.getInstance().addData(sequencesName, sequences)) {
64                        CommandHelpers.dataOverwritten(sequencesName);
65                }
66
67        }
68
69        /*
70         * (non-Javadoc)
71         *
72         * @see de.ugoe.cs.util.console.Command#help()
73         */
74        @Override
75        public void help() {
76                Console.println("Usage: parseDirJFC <path> {<sequencesName>}");
77        }
78
79}
Note: See TracBrowser for help on using the repository browser.