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 for Renderer implementations.
  • Field Details

    • name

      protected String name
    • description

      protected String description
    • showSuppressedViolations

      protected boolean showSuppressedViolations
    • writer

      protected PrintWriter writer
  • Constructor Details

    • AbstractRenderer

      public AbstractRenderer(String name, String description)
  • Method Details

    • getPropertySourceType

      protected String getPropertySourceType()
      Specified by:
      getPropertySourceType in class AbstractPropertySource
    • getName

      public String getName()
      Description copied from interface: Renderer
      Get the name of the Renderer.
      Specified by:
      getName in interface PropertySource
      Specified by:
      getName in interface Renderer
      Returns:
      The name of the Renderer.
    • setName

      public void setName(String name)
      Description copied from interface: Renderer
      Set the name of the Renderer.
      Specified by:
      setName in interface Renderer
      Parameters:
      name - The name of the Renderer.
    • getDescription

      public String getDescription()
      Description copied from interface: Renderer
      Get the description of the Renderer.
      Specified by:
      getDescription in interface Renderer
      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 interface Renderer
      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 interface Renderer
      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 interface Renderer
      Parameters:
      showSuppressedViolations - Whether to show suppressed violations.
    • setFileNameRenderer

      public void setFileNameRenderer(FileNameRenderer fileNameRenderer)
      Description copied from interface: Renderer
      Set the FileNameRenderer 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.
      Specified by:
      setFileNameRenderer in interface Renderer
      Parameters:
      fileNameRenderer - a non-null file name renderer
    • determineFileName

      protected final String determineFileName(FileId fileId)
      Determines the filename that should be used in the report for the given ID. This uses the FileNameRenderer of this renderer. In the PMD CLI, the file name renderer respects the AbstractConfiguration.getRelativizeRoots() relativize roots to output relative paths.

      A renderer does not have to use this method to output paths. Some report formats require a specific format for paths, eg URIs. They can implement this ad-hoc.

    • setWriter

      public void setWriter(Writer writer)
      Description copied from interface: Renderer
      Set the Writer for the Renderer.
      Specified by:
      setWriter in interface Renderer
      Parameters:
      writer - The Writer.
    • getWriter

      public Writer getWriter()
      Description copied from interface: Renderer
      Get the Writer for the Renderer.
      Specified by:
      getWriter in interface Renderer
      Returns:
      The Writer.
    • flush

      public void flush()
      Specified by:
      flush in interface Renderer
    • setReportFile

      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 interface Renderer
      Parameters:
      reportFilename - the filename (optional).