Package gov.nasa.pds.citool.report
Class Report
- java.lang.Object
-
- gov.nasa.pds.citool.report.Report
-
- Direct Known Subclasses:
CompareReport
,IngestReport
,NewStandardValuesReport
,ReferentialIntegrityReport
,ValidateReport
public abstract class Report extends Object
Abstract class that represents a Report for the Vtool command line API. This class handles basic utilities for reporting and calling customized portions of reports.- Author:
- pramirez
-
-
Field Summary
Fields Modifier and Type Field Description protected List<String>
configurations
protected List<String>
parameters
-
Constructor Summary
Constructors Constructor Description Report()
Default constructor to initialize report variables.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addConfiguration(String configuration)
Adds the string supplied to the configuration section in the heading of the report.void
addParameter(String parameter)
Adds the string supplied to the parameter section in the heading of the report.protected List<gov.nasa.pds.tools.LabelParserException>
filterProblems(List<gov.nasa.pds.tools.LabelParserException> problems)
gov.nasa.pds.tools.constants.Constants.Severity
getLevel()
int
getNumFailed()
int
getNumPassed()
int
getNumSkipped()
PrintWriter
getOutput()
int
getTotalErrors()
int
getTotalInfos()
int
getTotalWarnings()
boolean
hasErrors()
boolean
hasWarnings()
void
printFooter()
Prints out the footer or the report and calls the customized footer section.protected abstract void
printFooter(PrintWriter writer)
Allows customization of the footer section of the reportvoid
printHeader()
This method will display the default header for the Vtool command line library reports.protected abstract void
printHeader(PrintWriter writer)
Allows a Report to customize the header portion of the Report if necessary.protected abstract void
printRecordMessages(PrintWriter writer, Status status, URI sourceUri, List<gov.nasa.pds.tools.LabelParserException> problems)
Allows a report to customize how it handles reporting on a particular label.protected abstract void
printRecordMessages(PrintWriter writer, Status status, List<String> sourceUris, List<gov.nasa.pds.tools.LabelParserException> problems)
protected void
printRecordSkip(PrintWriter writer, URI sourceUri, Exception exception)
protected void
printRecordSkip(PrintWriter writer, List<String> sourceUris, Exception exception)
Status
record(File source, List<gov.nasa.pds.tools.LabelParserException> problems)
Status
record(URI sourceUri, List<gov.nasa.pds.tools.LabelParserException> problems)
Allows a report to change how they manage reporting on a given file that has been parsed and validated.Status
record(List<String> sourceUris, List<gov.nasa.pds.tools.LabelParserException> problems)
Allows a report to change how they manage reporting on a given file that has been parsed and validated.Status
recordSkip(URI sourceUri, Exception exception)
Status
recordSkip(List<String> sourceUris, Exception exception)
void
setLevel(gov.nasa.pds.tools.constants.Constants.Severity severity)
Anything at or above the level will be reported.void
setOutput(File file)
Handles writing a Report to aFile
.void
setOutput(OutputStream os)
Handle writing a Report to anOutputStream
.void
setOutput(Writer writer)
Handles writing a Report to the writer interface.
-
-
-
Method Detail
-
setOutput
public final void setOutput(Writer writer)
Handles writing a Report to the writer interface. This is is useful if someone would like to put the contents of the Report to something such asStringWriter
.- Parameters:
writer
- which the report will be written to
-
setOutput
public final void setOutput(OutputStream os)
Handle writing a Report to anOutputStream
. This is useful to get the report to print to something such as System.out- Parameters:
os
- stream which the report will be written to
-
setOutput
public final void setOutput(File file) throws IOException
Handles writing a Report to aFile
.- Parameters:
file
- which the report will output to- Throws:
IOException
- if there is an issue in writing the report to the file
-
getOutput
public final PrintWriter getOutput()
-
printHeader
public void printHeader()
This method will display the default header for the Vtool command line library reports. This is the standard header across all reports.
-
addParameter
public void addParameter(String parameter)
Adds the string supplied to the parameter section in the heading of the report.- Parameters:
parameter
- in a string form that represents something that was passed in when the tool was run
-
addConfiguration
public void addConfiguration(String configuration)
Adds the string supplied to the configuration section in the heading of the report.- Parameters:
configuration
- in a string form that represents a configuration that was used during parsing and validation
-
printHeader
protected abstract void printHeader(PrintWriter writer)
Allows a Report to customize the header portion of the Report if necessary.- Parameters:
writer
- passed down to write header contents to
-
record
public Status record(URI sourceUri, List<gov.nasa.pds.tools.LabelParserException> problems)
Allows a report to change how they manage reporting on a given file that has been parsed and validated. Also handles generating a status for a file and generating some summary statistics.- Parameters:
sourceUri
- reference to the file that is being reported onproblems
- the set of issues found with the file. to be reported on- Returns:
- status of the file (i.e. PASS, FAIL, or SKIP)
-
filterProblems
protected List<gov.nasa.pds.tools.LabelParserException> filterProblems(List<gov.nasa.pds.tools.LabelParserException> problems)
-
record
public Status record(List<String> sourceUris, List<gov.nasa.pds.tools.LabelParserException> problems)
Allows a report to change how they manage reporting on a given file that has been parsed and validated. Also handles generating a status for a file and generating some summary statistics.- Parameters:
sourceUris
- reference to the file that is being reported onproblems
- the set of issues found with the file. to be reported on- Returns:
- status of the file (i.e. PASS, FAIL, or SKIP)
-
printRecordSkip
protected void printRecordSkip(PrintWriter writer, URI sourceUri, Exception exception)
-
printRecordSkip
protected void printRecordSkip(PrintWriter writer, List<String> sourceUris, Exception exception)
-
printRecordMessages
protected abstract void printRecordMessages(PrintWriter writer, Status status, URI sourceUri, List<gov.nasa.pds.tools.LabelParserException> problems)
Allows a report to customize how it handles reporting on a particular label.- Parameters:
writer
- passed on to write customized messages tosourceUri
- reference to the file that is being reported onproblems
- which to report on for this source
-
printRecordMessages
protected abstract void printRecordMessages(PrintWriter writer, Status status, List<String> sourceUris, List<gov.nasa.pds.tools.LabelParserException> problems)
-
printFooter
public void printFooter()
Prints out the footer or the report and calls the customized footer section.
-
printFooter
protected abstract void printFooter(PrintWriter writer)
Allows customization of the footer section of the report- Parameters:
writer
- passed on to writer customized footer contents
-
getNumPassed
public int getNumPassed()
- Returns:
- number of labels that passed (had no errors)
-
getNumFailed
public int getNumFailed()
- Returns:
- number of labels that failed (had one or more errors)
-
getNumSkipped
public int getNumSkipped()
- Returns:
- number of files that were not recognized as a label
-
getTotalErrors
public int getTotalErrors()
- Returns:
- total number of errors that were found across all labels inspected. Will not count errors generated from files that were considered skipped.
-
getTotalWarnings
public int getTotalWarnings()
- Returns:
- total number of warning that were found across all labels inspected. Will not count warnings generated from files that were considered skipped.
-
getTotalInfos
public int getTotalInfos()
- Returns:
- total number of info messages that were found across all labels inspected. Will not count info messages from files that were considered skipped.
-
hasErrors
public boolean hasErrors()
- Returns:
- flag indicating if errors were found in the inspected files
-
hasWarnings
public boolean hasWarnings()
- Returns:
- flag indicating if warnings were found in the inspected files
-
setLevel
public void setLevel(gov.nasa.pds.tools.constants.Constants.Severity severity)
Anything at or above the level will be reported. Default severity level is info and above- Parameters:
severity
- level on which items will be reported
-
getLevel
public gov.nasa.pds.tools.constants.Constants.Severity getLevel()
- Returns:
- severity level of items that will be reported on. Anything at or above this level will be reported on
-
-