sofya.apps.dejavu
Class NodeComparer

java.lang.Object
  extended by sofya.apps.dejavu.NodeComparer
Direct Known Subclasses:
BytecodeNodeComparer

public abstract class NodeComparer
extends java.lang.Object

This abstract class defines the contract for classes that provide the service of comparing nodes from different Java classes for equality. The actual means of comparison is abstracted behind this interface, and is (of course) up to the class providing a concrete implementation of the interface.

Version:
05/03/2005
Author:
Alex Kinneer

Field Summary
protected  ClassPair class_
          Information about the class which is currently loaded for node comparisons.
 
Constructor Summary
protected NodeComparer()
          No-argument constructor for subclasses only.
 
Method Summary
abstract  boolean compareNodes(java.lang.String methodName, Node oldNode, Node newNode)
          Compares two nodes from the same method in two different graphs (versions of the program).
abstract  java.lang.String getCallMethodName(java.lang.String methodName, Node oldCallNode, Node newCallNode)
          Retrives the name of the method that is invoked by a call node.
 ClassPair getComparisonClass()
          Gets the name of the class from which the nodes to be compared are obtained (as set by setComparisonClass(sofya.apps.dejavu.ClassPair).
 void setComparisonClass(ClassPair clazz)
          Sets the name of the class from which the nodes to be compared are obtained.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

class_

protected ClassPair class_
Information about the class which is currently loaded for node comparisons.

Constructor Detail

NodeComparer

protected NodeComparer()
No-argument constructor for subclasses only.

Method Detail

getComparisonClass

public ClassPair getComparisonClass()
Gets the name of the class from which the nodes to be compared are obtained (as set by setComparisonClass(sofya.apps.dejavu.ClassPair).

Returns:
The name of the class from which the nodes have been obtained.

setComparisonClass

public void setComparisonClass(ClassPair clazz)
                        throws java.io.IOException
Sets the name of the class from which the nodes to be compared are obtained.

Parameters:
clazz - Information about the class from which nodes are to be compared.
Throws:
java.io.IOException - If the class or class-related file cannot be loaded (most comparers are expected to need to access files based on this information.)

getCallMethodName

public abstract java.lang.String getCallMethodName(java.lang.String methodName,
                                                   Node oldCallNode,
                                                   Node newCallNode)
                                            throws MethodNotFoundException
Retrives the name of the method that is invoked by a call node.

Parameters:
methodName - Name of the method which contains the call node for which the called method name is being requested.
oldCallNode - Call node in the original graph.
newCallNode - Call node in the modified graph.
Returns:
The name of the called method contained within the node, if it can be obtained from either the original or modified node.
Throws:
MethodNotFoundException - If no method matching the specified name can be found within which to locate the call nodes.

compareNodes

public abstract boolean compareNodes(java.lang.String methodName,
                                     Node oldNode,
                                     Node newNode)
                              throws MethodNotFoundException,
                                     java.lang.NullPointerException
Compares two nodes from the same method in two different graphs (versions of the program).

Parameters:
methodName - Name of the method from which the nodes for comparison have been obtained.
oldNode - Node for comparison from the original graph.
newNode - Node for comparison from the modified graph.
Returns:
true if the two nodes are equivalent, false otherwise.
Throws:
MethodNotFoundException - If no method by the given name exists in one or both of the graphs.
java.lang.NullPointerException - If a valid node for comparison is not provided.