Package randoop.generation
Class OperationHistoryLogger
- java.lang.Object
-
- randoop.generation.OperationHistoryLogger
-
- All Implemented Interfaces:
OperationHistoryLogInterface
public class OperationHistoryLogger extends Object implements OperationHistoryLogInterface
The working implementation of aOperationHistoryLogInterface
that will collect and print the operation history log to thePrintWriter
given when constructed.
-
-
Field Summary
Fields Modifier and Type Field Description private Map<TypedOperation,EnumMap<OperationOutcome,Integer>>
operationMap
A sparse representation for the operation-outcome table.private PrintWriter
writer
ThePrintWriter
for outputting the operation history as a table.
-
Constructor Summary
Constructors Constructor Description OperationHistoryLogger(PrintWriter writer)
Creates anOperationHistoryLogger
that will write to the givenPrintWriter
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(TypedOperation operation, OperationOutcome outcome)
Increments the count foroperation
andoutcome
.void
outputTable()
Prints a table showing the counts for each operation-outcome pair in the operation history log.private Map<OperationOutcome,String>
printHeader(int firstColumnLength)
Writes the header for the operation history table, and constructs a map of format strings for the columns of the table matching the length of the outcome names.private void
printRow(int firstColumnLength, Map<OperationOutcome,String> formatMap, TypedOperation operation, EnumMap<OperationOutcome,Integer> countMap)
Writes a row for a particular operation consisting of the operation signature and the counts of sequences for each outcome.
-
-
-
Field Detail
-
writer
private final PrintWriter writer
ThePrintWriter
for outputting the operation history as a table.
-
operationMap
private final Map<TypedOperation,EnumMap<OperationOutcome,Integer>> operationMap
A sparse representation for the operation-outcome table. The integeroperationMap.get(A).get(B)
is the number of times that (A, B) were arguments toadd(randoop.operation.TypedOperation, randoop.generation.OperationOutcome)
.
-
-
Constructor Detail
-
OperationHistoryLogger
public OperationHistoryLogger(PrintWriter writer)
Creates anOperationHistoryLogger
that will write to the givenPrintWriter
.- Parameters:
writer
- thePrintWriter
for writing the table from the created operation history
-
-
Method Detail
-
add
public void add(TypedOperation operation, OperationOutcome outcome)
Description copied from interface:OperationHistoryLogInterface
Increments the count foroperation
andoutcome
.- Specified by:
add
in interfaceOperationHistoryLogInterface
- Parameters:
operation
- theTypedOperation
outcome
- the generation outcome for the operation
-
outputTable
public void outputTable()
Description copied from interface:OperationHistoryLogInterface
Prints a table showing the counts for each operation-outcome pair in the operation history log.- Specified by:
outputTable
in interfaceOperationHistoryLogInterface
-
printHeader
private Map<OperationOutcome,String> printHeader(int firstColumnLength)
Writes the header for the operation history table, and constructs a map of format strings for the columns of the table matching the length of the outcome names.- Parameters:
firstColumnLength
- the width to use for the first column- Returns:
- a map from
OperationOutcome
value to numeric column format for subsequent rows
-
printRow
private void printRow(int firstColumnLength, Map<OperationOutcome,String> formatMap, TypedOperation operation, EnumMap<OperationOutcome,Integer> countMap)
Writes a row for a particular operation consisting of the operation signature and the counts of sequences for each outcome.- Parameters:
firstColumnLength
- the width to use for the first columnformatMap
- the map of format strings for the counts for each outcomeoperation
- the operation for the rowcountMap
- the map of counts for the operation and each outcome
-
-