Class AbstractFileReporter
java.lang.Object
org.revapi.reporter.file.AbstractFileReporter
- All Implemented Interfaces:
AutoCloseable,org.revapi.configuration.Configurable,org.revapi.Reporter
This class can be used as a base class for reporters that want to write the reports into the files. It provides some
basic features like difference filtering based on severity, the ability to specify the file to write to (including
"out" and "err" as special file names for standard output and standard error) and whether to overwrite or append to
an existing file.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.revapi.AnalysisContextprotected Fileprotected booleanprotected org.revapi.Criticalityprotected org.revapi.DifferenceSeverityprotected PrintWriterprotected boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected PrintWritercreateOutputWriter(OutputStream stream, org.revapi.AnalysisContext ctx) Creates a print writer to be used as an output from the supplied output stream.protected abstract voiddoReport(org.revapi.Report report) The report contains differences of at least the configured severity.protected abstract voidSubclasses should write the reports to theoutputin this method.protected Comparator<org.revapi.Report> voidinitialize(org.revapi.AnalysisContext analysis) protected booleanisReportable(org.revapi.Report report) voidreport(org.revapi.Report report) This is the default implementation of the report method that does the initial filtering based on the configured minimum severity and then delegates todoReport(Report)if the reporting should really be performed.protected voidsetOutput(PrintWriter wrt) For testing.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.revapi.configuration.Configurable
getExtensionId, getJSONSchema
-
Field Details
-
minLevel
protected org.revapi.DifferenceSeverity minLevel -
minCriticality
protected org.revapi.Criticality minCriticality -
output
-
file
-
shouldClose
protected boolean shouldClose -
keepEmptyFile
protected boolean keepEmptyFile -
analysis
protected org.revapi.AnalysisContext analysis
-
-
Constructor Details
-
AbstractFileReporter
public AbstractFileReporter()
-
-
Method Details
-
setOutput
-
flushReports
Subclasses should write the reports to theoutputin this method. This method MUST NOT close the output though.- Throws:
IOException
-
initialize
- Specified by:
initializein interfaceorg.revapi.configuration.Configurable
-
createOutputWriter
Creates a print writer to be used as an output from the supplied output stream. This method is called during the defaultinitialize(AnalysisContext)and the default implementation creates a print writer writing in UTF-8.- Parameters:
stream- the stream to convert to a print writerctx- the analysis context which is being used ininitialize(AnalysisContext)- Returns:
- a print writer to be used as output
-
report
This is the default implementation of the report method that does the initial filtering based on the configured minimum severity and then delegates todoReport(Report)if the reporting should really be performed.- Specified by:
reportin interfaceorg.revapi.Reporter- Parameters:
report- the report with the differences
-
isReportable
protected boolean isReportable(org.revapi.Report report) -
doReport
protected abstract void doReport(org.revapi.Report report) The report contains differences of at least the configured severity. This method is called fromreport(Report)by default. -
close
- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-
getReportsByElementOrderComparator
- Returns:
- a comparator that can be used to sort the reports in the order of the compared elements.
- See Also:
-