net.sourceforge.pmd

Class PMD

public class PMD extends Object

BSD-style license; for more info see http://pmd.sourceforge.net/license.html
Field Summary
static StringEOL
static StringEXCLUDE_MARKER
static StringVERSION
Constructor Summary
PMD()
Method Summary
static ClassLoadercreateClasspathClassLoader(String classpath)
Create a ClassLoader which loads classes using a CLASSPATH like String.
ClassLoadergetClassLoader()
Get the ClassLoader being used by PMD when processing Rules.
static voidmain(String[] args)
voidprocessFile(Reader reader, RuleSets ruleSets, RuleContext ctx)
Processes the file read by the reader against the rule set.
voidprocessFile(Reader reader, RuleSets ruleSets, RuleContext ctx, SourceType sourceType)
Processes the file read by the reader against the rule set.
voidprocessFile(Reader reader, RuleSet ruleSet, RuleContext ctx)
Processes the file read by the reader against the rule set.
voidprocessFile(InputStream fileContents, String encoding, RuleSet ruleSet, RuleContext ctx)
Processes the input stream against a rule set using the given input encoding.
voidprocessFile(InputStream fileContents, String encoding, RuleSets ruleSets, RuleContext ctx)
Processes the input stream against a rule set using the given input encoding.
voidprocessFile(InputStream fileContents, RuleSet ruleSet, RuleContext ctx)
Processes the input stream against a rule set assuming the platform character set.
static voidprocessFiles(int threadCount, RuleSetFactory ruleSetFactory, SourceType sourceType, List<DataSource> files, RuleContext ctx, List<Renderer> renderers, String rulesets, boolean shortNamesEnabled, String inputPath, String encoding, String excludeMarker, ClassLoader classLoader)
Run PMD on a list of files using multiple threads.
static voidprocessFiles(int threadCount, RuleSetFactory ruleSetFactory, SourceType sourceType, List<DataSource> files, RuleContext ctx, List<Renderer> renderers, boolean stressTestEnabled, String rulesets, boolean shortNamesEnabled, String inputPath, String encoding, String excludeMarker, ClassLoader classLoader)
Run PMD on a list of files using multiple threads.
voidprocessFiles(List<DataSource> files, RuleContext ctx, RuleSets rulesets, boolean debugEnabled, boolean shortNamesEnabled, String inputPath, String encoding)
Run PMD on a list of files.
voidsetClassLoader(ClassLoader classLoader)
Set the ClassLoader being used by PMD when processing Rules.
voidsetExcludeMarker(String marker)
voidsetJavaVersion(SourceType javaVersion)
Set the SourceType to be used for ".java" files.

Field Detail

EOL

public static final String EOL

EXCLUDE_MARKER

public static final String EXCLUDE_MARKER

VERSION

public static final String VERSION

Constructor Detail

PMD

public PMD()

Method Detail

createClasspathClassLoader

public static ClassLoader createClasspathClassLoader(String classpath)
Create a ClassLoader which loads classes using a CLASSPATH like String. If the String looks like a URL to a file (e.g. starts with file://) the file will be read with each line representing an entry on the classpath.

The ClassLoader used to load the net.sourceforge.pmd.PMD class will be used as the parent ClassLoader of the created ClassLoader.

Parameters: classpath The classpath String.

Returns: A ClassLoader

Throws: IOException

See Also: ClasspathClassLoader

getClassLoader

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

Returns: The ClassLoader being used

main

public static void main(String[] args)

processFile

public void processFile(Reader reader, RuleSets ruleSets, RuleContext ctx)
Processes the file read by the reader against the rule set.

Parameters: reader input stream reader ruleSets set of rules to process against the file ctx context in which PMD is operating. This contains the Renderer and whatnot

Throws: PMDException if the input could not be parsed or processed

processFile

public void processFile(Reader reader, RuleSets ruleSets, RuleContext ctx, SourceType sourceType)
Processes the file read by the reader against the rule set.

Parameters: reader input stream reader ruleSets set of rules to process against the file ctx context in which PMD is operating. This contains the Renderer and whatnot sourceType the SourceType of the source

Throws: PMDException if the input could not be parsed or processed

processFile

public void processFile(Reader reader, RuleSet ruleSet, RuleContext ctx)
Processes the file read by the reader against the rule set.

Parameters: reader input stream reader ruleSet set of rules to process against the file ctx context in which PMD is operating. This contains the Renderer and whatnot

Throws: PMDException if the input could not be parsed or processed

processFile

public void processFile(InputStream fileContents, String encoding, RuleSet ruleSet, RuleContext ctx)
Processes the input stream against a rule set using the given input encoding.

Parameters: fileContents an input stream to analyze encoding input stream's encoding ruleSet set of rules to process against the file ctx context in which PMD is operating. This contains the Report and whatnot

Throws: PMDException if the input encoding is unsupported or the input stream could not be parsed

See Also: PMD

processFile

public void processFile(InputStream fileContents, String encoding, RuleSets ruleSets, RuleContext ctx)
Processes the input stream against a rule set using the given input encoding.

Parameters: fileContents an input stream to analyze encoding input stream's encoding ruleSets set of rules to process against the file ctx context in which PMD is operating. This contains the Report and whatnot

Throws: PMDException if the input encoding is unsupported or the input stream could not be parsed

See Also: PMD

processFile

public void processFile(InputStream fileContents, RuleSet ruleSet, RuleContext ctx)
Processes the input stream against a rule set assuming the platform character set.

Parameters: fileContents input stream to check ruleSet the set of rules to process against the source code ctx the context in which PMD is operating. This contains the Report and whatnot

Throws: PMDException if the input encoding is unsupported or the input input stream could not be parsed

See Also: PMD

processFiles

public static void processFiles(int threadCount, RuleSetFactory ruleSetFactory, SourceType sourceType, List<DataSource> files, RuleContext ctx, List<Renderer> renderers, String rulesets, boolean shortNamesEnabled, String inputPath, String encoding, String excludeMarker, ClassLoader classLoader)
Run PMD on a list of files using multiple threads.

Throws: IOException If one of the files could not be read

processFiles

public static void processFiles(int threadCount, RuleSetFactory ruleSetFactory, SourceType sourceType, List<DataSource> files, RuleContext ctx, List<Renderer> renderers, boolean stressTestEnabled, String rulesets, boolean shortNamesEnabled, String inputPath, String encoding, String excludeMarker, ClassLoader classLoader)
Run PMD on a list of files using multiple threads.

Throws: IOException If one of the files could not be read

processFiles

public void processFiles(List<DataSource> files, RuleContext ctx, RuleSets rulesets, boolean debugEnabled, boolean shortNamesEnabled, String inputPath, String encoding)
Run PMD on a list of files.

Parameters: files the List of DataSource instances. ctx the context in which PMD is operating. This contains the Report and whatnot rulesets the RuleSets debugEnabled shortNamesEnabled inputPath encoding

Throws: IOException If one of the files could not be read

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

setExcludeMarker

public void setExcludeMarker(String marker)

setJavaVersion

public void setJavaVersion(SourceType javaVersion)
Set the SourceType to be used for ".java" files.

Parameters: javaVersion the SourceType that indicates the java version