// Path: src/main/java/heapdl/hprof/StackFrame.java
// public class StackFrame {
//     private static final int LINE_NUMBER_UNKNOWN = -1;
//     private static final int LINE_NUMBER_COMPILED = -2;
//     private static final int LINE_NUMBER_NATIVE = -3;
//     private final String methodName;
//     private final String methodSignature;
//     private final String className;
//     private final int lineNumber;
// 
//     public StackFrame(String methodName, String methodSignature, String className, int lineNumber) {
//         this.methodName = methodName;
//         this.methodSignature = methodSignature;
//         this.className = className;
//         this.lineNumber = lineNumber;
//     }
// 
//     public String getMethodName() {
//         return this.methodName;
//     }
// 
//     public String getMethodSignature() {
//         return this.methodSignature;
//     }
// 
//     public String getClassName() {
//         return this.className;
//     }
// 
//     public String getLineNumber() {
//         switch (this.lineNumber) {
//             case LINE_NUMBER_NATIVE:
//                 return "(native method)";
//             case LINE_NUMBER_COMPILED:
//                 return "(compiled method)";
//             case LINE_NUMBER_UNKNOWN:
//                 return "(unknown)";
//             default:
//                 return Integer.toString(this.lineNumber, 10);
//         }
//     }
// }
// 
// Path: src/main/java/heapdl/hprof/StackTrace.java
// public class StackTrace {
//     private final StackFrame[] frames;
// 
//     public StackTrace(StackFrame[] frames) {
//         this.frames = frames;
//     }
// 
//     public StackFrame[] getFrames() {
//         return this.frames;
//     }
// }
// 
// Path: src/main/java/heapdl/io/HeapDatabaseConsumer.java
// public interface HeapDatabaseConsumer {
//     /**
//      * Record a tuple in a table.
//      *
//      * @param table   the table
//      * @param arg     the value of the first column
//      * @param args    the values of the rest of the columns
//      */
//     void add(PredicateFile table, String arg, String... args);
// 
//     /**
//      * Finish writing to the database.
//      *
//      * @throws IOException if the operation failed
//      */
//     void finishWriting() throws IOException;
// }
// 
// Path: src/main/java/heapdl/io/PredicateFile.java
// public enum PredicateFile {
//     DYNAMIC_NORMAL_HEAP_OBJECT("DynamicNormalHeapObject"),
//     DYNAMIC_STRING_HEAP_OBJECT("DynamicStringHeapObject"),
//     DYNAMIC_STATIC_FIELD_POINTS_TO("DynamicStaticFieldPointsTo"),
//     DYNAMIC_INSTANCE_FIELD_POINTS_TO("DynamicInstanceFieldPointsTo"),
//     DYNAMIC_ARRAY_INDEX_POINTS_TO("DynamicArrayIndexPointsTo"),
//     DYNAMIC_VAR_POINTS_TO("DynamicVarPointsTo"),
//     DYNAMIC_REACHABLE_METHOD("DynamicReachableMethod"),
//     DYNAMIC_CALL_GRAPH_EDGE("DynamicCallGraphEdge"),
//     DYNAMIC_NORMAL_HEAP_ALLOCATION("DynamicNormalHeapAllocation"),
//     DYNAMIC_CONTEXT("DynamicContext"),
//     STRING_CONST("StringConstant"),
//     STRING_RAW("StringRaw");
// 
//     private final String name;
// 
//     PredicateFile(String name) {
//         this.name = name;
//     }
// 
//     @Override
//     public String toString() {
//         return  name;
//     }
// 
//     public Writer getWriter(File directory, String suffix) throws IOException {
//         File factsFile = new File(directory, name + suffix);
//         FileUtils.touch(factsFile);
//         return new FileWriter(factsFile, true);
//     }
// }


import heapdl.hprof.StackFrame;
import heapdl.hprof.StackTrace;
import heapdl.io.HeapDatabaseConsumer;
import heapdl.io.PredicateFile;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.stream.Collectors;
package heapdl.core;



/**
 * Created by neville on 16/02/2017.
 */
public class DynamicReachableMethod implements DynamicFact {
    private final String representation;

    public static Collection<DynamicReachableMethod> fromStackTrace(StackTrace trace) {
        if (trace == null || trace.getFrames() == null)
// Path: src/main/java/heapdl/hprof/StackFrame.java
// public class StackFrame {
//     private static final int LINE_NUMBER_UNKNOWN = -1;
//     private static final int LINE_NUMBER_COMPILED = -2;
//     private static final int LINE_NUMBER_NATIVE = -3;
//     private final String methodName;
//     private final String methodSignature;
//     private final String className;
//     private final int lineNumber;
// 
//     public StackFrame(String methodName, String methodSignature, String className, int lineNumber) {
//         this.methodName = methodName;
//         this.methodSignature = methodSignature;
//         this.className = className;
//         this.lineNumber = lineNumber;
//     }
// 
//     public String getMethodName() {
//         return this.methodName;
//     }
// 
//     public String getMethodSignature() {
//         return this.methodSignature;
//     }
// 
//     public String getClassName() {
//         return this.className;
//     }
// 
//     public String getLineNumber() {
//         switch (this.lineNumber) {
//             case LINE_NUMBER_NATIVE:
//                 return "(native method)";
//             case LINE_NUMBER_COMPILED:
//                 return "(compiled method)";
//             case LINE_NUMBER_UNKNOWN:
//                 return "(unknown)";
//             default:
//                 return Integer.toString(this.lineNumber, 10);
//         }
//     }
// }
// 
// Path: src/main/java/heapdl/hprof/StackTrace.java
// public class StackTrace {
//     private final StackFrame[] frames;
// 
//     public StackTrace(StackFrame[] frames) {
//         this.frames = frames;
//     }
// 
//     public StackFrame[] getFrames() {
//         return this.frames;
//     }
// }
// 
// Path: src/main/java/heapdl/io/HeapDatabaseConsumer.java
// public interface HeapDatabaseConsumer {
//     /**
//      * Record a tuple in a table.
//      *
//      * @param table   the table
//      * @param arg     the value of the first column
//      * @param args    the values of the rest of the columns
//      */
//     void add(PredicateFile table, String arg, String... args);
// 
//     /**
//      * Finish writing to the database.
//      *
//      * @throws IOException if the operation failed
//      */
//     void finishWriting() throws IOException;
// }
// 
// Path: src/main/java/heapdl/io/PredicateFile.java
// public enum PredicateFile {
//     DYNAMIC_NORMAL_HEAP_OBJECT("DynamicNormalHeapObject"),
//     DYNAMIC_STRING_HEAP_OBJECT("DynamicStringHeapObject"),
//     DYNAMIC_STATIC_FIELD_POINTS_TO("DynamicStaticFieldPointsTo"),
//     DYNAMIC_INSTANCE_FIELD_POINTS_TO("DynamicInstanceFieldPointsTo"),
//     DYNAMIC_ARRAY_INDEX_POINTS_TO("DynamicArrayIndexPointsTo"),
//     DYNAMIC_VAR_POINTS_TO("DynamicVarPointsTo"),
//     DYNAMIC_REACHABLE_METHOD("DynamicReachableMethod"),
//     DYNAMIC_CALL_GRAPH_EDGE("DynamicCallGraphEdge"),
//     DYNAMIC_NORMAL_HEAP_ALLOCATION("DynamicNormalHeapAllocation"),
//     DYNAMIC_CONTEXT("DynamicContext"),
//     STRING_CONST("StringConstant"),
//     STRING_RAW("StringRaw");
// 
//     private final String name;
// 
//     PredicateFile(String name) {
//         this.name = name;
//     }
// 
//     @Override
//     public String toString() {
//         return  name;
//     }
// 
//     public Writer getWriter(File directory, String suffix) throws IOException {
//         File factsFile = new File(directory, name + suffix);
//         FileUtils.touch(factsFile);
//         return new FileWriter(factsFile, true);
//     }
// }


// Path: src/main/java/heapdl/core/DynamicReachableMethod.java
import heapdl.hprof.StackFrame;
import heapdl.hprof.StackTrace;
import heapdl.io.HeapDatabaseConsumer;
import heapdl.io.PredicateFile;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.stream.Collectors;

package heapdl.core;



/**
 * Created by neville on 16/02/2017.
 */
public class DynamicReachableMethod implements DynamicFact {
    private final String representation;

    public static Collection<DynamicReachableMethod> fromStackTrace(StackTrace trace) {
        if (trace == null || trace.getFrames() == null)
            return new ArrayList<>();