net.sourceforge.pmd
Class PMDConfiguration

java.lang.Object
  extended by net.sourceforge.pmd.AbstractConfiguration
      extended by net.sourceforge.pmd.PMDConfiguration

public class PMDConfiguration
extends AbstractConfiguration

This class contains the details for the runtime configuration of PMD. There are several aspects to the configuration of PMD.

The aspects related to generic PMD behavior:

The aspects related to Rules and Source files are:

The aspects related to special PMD behavior are:


Constructor Summary
PMDConfiguration()
           
 
Method Summary
 Renderer createRenderer()
          Create a Renderer instance based upon the configured reporting options.
 Renderer createRenderer(boolean withReportWriter)
          Create a Renderer instance based upon the configured reporting options.
 ClassLoader getClassLoader()
          Get the ClassLoader being used by PMD when processing Rules.
 String getInputPaths()
          Get the comma separated list of input paths to process for source files.
 String getInputUri()
          Get the input URI to process for source code objects.
 LanguageVersionDiscoverer getLanguageVersionDiscoverer()
          Get the LanguageVersionDiscoverer, used to determine the LanguageVersion of a source file.
 LanguageVersion getLanguageVersionOfFile(String fileName)
          Get the LanguageVersion of the source file with given name.
 RulePriority getMinimumPriority()
          Get the minimum priority threshold when loading Rules from RuleSets.
 RuleSets getPmdRuleSets()
          Get the RuleSets.
 String getReportFile()
          Get the file to which the report should render.
 String getReportFormat()
          Get the report format.
 Properties getReportProperties()
          Get the Report properties.
 String getRuleSets()
          Get the comma separated list of RuleSet URIs.
 String getSuppressMarker()
          Get the suppress marker.
 int getThreads()
          Get the number of threads to use when processing Rules.
 boolean isBenchmark()
          Return the benchmark indicator.
 boolean isReportShortNames()
          Get whether to use File short names in Reports.
 boolean isShowSuppressedViolations()
          Get whether the report should show suppressed violations.
 boolean isStressTest()
          Return the stress test indicator.
 void prependClasspath(String classpath)
          Prepend the specified classpath like string to the current ClassLoader of the configuration.
 void setBenchmark(boolean benchmark)
          Set the benchmark indicator.
 void setClassLoader(ClassLoader classLoader)
          Set the ClassLoader being used by PMD when processing Rules.
 void setDefaultLanguageVersion(LanguageVersion languageVersion)
          Set the given LanguageVersion as the current default for it's Language.
 void setDefaultLanguageVersions(List<LanguageVersion> languageVersions)
          Set the given LanguageVersions as the current default for their Languages.
 void setInputPaths(String inputPaths)
          Set the comma separated list of input paths to process for source files.
 void setInputUri(String inputUri)
          Set the input URI to process for source code objects.
 void setMinimumPriority(RulePriority minimumPriority)
          Set the minimum priority threshold when loading Rules from RuleSets.
 void setPmdRuleSets(RuleSets pmdRuleSets)
          Set the RuleSets
 void setReportFile(String reportFile)
          Set the file to which the report should render.
 void setReportFormat(String reportFormat)
          Set the report format.
 void setReportProperties(Properties reportProperties)
          Set the Report properties.
 void setReportShortNames(boolean reportShortNames)
          Set whether to use File short names in Reports.
 void setRuleSets(String ruleSets)
          Set the comma separated list of RuleSet URIs.
 void setShowSuppressedViolations(boolean showSuppressedViolations)
          Set whether the report should show suppressed violations.
 void setStressTest(boolean stressTest)
          Set the stress test indicator.
 void setSuppressMarker(String suppressMarker)
          Set the suppress marker.
 void setThreads(int threads)
          Set the number of threads to use when processing Rules.
 
Methods inherited from class net.sourceforge.pmd.AbstractConfiguration
getSourceEncoding, isDebug, setDebug, setSourceEncoding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PMDConfiguration

public PMDConfiguration()
Method Detail

getSuppressMarker

public String getSuppressMarker()
Get the suppress marker. This is the source level marker used to indicate a RuleViolation should be suppressed.

Returns:
The suppress marker.

setSuppressMarker

public void setSuppressMarker(String suppressMarker)
Set the suppress marker.

Parameters:
suppressMarker - The suppress marker to use.

getThreads

public int getThreads()
Get the number of threads to use when processing Rules.

Returns:
The number of threads.

setThreads

public void setThreads(int threads)
Set the number of threads to use when processing Rules.

Parameters:
threads - The number of threads.

getClassLoader

public ClassLoader getClassLoader()
Get the ClassLoader being used by PMD when processing Rules.

Returns:
The ClassLoader being used

setClassLoader

public void setClassLoader(ClassLoader classLoader)
Set the ClassLoader being used by PMD when processing Rules. Setting a value of null will cause the default ClassLoader to be used.

Parameters:
classLoader - The ClassLoader to use

prependClasspath

public void prependClasspath(String classpath)
                      throws IOException
Prepend the specified classpath like string to the current ClassLoader of the configuration. If no ClassLoader is currently configured, the ClassLoader used to load the PMDConfiguration class will be used as the parent ClassLoader of the created ClassLoader.

If the classpath String looks like a URL to a file (i.e. starts with file://) the file will be read with each line representing an entry on the classpath.

Parameters:
classpath - The prepended classpath.
Throws:
IOException - if the given classpath is invalid (e.g. does not exist)
See Also:
setClassLoader(ClassLoader), ClasspathClassLoader

getLanguageVersionDiscoverer

public LanguageVersionDiscoverer getLanguageVersionDiscoverer()
Get the LanguageVersionDiscoverer, used to determine the LanguageVersion of a source file.

Returns:
The LanguageVersionDiscoverer.

setDefaultLanguageVersion

public void setDefaultLanguageVersion(LanguageVersion languageVersion)
Set the given LanguageVersion as the current default for it's Language.

Parameters:
languageVersion - the LanguageVersion

setDefaultLanguageVersions

public void setDefaultLanguageVersions(List<LanguageVersion> languageVersions)
Set the given LanguageVersions as the current default for their Languages.

Parameters:
languageVersions - The LanguageVersions.

getLanguageVersionOfFile

public LanguageVersion getLanguageVersionOfFile(String fileName)
Get the LanguageVersion of the source file with given name. This depends on the fileName extension, and the java version.

For compatibility with older code that does not always pass in a correct filename, unrecognized files are assumed to be java files.

Parameters:
fileName - Name of the file, can be absolute, or simple.
Returns:
the LanguageVersion

getRuleSets

public String getRuleSets()
Get the comma separated list of RuleSet URIs.

Returns:
The RuleSet URIs.

setRuleSets

public void setRuleSets(String ruleSets)
Set the comma separated list of RuleSet URIs.

Parameters:
ruleSets - the rulesets to set

getPmdRuleSets

public RuleSets getPmdRuleSets()
Get the RuleSets.

Returns:
the pmdRuleSets

setPmdRuleSets

public void setPmdRuleSets(RuleSets pmdRuleSets)
Set the RuleSets

Parameters:
pmdRuleSets - the pmdRuleSets to set

getMinimumPriority

public RulePriority getMinimumPriority()
Get the minimum priority threshold when loading Rules from RuleSets.

Returns:
The minimum priority threshold.

setMinimumPriority

public void setMinimumPriority(RulePriority minimumPriority)
Set the minimum priority threshold when loading Rules from RuleSets.

Parameters:
minimumPriority - The minimum priority.

getInputPaths

public String getInputPaths()
Get the comma separated list of input paths to process for source files.

Returns:
A comma separated list.

setInputPaths

public void setInputPaths(String inputPaths)
Set the comma separated list of input paths to process for source files.

Parameters:
inputPaths - The comma separated list.

getInputUri

public String getInputUri()
Get the input URI to process for source code objects.

Returns:
URI

setInputUri

public void setInputUri(String inputUri)
Set the input URI to process for source code objects.

Parameters:
inputUri - a single URI

isReportShortNames

public boolean isReportShortNames()
Get whether to use File short names in Reports.

Returns:
true when using short names in reports.

setReportShortNames

public void setReportShortNames(boolean reportShortNames)
Set whether to use File short names in Reports.

Parameters:
reportShortNames - true when using short names in reports.

createRenderer

public Renderer createRenderer()
Create a Renderer instance based upon the configured reporting options. No writer is created.

Returns:
renderer

createRenderer

public Renderer createRenderer(boolean withReportWriter)
Create a Renderer instance based upon the configured reporting options. If withReportWriter then we'll configure it with a writer for the reportFile specified.

Parameters:
withReportWriter - whether to configure a writer or not
Returns:
A Renderer instance.

getReportFormat

public String getReportFormat()
Get the report format.

Returns:
The report format.

setReportFormat

public void setReportFormat(String reportFormat)
Set the report format. This should be a name of a Renderer.

Parameters:
reportFormat - The report format.
See Also:
Renderer

getReportFile

public String getReportFile()
Get the file to which the report should render.

Returns:
The file to which to render.

setReportFile

public void setReportFile(String reportFile)
Set the file to which the report should render.

Parameters:
reportFile - the file to set

isShowSuppressedViolations

public boolean isShowSuppressedViolations()
Get whether the report should show suppressed violations.

Returns:
true if showing suppressed violations, false otherwise.

setShowSuppressedViolations

public void setShowSuppressedViolations(boolean showSuppressedViolations)
Set whether the report should show suppressed violations.

Parameters:
showSuppressedViolations - true if showing suppressed violations, false otherwise.

getReportProperties

public Properties getReportProperties()
Get the Report properties. These are used to create the Renderer.

Returns:
The report properties.

setReportProperties

public void setReportProperties(Properties reportProperties)
Set the Report properties. These are used to create the Renderer.

Parameters:
reportProperties - The Report properties to set.

isStressTest

public boolean isStressTest()
Return the stress test indicator. If this value is true then PMD will randomize the order of file processing to attempt to shake out bugs.

Returns:
true if stress test is enbaled, false otherwise.

setStressTest

public void setStressTest(boolean stressTest)
Set the stress test indicator.

Parameters:
stressTest - The stree test indicator to set.
See Also:
isStressTest()

isBenchmark

public boolean isBenchmark()
Return the benchmark indicator. If this value is true then PMD will log benchmark information.

Returns:
true if benchmark logging is enbaled, false otherwise.

setBenchmark

public void setBenchmark(boolean benchmark)
Set the benchmark indicator.

Parameters:
benchmark - The benchmark indicator to set.
See Also:
isBenchmark()


Copyright © 2002-2015 InfoEther. All Rights Reserved.