sofya.graphs.irg
Class IRG

java.lang.Object
  extended by sofya.graphs.irg.IRG

public class IRG
extends java.lang.Object

Class which represents an Interclass Relation Graph for a given set of Java classes, as described by Orso, Shi, and Harrold (Scaling Regression Testing to Large Software Systems), extended to additionally support Java interfaces. This is effectively a class hierarchy graph which supports the modeling of class relationships introduced by the semantics of Java interfaces.

Version:
06/09/2006
Author:
Alex Kinneer
See Also:
IRGHandler

Nested Class Summary
static class IRG.ClassNode
          This class represents a node in the IRG which encapsulates the interclass relations for a particular class.
 
Field Summary
static java.lang.String BASE_ID
          Identifier returned if the superclass is requested for the primordial class (java.lang.Object).
static int MAX_NAME_TABLE_SIZE
          Maximum number of entries permitted in the name table.
static int NO_SUPERCLASS
          Special index indicating that a class has no superclass.
static java.lang.String UNDEF_ID
          Identifier returned if the superclass is requested for a class outside of the set of classes for which the IRG was constructed.
 
Constructor Summary
IRG(java.util.List classList)
          Constructs an interclass relation graph from a list of classes.
IRG(java.util.List classList, boolean findUses)
          Constructs an interclass relation graph from a list of classes.
IRG(java.lang.String progFile, java.lang.String tag)
          Constructs an interclass relation graph from the list of classes specified by the given '.prog' file.
 
Method Summary
protected  void buildIRG(java.util.List classList)
          Builds the interclass relation graph.
 IRG.ClassNode getClassRelationData(java.lang.String className)
          Gets the node containing the interclass relations for a given class.
 java.lang.String[] getNameTable()
          Gets a copy of the name/index table.
static void main(java.lang.String[] argv)
          Test driver for the IRG class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_SUPERCLASS

public static final int NO_SUPERCLASS
Special index indicating that a class has no superclass. This is true for interfaces and java.lang.Object (interfaces support direct multiple inheritance, thus subinterfaces do not have direct references to their superinterfaces in the graph. They do however implement their superinterface(s), so they appear in their superinterfaces' implementors list(s)).

See Also:
Constant Field Values

MAX_NAME_TABLE_SIZE

public static final int MAX_NAME_TABLE_SIZE
Maximum number of entries permitted in the name table.

See Also:
Constant Field Values

BASE_ID

public static final java.lang.String BASE_ID
Identifier returned if the superclass is requested for the primordial class (java.lang.Object).

See Also:
Constant Field Values

UNDEF_ID

public static final java.lang.String UNDEF_ID
Identifier returned if the superclass is requested for a class outside of the set of classes for which the IRG was constructed.

See Also:
Constant Field Values
Constructor Detail

IRG

public IRG(java.lang.String progFile,
           java.lang.String tag)
    throws java.io.FileNotFoundException,
           java.io.IOException,
           java.lang.ClassFormatError
Constructs an interclass relation graph from the list of classes specified by the given '.prog' file.

Parameters:
progFile - A '.prog' file in the database containing the list of classes for which the graph is to be built.
tag - Database tag associated with the file. May be null, in which case the file is assumed to be located in the root database directory.
Throws:
java.io.FileNotFoundException - If a class named in the 'prog' file cannot be found.
java.io.IOException - If an error occurs while attempting to read an input class for analysis.
java.lang.ClassFormatError - If an input class is not a valid Java class.

IRG

public IRG(java.util.List classList)
    throws java.io.IOException,
           java.lang.ClassFormatError
Constructs an interclass relation graph from a list of classes.

Parameters:
classList - List of classes for which to construct an interclass relation graph.
Throws:
java.io.IOException - If an error occurs while attempting to read an input class for analysis.
java.lang.ClassFormatError - If an input class is not a valid Java class.

IRG

public IRG(java.util.List classList,
           boolean findUses)
    throws java.io.IOException,
           java.lang.ClassFormatError
Constructs an interclass relation graph from a list of classes.

Parameters:
classList - List of classes for which to construct an interclass relation graph.
findUses - Flag specifying whether to compute used classes in the graph. Setting to true makes the IRG consistent with the data structure described by Orso, Shi, and Harrold.
Throws:
java.io.IOException - If an error occurs while attempting to read an input class for analysis.
java.lang.ClassFormatError - If an input class is not a valid Java class.
Method Detail

buildIRG

protected void buildIRG(java.util.List classList)
                 throws java.io.IOException,
                        java.lang.ClassFormatError
Builds the interclass relation graph.

Parameters:
classList - List of fully qualified class names from which the IRG will be built. Class relationship data will only be computed for those classes found in this list, although superclasses 'external' to the list will be properly identified.
Throws:
java.io.IOException - If an error occurs while attempting to read an input class for analysis.
java.lang.ClassFormatError - If an input class is not a valid Java class.

getNameTable

public java.lang.String[] getNameTable()
Gets a copy of the name/index table. The copy cannot be used to change the internal table, by design.

This method is intended primarily for use by IRGHandler.

Returns:
A deep copy of the table recording mappings of names to their internal numeric indices for this IRG.

getClassRelationData

public IRG.ClassNode getClassRelationData(java.lang.String className)
                                   throws java.lang.ClassNotFoundException
Gets the node containing the interclass relations for a given class.

Parameters:
className - Name of the class for which the interclass relations data node is to be retrieved.
Returns:
A data node which provides access to the interclass relationship data computed for the specified class.
Throws:
java.lang.ClassNotFoundException - If no node can be found in the IRG for the specified class.

main

public static void main(java.lang.String[] argv)
                 throws java.lang.Exception
Test driver for the IRG class.

Throws:
java.lang.Exception