Package org.revapi.reporter.file
Class AbstractFileReporter
- java.lang.Object
-
- org.revapi.reporter.file.AbstractFileReporter
-
- All Implemented Interfaces:
AutoCloseable
,org.revapi.configuration.Configurable
,org.revapi.Reporter
public abstract class AbstractFileReporter extends Object implements 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
Fields Modifier and Type Field Description protected org.revapi.AnalysisContext
analysis
protected File
file
protected boolean
keepEmptyFile
protected org.revapi.Criticality
minCriticality
protected org.revapi.DifferenceSeverity
minLevel
protected PrintWriter
output
protected boolean
shouldClose
-
Constructor Summary
Constructors Constructor Description AbstractFileReporter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
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
flushReports()
Subclasses should write the reports to theoutput
in this method.protected Comparator<org.revapi.Report>
getReportsByElementOrderComparator()
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.
-
-
-
Field Detail
-
minLevel
protected org.revapi.DifferenceSeverity minLevel
-
minCriticality
protected org.revapi.Criticality minCriticality
-
output
protected PrintWriter output
-
file
protected File file
-
shouldClose
protected boolean shouldClose
-
keepEmptyFile
protected boolean keepEmptyFile
-
analysis
protected org.revapi.AnalysisContext analysis
-
-
Method Detail
-
setOutput
protected void setOutput(PrintWriter wrt)
For testing.- Parameters:
wrt
- the output writer
-
flushReports
protected abstract void flushReports() throws IOException
Subclasses should write the reports to theoutput
in this method. This method MUST NOT close the output though.- Throws:
IOException
-
initialize
public void initialize(@Nonnull org.revapi.AnalysisContext analysis)
- Specified by:
initialize
in interfaceorg.revapi.configuration.Configurable
-
createOutputWriter
protected PrintWriter createOutputWriter(OutputStream stream, org.revapi.AnalysisContext ctx)
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
public void report(@Nonnull 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.- 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
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Throws:
IOException
-
getReportsByElementOrderComparator
protected Comparator<org.revapi.Report> getReportsByElementOrderComparator()
- Returns:
- a comparator that can be used to sort the reports in the order of the compared elements.
- See Also:
ReportComparator
-
-