sofya.tools.th
Class TestHistoryHandler

java.lang.Object
  extended by sofya.base.Handler
      extended by sofya.tools.th.TestHistoryHandler
All Implemented Interfaces:
SConstants

public class TestHistoryHandler
extends Handler
implements SConstants

The TestHistoryHandler provides methods to manipulate Galileo test history files and manage test histories for methods.

Version:
07/21/2005
Author:
Alex Kinneer
See Also:
TestHistory, TestHistoryViewer

Nested Class Summary
 
Nested classes/interfaces inherited from interface sofya.base.SConstants
SConstants.BlockLabel, SConstants.BlockObjectType, SConstants.BlockSubType, SConstants.BlockType, SConstants.BranchObjectType, SConstants.BranchType, SConstants.EDObjectType, SConstants.TraceObjectType
 
Field Summary
 
Fields inherited from class sofya.base.Handler
HANDLER_EXTENSIONS, LINE_SEP
 
Fields inherited from interface sofya.base.SConstants
DEFAULT_PORT, INST_COMPATIBLE, INST_OLD_UNSUPPORTED, INST_OPT_NORMAL, INST_OPT_SEQUENCE, SIG_CHKALIVE, SIG_ECHO
 
Constructor Summary
TestHistoryHandler()
          Default constructor, creates a test history handler with no test histories yet registered.
TestHistoryHandler(int typeFlags)
          Standard constructor, creates a test history handler which will indicate that the test history stores information for the given block types.
 
Method Summary
 boolean containsTestHistory(java.lang.String methodName)
          Reports whether a test history exists for a given method.
 java.lang.String[] getMethodList()
          Gets the list of methods names for which test histories are currently registered with the handler.
 TestHistory getTestHistory(java.lang.String methodName)
          Gets the test history associated with a given method.
 int getTypeFlags()
          Gets the bit mask indicating what types of blocks are marked by the test history being managed by the handler.
 java.lang.String getTypeString()
          Gets a string listing the types of blocks marked by the test history being managed by the handler.
 void readTestHistoryFile(java.lang.String fileName)
          Reads a test history file making the information available for request from the handler.
 void setTestHistory(java.lang.String methodName, TestHistory th)
          Sets the test history associated with a given method.
 void setTypeFlags(int typeFlags)
          Sets the bit mask indicating what types of blocks are marked by the test histories being managed by the handler.
protected static java.util.BitSet toBinary(java.lang.String hexString)
           
protected static java.lang.String toHex(java.util.BitSet bv, int size)
           
 void writeTestHistoryFile(java.lang.String fileName)
          Writes a test history file from the test history information currently registered with the handler.
 
Methods inherited from class sofya.base.Handler
copyFile, createCacheFile, disableParseNumbers, ensureTagExists, formatSignature, isIntAvailable, isStringAvailable, newCache, openCacheFile, openInputFile, openInputFile, openOutputFile, openOutputFile, parseClass, prepareTokenizer, readInt, readIntIgnoreEOL, readJarClasses, readNextLine, readProgFile, readString, readStringIgnoreEOL, readToEOL, readToNextDataLine
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestHistoryHandler

public TestHistoryHandler()
Default constructor, creates a test history handler with no test histories yet registered.

Note: You must call setTypeFlags(int) before attempting to save a test history file or an IllegalArgumentException will be thrown.


TestHistoryHandler

public TestHistoryHandler(int typeFlags)
Standard constructor, creates a test history handler which will indicate that the test history stores information for the given block types.

Parameters:
typeFlags - Bit mask representing the types of blocks that are marked in traces managed by the handler. Can be any bitwise combination of the following (See SConstants):
  • SConstants.BlockType.MASK_BASIC
  • SConstants.BlockType.MASK_ENTRY
  • SConstants.BlockType.MASK_EXIT
  • SConstants.BlockType.MASK_CALL
Throws:
java.lang.IllegalArgumentException - If the bit mask doesn't have a bit set which corresponds to a valid block type.
Method Detail

writeTestHistoryFile

public void writeTestHistoryFile(java.lang.String fileName)
                          throws java.io.IOException
Writes a test history file from the test history information currently registered with the handler.

Parameters:
fileName - Name of the test history file to be written.
Throws:
java.io.IOException - If there is an I/O error creating or writing the file.

readTestHistoryFile

public void readTestHistoryFile(java.lang.String fileName)
                         throws java.io.FileNotFoundException,
                                LocatableFileException,
                                BadFileFormatException,
                                java.io.IOException
Reads a test history file making the information available for request from the handler. The getTestHistory(java.lang.String) method can be used to retrieve information loaded by this method.

Parameters:
fileName - Name of the test history file to be read.
Throws:
java.io.FileNotFoundException - If the specified file doesn't exist.
BadFileFormatException - If the specified file is not a test history file, or is otherwise malformed or corrupted.
java.io.IOException - If there is an I/O error reading the file.
LocatableFileException

getMethodList

public java.lang.String[] getMethodList()
Gets the list of methods names for which test histories are currently registered with the handler.

Returns:
A list of the method names for which test histories can be retrieved from this handler.

containsTestHistory

public boolean containsTestHistory(java.lang.String methodName)
Reports whether a test history exists for a given method.

Parameters:
methodName - Name of the method which the handler should check for a test history.
Returns:
true if a test history is available for the given method, false otherwise.

getTestHistory

public TestHistory getTestHistory(java.lang.String methodName)
                           throws MethodNotFoundException
Gets the test history associated with a given method.

Parameters:
methodName - Name of the method for which the test history is to be retrieved.
Returns:
The TestHistory associated with the specified method.
Throws:
MethodNotFoundException - If the handler has no test history associated with a method of the specified name.

setTestHistory

public void setTestHistory(java.lang.String methodName,
                           TestHistory th)
Sets the test history associated with a given method.

If a test history already exists for the specified method, it is overwritten. Otherwise the method and test history are added to the set of methods registered with the handler.

Parameters:
methodName - Name of the method for which a test history is being specified.
th - The test history to be associated with the method.

setTypeFlags

public void setTypeFlags(int typeFlags)
Sets the bit mask indicating what types of blocks are marked by the test histories being managed by the handler.

Parameters:
typeFlags - Bit mask representing the types of blocks that are marked in traces managed by the handler. Can be any bitwise combination of the following (See SConstants):
  • SConstants.BlockType.MASK_BASIC
  • SConstants.BlockType.MASK_ENTRY
  • SConstants.BlockType.MASK_EXIT
  • SConstants.BlockType.MASK_CALL
Throws:
java.lang.IllegalArgumentException - If the bit mask doesn't have a bit set which corresponds to a valid block type.

getTypeFlags

public int getTypeFlags()
Gets the bit mask indicating what types of blocks are marked by the test history being managed by the handler.

Returns:
Bit mask controlling what types of blocks are instrumented.

getTypeString

public java.lang.String getTypeString()
Gets a string listing the types of blocks marked by the test history being managed by the handler.

Returns:
A string listing the types of blocks marked by the test histories being managed by this handler. The types are delimited by a single space character (ASCII 32).

toHex

protected static java.lang.String toHex(java.util.BitSet bv,
                                        int size)

toBinary

protected static java.util.BitSet toBinary(java.lang.String hexString)