Repository navigation
Expand file tree
/
Copy pathApp.java
More file actions
60 lines (52 loc) · 1.71 KB
/
Copy pathApp.java
File metadata and controls
60 lines (52 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package JavaExtractor;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.LinkedList;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import org.kohsuke.args4j.CmdLineException;
import JavaExtractor.Common.CommandLineValues;
import JavaExtractor.FeaturesEntities.ProgramRelation;
public class App {
private static CommandLineValues s_CommandLineValues;
public static void main(String[] args) {
try {
s_CommandLineValues = new CommandLineValues(args);
} catch (CmdLineException e) {
e.printStackTrace();
return;
}
if (s_CommandLineValues.NoHash) {
ProgramRelation.setNoHash();
}
if (s_CommandLineValues.File != null) {
ExtractFeaturesTask extractFeaturesTask = new ExtractFeaturesTask(s_CommandLineValues,
s_CommandLineValues.File.toPath());
extractFeaturesTask.processFile();
} else if (s_CommandLineValues.Dir != null) {
extractDir();
}
}
private static void extractDir() {
ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(s_CommandLineValues.NumThreads);
LinkedList<ExtractFeaturesTask> tasks = new LinkedList<>();
try {
Files.walk(Paths.get(s_CommandLineValues.Dir)).filter(Files::isRegularFile)
.filter(p -> p.toString().toLowerCase().endsWith(".java")).forEach(f -> {
ExtractFeaturesTask task = new ExtractFeaturesTask(s_CommandLineValues, f);
tasks.add(task);
});
} catch (IOException e) {
e.printStackTrace();
return;
}
try {
executor.invokeAll(tasks);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
executor.shutdown();
}
}
}