sofya.apps.dejavu
Class EdgeSelector

java.lang.Object
  extended by sofya.apps.dejavu.EdgeSelector
Direct Known Subclasses:
CFEdgeSelector

public abstract class EdgeSelector
extends java.lang.Object

The edge selector retrieves and matches edges from the graphs being traversed, using this information to control how the graph traverser walks the graphs.

The graph traverser raises 'event' methods defined by this class to indicate when it is at certain points in the traversal. This provides an edge selector the opportunity to guide the graph traverser based on knowledge it has about the specific types of edges (and nodes) contained in the graphs being walked, and special conditions which may apply to the particular type of graph. An edge selector is also responsible for determining how to handle new edges found in the graph for a new version of a method.

Version:
02/23/2005
Author:
Alex Kinneer

Nested Class Summary
static class EdgeSelector.EdgeMatchData
          Data container class which records information about the outgoing edges from nodes in each graph and the path (or paths) the traverser should follow next.
static class EdgeSelector.EdgeTraversal
          Data container class which is used to direct the behavior of the graph traverser.
 
Field Summary
protected  Graph newGraph
          Graph for the method from the new version of the program.
protected  Graph oldGraph
          Graph for the method from the old version of the program.
 
Constructor Summary
EdgeSelector()
           
 
Method Summary
abstract  EdgeSelector.EdgeMatchData beginVisit(Node oldNode, Node newNode)
          Event raised by the traverser when it reaches a node in the graph which has not been visited.
protected  Edge findEdge(Edge[] edgeList, Node sourceNode, Node sinkNode)
          Utility method to find the first edge with the given source and sink nodes in a list of edges.
protected  java.util.List findEdges(Edge[] edgeList, Node sourceNode, Node sinkNode)
          Utility method to find all edges with the given source and sink nodes in a list of edges.
 Graph[] getGraphs()
          Gets the graphs currently in use.
protected  Edge matchLabelToEdge(Edge[] edgeList, java.lang.String edgeLabel)
          Utility method to find an edge with a given basic label in a list of edges.
abstract  void newEdges(Node oldNode, java.util.List newEdges, EdgeSelector.EdgeMatchData edgeData, java.util.Set dangerousEdges)
          Event raised by the traverser when it has determined that the graph for the new version of the method contains new edges out of a given node.
abstract  EdgeSelector.EdgeTraversal nodesCompared(Edge oldEdge, Edge newEdge)
          Event raised by the traverser immediately after comparison of two successor nodes when it is in the process of following all outgoing edges from a node.
 void setGraphs(Graph oldGraph, Graph newGraph)
          Sets the graphs for the old and new versions of the methods.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

oldGraph

protected Graph oldGraph
Graph for the method from the old version of the program.


newGraph

protected Graph newGraph
Graph for the method from the new version of the program.

Constructor Detail

EdgeSelector

public EdgeSelector()
Method Detail

beginVisit

public abstract EdgeSelector.EdgeMatchData beginVisit(Node oldNode,
                                                      Node newNode)
Event raised by the traverser when it reaches a node in the graph which has not been visited.

This event provides an opportunity for subclasses to produce edge data and control the traversal based on information that may be available from specific types of edges contained in the graphs.

Parameters:
oldNode - Node in the graph for the old version of the method.
newNode - Node in the graph for the new version of the method which has been determined to correspond to oldNode.
Returns:
A data object containing outgoing edges from the given nodes in each graph and an object instructing the traverser how to proceed.

nodesCompared

public abstract EdgeSelector.EdgeTraversal nodesCompared(Edge oldEdge,
                                                         Edge newEdge)
Event raised by the traverser immediately after comparison of two successor nodes when it is in the process of following all outgoing edges from a node.

This event provides an opportunity for subclasses to provide special case control over the traversal based on information that may be available from specific types of edges and nodes contained in the graphs.

Parameters:
oldEdge - Edge which was followed in the old graph to reach the node from that graph which was used in the comparison.
newEdge - Edge which was followed in the new graph to reach the node from that graph which was used in the comparison.
Returns:
An object instruction the traverser how to proceed.

newEdges

public abstract void newEdges(Node oldNode,
                              java.util.List newEdges,
                              EdgeSelector.EdgeMatchData edgeData,
                              java.util.Set dangerousEdges)
Event raised by the traverser when it has determined that the graph for the new version of the method contains new edges out of a given node.

This event provides an opportunity for subclasses to specify how the new edges impact the dangerous edge set based on information that may be available from specific types of edges and nodes contained in the graphs.

Parameters:
oldNode - Node from the graph of the old version of the method from which new outgoing edges were found in the graph for the new version of the method.
newEdges - List of the new outgoing edges found in the graph for the new version of the method at the given node.
edgeData - Data about outgoing edges in both graphs, as determined by the last call to beginVisit(sofya.graphs.Node, sofya.graphs.Node).
dangerousEdges - Set containing the dangerous edges identified by the traversal up to the current point.

setGraphs

public void setGraphs(Graph oldGraph,
                      Graph newGraph)
Sets the graphs for the old and new versions of the methods.

Parameters:
oldGraph - Graph corresponding to the old version of the method.
newGraph - Graph corresponding to the new version of the method.

getGraphs

public Graph[] getGraphs()
Gets the graphs currently in use.

Returns:
A two-element array, where the first element contains the graph for the old version of the method and the second element contains the graph for the new version of the method.

findEdge

protected Edge findEdge(Edge[] edgeList,
                        Node sourceNode,
                        Node sinkNode)
Utility method to find the first edge with the given source and sink nodes in a list of edges.

Parameters:
edgeList - List of edges to be searched, as an array.
sourceNode - Node which must be the predecessor node of a matching edge.
sinkNode - Node which must be the successor node of a matching edge.
Returns:
The first matching edge in the list, or null if no matching edge can be found.

findEdges

protected java.util.List findEdges(Edge[] edgeList,
                                   Node sourceNode,
                                   Node sinkNode)
Utility method to find all edges with the given source and sink nodes in a list of edges.

Parameters:
edgeList - List of edges to be searched, as an array.
sourceNode - Node which must be the predecessor node of a matching edge.
sinkNode - Node which must be the successor node of a matching edge.
Returns:
A list of all matching edges found in the provided edge list, which may be of length zero if no matching edges were found.

matchLabelToEdge

protected Edge matchLabelToEdge(Edge[] edgeList,
                                java.lang.String edgeLabel)
Utility method to find an edge with a given basic label in a list of edges.

Parameters:
edgeList - List of edges to be searched, as an array.
edgeLabel - Basic label of the edge to found. (Auxiliary label information is ignored).
Returns:
The edge in the edge list with the given basic label, or null if no such edge exists.