Package net.sourceforge.pmd.renderers
Class AbstractRenderer
- java.lang.Object
-
- net.sourceforge.pmd.properties.AbstractPropertySource
-
- net.sourceforge.pmd.renderers.AbstractRenderer
-
- All Implemented Interfaces:
PropertySource
,Renderer
- Direct Known Subclasses:
AbstractAccumulatingRenderer
,AbstractIncrementingRenderer
,EmptyRenderer
public abstract class AbstractRenderer extends AbstractPropertySource implements Renderer
Abstract base class forRenderer
implementations.
-
-
Field Summary
Fields Modifier and Type Field Description protected String
description
protected List<String>
inputPathPrefixes
protected String
name
protected boolean
showSuppressedViolations
protected Writer
writer
-
Fields inherited from class net.sourceforge.pmd.properties.AbstractPropertySource
propertyDescriptors, propertyValuesByDescriptor
-
-
Constructor Summary
Constructors Constructor Description AbstractRenderer(String name, String description)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
determineFileName(String inputFileName)
Determines the filename that should be used in the report depending on the option "shortnames".void
flush()
String
getDescription()
Get the description of the Renderer.String
getName()
Get the name of the Renderer.protected String
getPropertySourceType()
Writer
getWriter()
Get the Writer for the Renderer.boolean
isShowSuppressedViolations()
Get the indicator for whether to show suppressed violations.void
setDescription(String description)
Set the description of the Renderer.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
setUseShortNames(List<String> inputPaths)
Render the filenames of found violations with short names.void
setWriter(Writer writer)
Set the Writer for the Renderer.-
Methods inherited from class net.sourceforge.pmd.properties.AbstractPropertySource
copyPropertyDescriptors, copyPropertyValues, definePropertyDescriptor, dysfunctionReason, getOverriddenPropertiesByPropertyDescriptor, getOverriddenPropertyDescriptors, getPropertiesByPropertyDescriptor, getProperty, getPropertyDescriptor, getPropertyDescriptors, hasDescriptor, ignoredProperties, isPropertyOverridden, setProperty, setProperty, useDefaultValueFor, usesDefaultValues
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sourceforge.pmd.properties.PropertySource
definePropertyDescriptor, dysfunctionReason, getOverriddenPropertiesByPropertyDescriptor, getOverriddenPropertyDescriptors, getPropertiesByPropertyDescriptor, getProperty, getPropertyDescriptor, getPropertyDescriptors, hasDescriptor, ignoredProperties, isPropertyOverridden, setProperty, setProperty, useDefaultValueFor, usesDefaultValues
-
Methods inherited from interface net.sourceforge.pmd.renderers.Renderer
defaultFileExtension, end, renderFileReport, start, startFileAnalysis
-
-
-
-
Method Detail
-
getPropertySourceType
protected String getPropertySourceType()
- Specified by:
getPropertySourceType
in classAbstractPropertySource
-
getName
public String getName()
Description copied from interface:Renderer
Get the name of the Renderer.- Specified by:
getName
in interfacePropertySource
- Specified by:
getName
in interfaceRenderer
- Returns:
- The name of the Renderer.
-
setName
public void setName(String name)
Description copied from interface:Renderer
Set the name of the Renderer.
-
getDescription
public String getDescription()
Description copied from interface:Renderer
Get the description of the Renderer.- Specified by:
getDescription
in interfaceRenderer
- Returns:
- The description of the Renderer.
-
setDescription
public void setDescription(String description)
Description copied from interface:Renderer
Set the description of the Renderer.- Specified by:
setDescription
in interfaceRenderer
- Parameters:
description
- The description of the Renderer.
-
isShowSuppressedViolations
public boolean isShowSuppressedViolations()
Description copied from interface:Renderer
Get the indicator for whether to show suppressed violations.- Specified by:
isShowSuppressedViolations
in interfaceRenderer
- Returns:
true
if suppressed violations should show,false
otherwise.
-
setShowSuppressedViolations
public void setShowSuppressedViolations(boolean showSuppressedViolations)
Description copied from interface:Renderer
Set the indicator for whether to show suppressed violations.- Specified by:
setShowSuppressedViolations
in interfaceRenderer
- Parameters:
showSuppressedViolations
- Whether to show suppressed violations.
-
setUseShortNames
public void setUseShortNames(List<String> inputPaths)
Description copied from interface:Renderer
Render the filenames of found violations with short names. That is, any prefix given as inputPaths is removed. By default, the full pathnames are used. If the given list ofinputPaths
is empty, then the full pathnames are used.- Specified by:
setUseShortNames
in interfaceRenderer
-
determineFileName
protected String determineFileName(String inputFileName)
Determines the filename that should be used in the report depending on the option "shortnames". If the option is enabled, then the filename in the report is without the directory prefix of the directories, that have been analyzed. If the option "shortnames" is not enabled, then the inputFileName is returned as-is.- Parameters:
inputFileName
-- Returns:
- See Also:
PMDConfiguration.isReportShortNames()
,PMDParameters.isShortnames()
-
setWriter
public void setWriter(Writer writer)
Description copied from interface:Renderer
Set the Writer for the Renderer.
-
getWriter
public Writer getWriter()
Description copied from interface:Renderer
Get the Writer for the Renderer.
-
setReportFile
@Experimental public 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
setReportFile(String)
for the default impl.This default implementation always uses the system default charset for the writer. Overwrite in specific renderers to support other charsets.
- Specified by:
setReportFile
in interfaceRenderer
- Parameters:
reportFilename
- the filename (optional).
-
-