MCPcopy Create free account
hub / github.com/GCMiner/GCMiner / ReadChain

Class ReadChain

src/main/java/com/ReadChain.java:16–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14import java.util.ArrayList;
15
16public class ReadChain {
17 public String getData(String fileName) {
18 String Path="src\\test\\java\\com\\result\\" + fileName + ".json";
19 BufferedReader reader = null;
20 StringBuilder laststr = new StringBuilder();
21 try {
22 FileInputStream fileInputStream = new FileInputStream(Path);
23 InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, StandardCharsets.UTF_8);
24 reader = new BufferedReader(inputStreamReader);
25 String tempString;
26 while ((tempString = reader.readLine()) != null) {
27 laststr.append(tempString);
28 }
29 reader.close();
30 } catch (IOException e) {
31 e.printStackTrace();
32 } finally {
33 if (reader != null) {
34 try {
35 reader.close();
36 } catch (IOException e) {
37 e.printStackTrace();
38 }
39 }
40 }
41 return laststr.toString();
42 }
43
44 public String get_ClassName (JsonNode results, int chain_id, int node_id) {
45 JsonNode ClassName = results.get(chain_id).get("ClassName");
46 String classname = null;
47 for (int i=0; i<ClassName.size(); i++) {
48 if (ClassName.get(i).get("id").intValue() == node_id) {
49 classname = ClassName.get(i).get("value").textValue();
50 break;
51 }
52 }
53 return classname;
54 }
55
56 public String get_MethodName (JsonNode results, int chain_id, int node_id) {
57 JsonNode MethodName = results.get(chain_id).get("MethodName");
58 String methodname = null;
59 for (int i=0; i<MethodName.size(); i++) {
60 if (MethodName.get(i).get("id").intValue() == node_id) {
61 methodname = MethodName.get(i).get("value").textValue();
62 break;
63 }
64 }
65 return methodname;
66 }
67
68 public int[] get_ReflectClassId (JsonNode Edges, int edge_id) {
69 int[] result_list = new int[2];
70 int classId;
71 if (Edges.get(edge_id-1).get("edge").textValue().equals("CALL") &
72 Edges.get(edge_id+1).get("edge").textValue().equals("CALL")) {
73 classId = Edges.get(edge_id).get("exit_id").intValue();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected