Package outputProviders.logInputter
Class IterationResultsFormatter
java.lang.Object
outputProviders.logInputter.IterationResultsFormatter
This class formats some attributes of the total iteration results, such as iterations numbers together, amount of total
iterations, fuzz attempt number, exit counts, execution times, current times, and so on.
-
Constructor Summary
ConstructorsConstructorDescriptionIterationResultsFormatter(List<IterationResult> iterationResults) Constructor for IterationResultsFormatter. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetFormattedExecutionTime(int elapsedTime) Default values of getFormattedExecutionTime()static StringgetFormattedExecutionTime(long elapsedTime, boolean titlePrefix, boolean CSVReplacement, boolean appendComma, boolean appendNewLine) Gives the execution time formatted properly.static StringgetFormattedExecutionTime(String totalTime) Default values of getFormattedExecutionTime()static StringgetFormattedExecutionTime(String totalTime, boolean titlePrefix, boolean CSVReplacement, boolean appendComma, boolean appendNewLine) Gives the execution time formatted properly.getFormattedExitCount(int exitCode) Default values of getFormattedExitCount()getFormattedExitCount(int exitCode, boolean asText, boolean titlePrefix, boolean CSVReplacement, boolean appendComma, boolean appendNewLine) Counts the iterations of the given error code within the list of iterations that the formatter has been initialized with.static StringgetFormattedExitCount(int ErrorCode, int ErrorCount) Default version of the static getFormattedExitCount() method with use of own count.static StringgetFormattedExitCount(int ErrorCode, int ErrorCount, boolean asText, boolean titlePrefix, boolean CSVReplacement, boolean appendComma, boolean appendNewLine) Should only be used carefully, if one is completely sure of count.static StringgetFormattedExitCount(List<IterationResult> iterationResults) Default values of getFormattedExitCount().static StringgetFormattedExitCount(List<IterationResult> iterationResults, boolean asText, boolean titlePrefix, boolean CSVReplacement, boolean appendComma, boolean appendNewLine) Static version to get formatted exit count.static StringDefault values of getFormattedFuzzAttemptNr()static StringgetFormattedFuzzAttemptNr(boolean titlePrefix, boolean CSVReplacement, boolean appendComma, boolean appendNewLine) Gets formatted current fuzz number attempt.static StringgetFormattedFuzzAttemptNr(String fuzzAttemptNr) Default values of getFormattedFuzzAttemptNr()static StringgetFormattedFuzzAttemptNr(String fuzzAttemptNr, boolean titlePrefix, boolean CSVReplacement, boolean appendComma, boolean appendNewLine) Gets formatted fuzz number attempt.static StringgetFormattedIterationNumbersString(List<IterationResult> filteredResults) Default version of the static version of the getFormattedIterationNumbersString.static StringgetFormattedIterationNumbersString(List<IterationResult> filteredResults, boolean titlePrefix, boolean CSVReplacement, boolean appendComma, boolean appendNewLine) Static version of the getIterationNumbersString.static StringDefault values of getFormattedTimeStamp()static StringgetFormattedTimeStamp(boolean titlePrefix, boolean CSVReplacement, boolean appendComma, boolean appendNewLine) Gets the current timestamp formatted properly.static StringgetFormattedTimeStamp(String timeStamp) Default values of getFormattedTimeStamp()static StringgetFormattedTimeStamp(String timeStamp, boolean titlePrefix, boolean CSVReplacement, boolean appendComma, boolean appendNewLine) Gets the given timestamp formatted properly.Default values of getFormattedTotalIterations()getFormattedTotalIterations(boolean titlePrefix, boolean CSVReplacement, boolean appendComma, boolean appendNewLine) Gets the total number of iterations of the list of iterations the formatter has been initialized with as a string.static StringgetFormattedTotalIterations(int totalIterations) Default values of getFormattedTotalIterations()static StringgetFormattedTotalIterations(int totalIterations, boolean titlePrefix, boolean CSVReplacement, boolean appendComma, boolean appendNewLine) Gets the total number of iterations as a string.Default values of getIterationNumbersString()getIterationNumbersString(boolean titlePrefix, boolean CSVReplacement, boolean appendComma, boolean appendNewLine) Retrieves a string representation of iteration numbers from a list of iteration results.
-
Constructor Details
-
IterationResultsFormatter
Constructor for IterationResultsFormatter.- Parameters:
iterationResults- - list of iteration results to be formatted.
-
-
Method Details
-
getIterationNumbersString
public String getIterationNumbersString(boolean titlePrefix, boolean CSVReplacement, boolean appendComma, boolean appendNewLine) Retrieves a string representation of iteration numbers from a list of iteration results. e.g., [1, 2, 3] becomes "1-2-3"- Parameters:
titlePrefix- - if true, the variable name will be prefixed with "All Iteration Numbers: "CSVReplacement- -if true, comma's and line breaks in the name will be removed.appendComma- - if true, a comma will be appendedappendNewLine- - if true, a newline will be appended- Returns:
- A string containing the iteration numbers separated by hyphens.
-
getIterationNumbersString
Default values of getIterationNumbersString()- Returns:
- A string containing the iteration numbers separated by hyphens, without titles, with replaced commas and newlines, and a comma appended thereafter.
-
getFormattedIterationNumbersString
public static String getFormattedIterationNumbersString(List<IterationResult> filteredResults, boolean titlePrefix, boolean CSVReplacement, boolean appendComma, boolean appendNewLine) Static version of the getIterationNumbersString. Should only be used for iteration results that have one error code in common.- Parameters:
filteredResults- Results that need formatting and analyzing and only have one error code in common.titlePrefix- - if true, the variable name will be prefixed with "All Iteration Numbers:CSVReplacement- -if true, comma's and line breaks in the name will be removed.appendComma- – if true, a comma will be appendedappendNewLine- – - if true, a newline will be appended- Returns:
- A string containing the iteration numbers separated by hyphens.
-
getFormattedIterationNumbersString
Default version of the static version of the getFormattedIterationNumbersString.- Parameters:
filteredResults- - Results that need formatting and analyzing and only have one error code in common.- Returns:
- A string containing the iteration numbers of that error code separated by hyphens, without titles, with replaced commas and newlines, and a comma appended thereafter.
-
getFormattedFuzzAttemptNr
public static String getFormattedFuzzAttemptNr(String fuzzAttemptNr, boolean titlePrefix, boolean CSVReplacement, boolean appendComma, boolean appendNewLine) Gets formatted fuzz number attempt. Is always static because is same for whole application run.- Parameters:
fuzzAttemptNr- the fuzz attempt number that needs formatting, as String.titlePrefix- - if true, the variable name will be prefixed with "Fuzz Attempt Nr.: "CSVReplacement- - if true, comma's and line breaks in the name will be removed.appendComma- - if true, a comma will be appendedappendNewLine- - if true, a newline will be appended- Returns:
- String Fuzz attempt nr as a string and formatted as required
-
getFormattedFuzzAttemptNr
Default values of getFormattedFuzzAttemptNr()- Parameters:
fuzzAttemptNr- The fuzz attempt number that needs formatting, as String.- Returns:
- String Fuzz attempt nr without titles, with replaced commas and newlines, and a comma appended thereafter.
-
getFormattedFuzzAttemptNr
public static String getFormattedFuzzAttemptNr(boolean titlePrefix, boolean CSVReplacement, boolean appendComma, boolean appendNewLine) Gets formatted current fuzz number attempt. Is always static because is same for whole application run.- Parameters:
titlePrefix- - if true, the variable name will be prefixed with "Fuzz Attempt Nr.: "CSVReplacement- - if true, comma's and line breaks in the name will be removed.appendComma- - if true, a comma will be appendedappendNewLine- - if true, a newline will be appended- Returns:
- String Fuzz attempt nr as a string and formatted as required
-
getFormattedFuzzAttemptNr
Default values of getFormattedFuzzAttemptNr()- Returns:
- String Current fuzz attempt nr without titles, with replaced commas and newlines, and a comma appended thereafter.
-
getFormattedExitCount
public static String getFormattedExitCount(int ErrorCode, int ErrorCount, boolean asText, boolean titlePrefix, boolean CSVReplacement, boolean appendComma, boolean appendNewLine) Should only be used carefully, if one is completely sure of count. Defers from the getExitCount method in LogFileCalculator.- Parameters:
ErrorCode- - the error code to count. Can be 0 1 10 or -1.ErrorCount- - the number of iterations that had the error code.asText- - "occurrences" will be appended after the count number.titlePrefix- - if true, the variable name will be prefixed with "Exit code " + exitCode + ": "CSVReplacement- - if true, newlines and commas are removed.appendComma- - if true, a comma is appended afterwards.appendNewLine- - if true, a new line is appended afterwards.- Returns:
- The number of iterations that had the exit code, formatted as required in a String.
-
getFormattedExitCount
Default version of the static getFormattedExitCount() method with use of own count.- Parameters:
ErrorCode- - the error code to count. Can be 0 1 10 or -1.ErrorCount- - the number of iterations that had the error code.- Returns:
- The number of iterations that had the exit code, without titles or text, with newlines and commas replaced, and with a comma appended afterwards.
-
getFormattedExitCount
public String getFormattedExitCount(int exitCode, boolean asText, boolean titlePrefix, boolean CSVReplacement, boolean appendComma, boolean appendNewLine) Counts the iterations of the given error code within the list of iterations that the formatter has been initialized with.- Parameters:
exitCode- - the error code to count. Can be 0 1 10 or -1.asText- - "occurrences" will be appended after the count number.titlePrefix- - if true, the variable name will be prefixed with "Exit code " + exitCode + ": "CSVReplacement- - if true, the commas and new lines will be removed.appendComma- - if true, a comma will be appendedappendNewLine- - if true, a newline will be appended- Returns:
- The number of iterations that had the exit code, formatted as required in a String.
-
getFormattedExitCount
Default values of getFormattedExitCount()- Parameters:
exitCode- - the error code to count. Can be 0 1 10 or -1.- Returns:
- The number of iterations that had the exit code within the list of iterations that the formatter has been initialized with, without titles or text, with newlines and commas replaced,and with a comma appended afterwards.
-
getFormattedExitCount
public static String getFormattedExitCount(List<IterationResult> iterationResults, boolean asText, boolean titlePrefix, boolean CSVReplacement, boolean appendComma, boolean appendNewLine) Static version to get formatted exit count. Is only meant to be used with filtered results that only have one error code. Could also just take size() if no format needed.- Parameters:
iterationResults- - the list of iteration results with only one exit code to get the exit count from.asText- - "occurrences" will be appended after the count number.titlePrefix- - if true, the variable name will be prefixed with "Exit code " + exitCode + ": "CSVReplacement- - if true, newlines and commas are removed.appendComma- - if true, a comma is appended afterwards.appendNewLine- - if true, a new line is appended afterwards.- Returns:
- Exit count of the only error code in the results, formatted as required in a String.
-
getFormattedExitCount
Default values of getFormattedExitCount().- Parameters:
iterationResults- - the list of iteration results with only one exit code to get the exit count from.- Returns:
- Exit count of the only error code in the results, without titles or text, with newlines and commas replaced, and with a comma appended afterwards.
-
getFormattedTotalIterations
public static String getFormattedTotalIterations(int totalIterations, boolean titlePrefix, boolean CSVReplacement, boolean appendComma, boolean appendNewLine) Gets the total number of iterations as a string.- Parameters:
totalIterations- - the total number of iterations as int.titlePrefix- - if true, the variable name will be prefixed with "Total Iterations: "CSVReplacement- -if true, newlines and commas are removed.appendComma- if true, a comma is appended afterwards.appendNewLine- - if true, a new line is appended afterwards.- Returns:
- The total number of iterations, formatted as required in a String.
-
getFormattedTotalIterations
Default values of getFormattedTotalIterations()- Parameters:
totalIterations- - the total number of iterations as int.- Returns:
- Total number of iterations, with newlines and commas replaced, and with a comma appended afterwards.
-
getFormattedTotalIterations
public String getFormattedTotalIterations(boolean titlePrefix, boolean CSVReplacement, boolean appendComma, boolean appendNewLine) Gets the total number of iterations of the list of iterations the formatter has been initialized with as a string.- Parameters:
titlePrefix- - if true, the variable name will be prefixed with "Total Iterations: "CSVReplacement- -if true, newlines and commas are removed.appendComma- if true, a comma is appended afterwards.appendNewLine- - if true, a new line is appended afterwards.- Returns:
- The total number of iterations, formatted as required in a String.
-
getFormattedTotalIterations
Default values of getFormattedTotalIterations()- Returns:
- Total number of iterations of the list of iterations the formatter has been initialized with, with newlines and commas replaced, and with a comma appended afterwards.
-
getFormattedExecutionTime
public static String getFormattedExecutionTime(String totalTime, boolean titlePrefix, boolean CSVReplacement, boolean appendComma, boolean appendNewLine) Gives the execution time formatted properly. Static because it is only used in the main method, and calculated once there. Therefore, remains the same over whole run.- Parameters:
totalTime- - The total time, already formatted as 00:00titlePrefix- - if true, the variable name will be prefixed with "Execution time: "CSVReplacement- -if true, newlines and commas are removed.appendComma- - if true, a comma is appended afterwards.appendNewLine- - if true, a new line is appended afterwards.- Returns:
- Execution time, formatted as required in a String.
-
getFormattedExecutionTime
Default values of getFormattedExecutionTime()- Parameters:
totalTime- The total time, already formatted as 00:00- Returns:
- Execution time formatted from the elapsedTime, with newlines and commas replaced, and with a comma appended afterwards.
-
getFormattedExecutionTime
public static String getFormattedExecutionTime(long elapsedTime, boolean titlePrefix, boolean CSVReplacement, boolean appendComma, boolean appendNewLine) Gives the execution time formatted properly. Static because it is only used in the main method, and calculated once there. Therefore, remains the same over whole run.- Parameters:
elapsedTime- Time start to finish of iterationresults (see Fuzzer main method), as int.titlePrefix- - if true, the variable name will be prefixed with "Execution time: "CSVReplacement- -if true, newlines and commas are removed.appendComma- - if true, a comma is appended afterwards.appendNewLine- - if true, a new line is appended afterwards.- Returns:
- Execution time, formatted as required in a String.
-
getFormattedExecutionTime
Default values of getFormattedExecutionTime()- Parameters:
elapsedTime- Time start to finish of iterationresults (see Fuzzer main method).- Returns:
- Execution time formatted from the elapsedTime, with newlines and commas replaced, and with a comma appended afterwards.
-
getFormattedTimeStamp
public static String getFormattedTimeStamp(String timeStamp, boolean titlePrefix, boolean CSVReplacement, boolean appendComma, boolean appendNewLine) Gets the given timestamp formatted properly.- Parameters:
timeStamp- - The timestamp, already formatted as dd-MM-HH HH:mm string.titlePrefix- - if true, the variable name will be prefixed with "Date and Time: "CSVReplacement- -if true, newlines and commas are removed.appendComma- - if true, a comma is appended afterwards.appendNewLine- - if true, a new line is appended afterwards.- Returns:
- Current timestamp, formatted as required in a String.
-
getFormattedTimeStamp
Default values of getFormattedTimeStamp()- Parameters:
timeStamp- - The timestamp, already formatted as dd-MM-HH HH:mm string.- Returns:
- Given timestamp formatted from the current timestamp, with newlines and commas replaced, and with a comma appended afterwards.
-
getFormattedTimeStamp
public static String getFormattedTimeStamp(boolean titlePrefix, boolean CSVReplacement, boolean appendComma, boolean appendNewLine) Gets the current timestamp formatted properly. Static because it is only used in the main method, and calculated once there. Therefore, remains the same over whole run.- Parameters:
titlePrefix- - if true, the variable name will be prefixed with "Date and Time: "CSVReplacement- -if true, newlines and commas are removed.appendComma- - if true, a comma is appended afterwards.appendNewLine- - if true, a new line is appended afterwards.- Returns:
- Current timestamp, formatted as required in a String.
-
getFormattedTimeStamp
Default values of getFormattedTimeStamp()- Returns:
- Current timestamp formatted from the current timestamp, with newlines and commas replaced, and with a comma appended afterwards.
-