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.AnalysisContextanalysisprotected Filefileprotected booleankeepEmptyFileprotected org.revapi.CriticalityminCriticalityprotected org.revapi.DifferenceSeverityminLevelprotected PrintWriteroutputprotected booleanshouldClose
-
Constructor Summary
Constructors Constructor Description AbstractFileReporter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()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 voidflushReports()Subclasses should write the reports to theoutputin this method.protected Comparator<org.revapi.Report>getReportsByElementOrderComparator()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.
-
-
-
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 IOExceptionSubclasses should write the reports to theoutputin this method. This method MUST NOT close the output though.- Throws:
IOException
-
initialize
public void initialize(@Nonnull org.revapi.AnalysisContext analysis)
- Specified by:
initializein 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:
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
public void close() throws IOException- Specified by:
closein 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
-
-