use of com.google.security.zynamics.binnavi.disassembly.CCallgraphEdge in project binnavi by google.
the class PostgreSQLCallgraphLoader method loadEdges.
/**
* Loads the edges of the call graph.
*
* The call graph ID and all call graph nodes must refer to objects stored in the database
* connected to by the connection argument.
*
* @param connection Connection to the database.
* @param callgraphId ID of the call graph view to load.
* @param nodeMap Map between call graph node IDs and call graph view objects.
*
* @return The edged of the loaded call graph.
*
* @throws SQLException Thrown if loading the call graph edges failed.
*/
private static List<ICallgraphEdge> loadEdges(final CConnection connection, final int callgraphId, final Map<Integer, CCallgraphNode> nodeMap) throws SQLException {
final List<ICallgraphEdge> edges = new ArrayList<ICallgraphEdge>();
final String edgeQuery = "SELECT source_node_id, target_node_id" + " FROM " + CTableNames.NODES_TABLE + " JOIN " + CTableNames.EDGES_TABLE + " ON " + CTableNames.NODES_TABLE + ".id = " + CTableNames.EDGES_TABLE + ".source_node_id" + " WHERE view_id = " + callgraphId;
final ResultSet edgeResult = connection.executeQuery(edgeQuery, true);
try {
while (edgeResult.next()) {
final CCallgraphNode source = nodeMap.get(edgeResult.getInt("source_node_id"));
final CCallgraphNode target = nodeMap.get(edgeResult.getInt("target_node_id"));
CCallgraphNode.link(source, target);
edges.add(new CCallgraphEdge(source, target));
}
} finally {
edgeResult.close();
}
return edges;
}
Aggregations