Package net.sourceforge.pmd.renderers
Interface Renderer
-
- All Superinterfaces:
PropertySource
- All Known Implementing Classes:
AbstractAccumulatingRenderer
,AbstractIncrementingRenderer
,AbstractRenderer
,CodeClimateRenderer
,CSVRenderer
,EmacsRenderer
,EmptyRenderer
,HTMLRenderer
,IDEAJRenderer
,JsonRenderer
,SarifRenderer
,SummaryHTMLRenderer
,TextColorRenderer
,TextPadRenderer
,TextRenderer
,VBHTMLRenderer
,XMLRenderer
,XSLTRenderer
,YAHTMLRenderer
public interface Renderer extends PropertySource
This is an interface for rendering a Report. When a Renderer is being invoked, the sequence of method calls is something like the following:- Renderer construction/initialization
setShowSuppressedViolations(boolean)
setWriter(Writer)
start()
startFileAnalysis(TextFile)
for each source file processedrenderFileReport(Report)
for each Report instanceend()
An implementation of the Renderer interface is expected to have a default constructor. Properties should be defined using the
PropertySource.definePropertyDescriptor(PropertyDescriptor)
method. After the instance is created, the property values are set. This means, you won't have access to property values in your constructor.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description String
defaultFileExtension()
Return the default filename extension to use.void
end()
This method is at the very end of the Rendering process, afterrenderFileReport(Report)
.void
flush()
String
getDescription()
Get the description of the Renderer.String
getName()
Get the name of the Renderer.Writer
getWriter()
Get the Writer for the Renderer.boolean
isShowSuppressedViolations()
Get the indicator for whether to show suppressed violations.default GlobalAnalysisListener
newListener()
Returns a new analysis listener, that handles violations by rendering them in an implementation-defined way.void
renderFileReport(Report report)
Render the given file Report.void
setDescription(String description)
Set the description of the Renderer.void
setFileNameRenderer(FileNameRenderer fileNameRenderer)
Set theFileNameRenderer
used to render file paths to the report.void
setName(String name)
Set the name of the Renderer.void
setReportFile(String reportFilename)
Sets the filename where the report should be written to.void
setShowSuppressedViolations(boolean showSuppressedViolations)
Set the indicator for whether to show suppressed violations.void
setWriter(Writer writer)
Set the Writer for the Renderer.void
start()
This method is called before any source files are processed.void
startFileAnalysis(TextFile dataSource)
This method is called each time a source file is processed.-
Methods inherited from interface net.sourceforge.pmd.properties.PropertySource
definePropertyDescriptor, dysfunctionReason, getOverriddenPropertiesByPropertyDescriptor, getOverriddenPropertyDescriptors, getPropertiesByPropertyDescriptor, getProperty, getPropertyDescriptor, getPropertyDescriptors, hasDescriptor, isPropertyOverridden, setProperty, setProperty
-
-
-
-
Method Detail
-
getName
String getName()
Get the name of the Renderer.- Specified by:
getName
in interfacePropertySource
- Returns:
- The name of the Renderer.
-
setName
void setName(String name)
Set the name of the Renderer.- Parameters:
name
- The name of the Renderer.
-
getDescription
String getDescription()
Get the description of the Renderer.- Returns:
- The description of the Renderer.
-
defaultFileExtension
String defaultFileExtension()
Return the default filename extension to use.- Returns:
- String
-
setDescription
void setDescription(String description)
Set the description of the Renderer.- Parameters:
description
- The description of the Renderer.
-
isShowSuppressedViolations
boolean isShowSuppressedViolations()
Get the indicator for whether to show suppressed violations.- Returns:
true
if suppressed violations should show,false
otherwise.
-
setShowSuppressedViolations
void setShowSuppressedViolations(boolean showSuppressedViolations)
Set the indicator for whether to show suppressed violations.- Parameters:
showSuppressedViolations
- Whether to show suppressed violations.
-
getWriter
Writer getWriter()
Get the Writer for the Renderer.- Returns:
- The Writer.
-
setFileNameRenderer
void setFileNameRenderer(FileNameRenderer fileNameRenderer)
Set theFileNameRenderer
used to render file paths to the report. Note that this renderer does not have to use the parameter to output paths. Some report formats require a specific format for paths (eg a URI), and are allowed to circumvent the provided strategy.- Parameters:
fileNameRenderer
- a non-null file name renderer
-
setWriter
void setWriter(Writer writer)
Set the Writer for the Renderer.- Parameters:
writer
- The Writer.
-
start
void start() throws IOException
This method is called before any source files are processed. The Renderer will have been fully initialized by the time this method is called, so the Writer and other state will be available.- Throws:
IOException
-
startFileAnalysis
void startFileAnalysis(TextFile dataSource)
This method is called each time a source file is processed. It is called afterstart()
, but beforerenderFileReport(Report)
andend()
. This method may be invoked by different threads which are processing files independently. Therefore, any non-trivial implementation of this method needs to be thread-safe.- Parameters:
dataSource
- The source file.
-
renderFileReport
void renderFileReport(Report report) throws IOException
Render the given file Report. There may be multiple Report instances which need to be rendered if produced by different threads. It is called afterstart()
andstartFileAnalysis(TextFile)
, but beforeend()
.- Parameters:
report
- A file Report.- Throws:
IOException
- See Also:
Report
-
end
void end() throws IOException
This method is at the very end of the Rendering process, afterrenderFileReport(Report)
.- Throws:
IOException
-
flush
void flush() throws IOException
- Throws:
IOException
-
setReportFile
@Experimental void setReportFile(String reportFilename)
Sets the filename where the report should be written to. If no filename is provided, the renderer should write to stdout.Implementations must initialize the writer of the renderer.
See
AbstractRenderer.setReportFile(String)
for the default impl.- Parameters:
reportFilename
- the filename (optional).
-
newListener
default GlobalAnalysisListener newListener() throws IOException
Returns a new analysis listener, that handles violations by rendering them in an implementation-defined way.- Throws:
IOException
-
-