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.AnalysisContext
protected File
protected boolean
protected org.revapi.Criticality
protected org.revapi.DifferenceSeverity
protected PrintWriter
protected boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
protected PrintWriter
createOutputWriter
(OutputStream stream, org.revapi.AnalysisContext ctx) Creates a print writer to be used as an output from the supplied output stream.protected abstract void
doReport
(org.revapi.Report report) The report contains differences of at least the configured severity.protected abstract void
Subclasses should write the reports to theoutput
in this method.protected Comparator
<org.revapi.Report> void
initialize
(org.revapi.AnalysisContext analysis) protected boolean
isReportable
(org.revapi.Report report) void
report
(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 void
setOutput
(PrintWriter wrt) For testing.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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 theoutput
in this method. This method MUST NOT close the output though.- Throws:
IOException
-
initialize
- Specified by:
initialize
in 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:
report
in 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:
close
in interfaceAutoCloseable
- Throws:
IOException
-
getReportsByElementOrderComparator
- Returns:
- a comparator that can be used to sort the reports in the order of the compared elements.
- See Also:
-