-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConstructGroum.java
More file actions
executable file
·75 lines (70 loc) · 3.18 KB
/
Copy pathConstructGroum.java
File metadata and controls
executable file
·75 lines (70 loc) · 3.18 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.HashMap;
import java.util.Map;
public class ConstructGroum {
public Groum constructGroum(String groumPath,Map<String,String> apiMap){
Groum groum = new Groum();
try {
BufferedReader br = new BufferedReader(new FileReader(groumPath));
String line = null;
while((line = br.readLine()) != null){
if(line.endsWith("]")){
line = line.replace("[","");
line = line.replace("]","");
String[] strs = line.split(" ");
String id = strs[0];
String api = strs[1].replace("label=\"","");
api = api.substring(0,api.length() - 1);
if(!api.startsWith("/home/x/mydisk/download_high_repos")){
String originApi = api;
if(originApi.contains("<")){
if(originApi.contains("<init>")){
originApi = originApi.replaceAll("<init>","chenchichenchi");
}
originApi = originApi.replaceAll("\\<.*?\\>","");
originApi = originApi.replaceAll(">","");
if(originApi.contains("chenchichenchi")){
originApi = originApi.replaceAll("chenchichenchi","<init>");
}
}
if(apiMap.containsKey(originApi)){
api = apiMap.get(originApi);
}else{
api = Integer.toString(-1);
}
// String startLineString = strs[strs.length - 2].replace("startLine=","");
// String endLineString = strs[strs.length - 1].replace("endLine=","");
// int startLine = Integer.parseInt(startLineString);
// int endLine = Integer.parseInt(endLineString);
// GroumNode node = new GroumNode(id,api,originApi,startLine,endLine);
if(!api.equals("-1")) {
GroumNode node = new GroumNode(id, api, originApi, -1, -1);
groum.addNode(node);
}
}
}
else if(line.endsWith(";")){
line = line.replace("[label=\"\"];","");
line = line.trim();
String[] strs = line.split(" -> ");
if(strs.length == 2) {
String parentNodeId = strs[0];
String childNodeId = strs[1];
if (groum.getNodeMap().containsKey(parentNodeId) && groum.getNodeMap().containsKey(childNodeId)) {
groum.addEdge(parentNodeId, childNodeId);
}
}
}
}
br.close();
}catch(Exception e){
e.printStackTrace();
return null;
}catch (Error e){
e.printStackTrace();
return null;
}
return groum;
}
}