sofya.mutator
Class MutationHandler

java.lang.Object
  extended by sofya.base.Handler
      extended by sofya.mutator.MutationHandler

public class MutationHandler
extends Handler

Provides file handling routines for mutation related files.

Version:
10/07/2005
Author:
Alex Kinneer

Field Summary
static java.lang.String DEFAULT_OP_DIR
          Location of the default directory for mutation operators.
static java.lang.String DEFAULT_OP_LIST_FILE
          Location of the default mutation operator list file, which is the file that lists the operators included by default.
 
Fields inherited from class sofya.base.Handler
HANDLER_EXTENSIONS, LINE_SEP
 
Method Summary
static void main(java.lang.String[] argv)
          Test driver to exercise various handler routines.
static MutatorConfiguration readConfiguration(java.lang.String configFile)
          Reads a configuration file for the mutation table generator.
static MutationIterator readMutationFile(java.lang.String fileName)
          Returns an iterator that enables progressive reading of a mutation table from a file.
static MutationTable readMutationTable(java.lang.String fileName)
          Reads a mutation table from file into memory.
static java.lang.String[] readOperatorList(java.lang.String fileName)
          Reads the default operator list file.
static FileWriterMutationTable writeMutationFile(java.lang.String fileName)
          Returns a handle to a disk-backed mutation table that progressively writes mutations to a file as they are added.
static void writeMutationTable(java.lang.String fileName, MutationTable mt)
          Writes a mutation table to file from memory.
 
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, toBinary, toHex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_OP_DIR

public static final java.lang.String DEFAULT_OP_DIR
Location of the default directory for mutation operators.


DEFAULT_OP_LIST_FILE

public static final java.lang.String DEFAULT_OP_LIST_FILE
Location of the default mutation operator list file, which is the file that lists the operators included by default.

Method Detail

readConfiguration

public static MutatorConfiguration readConfiguration(java.lang.String configFile)
                                              throws BadFileFormatException,
                                                     java.io.IOException
Reads a configuration file for the mutation table generator.

Parameters:
configFile - Name of the configuration file.
Returns:
A MutatorConfiguration providing access to the configuration data.
Throws:
BadFileFormatException - If the specified file is not a configuration file or does not conform to the configuration file format.
java.io.IOException - For any other I/O error that prevents successful reading of the configuration file.

readOperatorList

public static java.lang.String[] readOperatorList(java.lang.String fileName)
                                           throws java.io.IOException
Reads the default operator list file.

Parameters:
fileName - Path to the default operator list file.
Returns:
An array of strings listing all the names of the implementing classes for the default operators.
Throws:
java.io.IOException - For any I/O error that prevents successful reading of the operator list file.

readMutationFile

public static MutationIterator readMutationFile(java.lang.String fileName)
                                         throws java.io.IOException
Returns an iterator that enables progressive reading of a mutation table from a file.

Reading a mutation table file using this approach is more efficient if mutations only need to be processed serially. This is especially true of large mutation tables.

Parameters:
fileName - Name of the mutation file to be read.
Returns:
A MutationIterator over the mutations in the mutation table stored in the file.
Throws:
java.io.IOException - If the specified file does not exist or does not contain a mutation table.

writeMutationFile

public static FileWriterMutationTable writeMutationFile(java.lang.String fileName)
                                                 throws java.io.IOException
Returns a handle to a disk-backed mutation table that progressively writes mutations to a file as they are added.

Writing a mutation table file using this approach is more efficient if access to previously written mutations is not required during generation of the table. This is especially true of large mutation tables.

Parameters:
fileName - Name of the mutation file to be written. Any existing file of the same name will be overwritten.
Returns:
A FileWriterMutationTable that provides transparent serialization of mutations to file as they are added.
Throws:
java.io.IOException - If the requested mutation file cannot be opened for writing.

readMutationTable

public static MutationTable readMutationTable(java.lang.String fileName)
                                       throws java.io.IOException
Reads a mutation table from file into memory.

Large mutation tables may cause significant memory consumption.

Parameters:
fileName - Name of the mutation file to be read.
Returns:
A MutationTable providing access to the mutations read from the mutation table.
Throws:
java.io.IOException - If the specified file does not exist or does not contain a mutation table.

writeMutationTable

public static void writeMutationTable(java.lang.String fileName,
                                      MutationTable mt)
                               throws java.io.IOException
Writes a mutation table to file from memory.

Retaining an entire mutation table in memory may be costly, therefore it is generally preferable to avoid using this method.

Parameters:
fileName - Name of the mutation file to be written. Any existing file of the same name will be overwritten.
mt - MutationTable to be written to the file.
Throws:
java.io.IOException - If the requested file cannot be opened for writing or for any other I/O error that prevents successful serialization of the mutation table to the file.

main

public static void main(java.lang.String[] argv)
                 throws java.lang.Exception
Test driver to exercise various handler routines.

Throws:
java.lang.Exception