|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.pmd.RuleContext
public class RuleContext
The RuleContext provides access to Rule processing state. This information includes the following global information:
Constructor Summary | |
---|---|
RuleContext()
Default constructor. |
|
RuleContext(RuleContext ruleContext)
Constructor which shares attributes with the given RuleContext. |
Method Summary | |
---|---|
Object |
getAttribute(String name)
Get an attribute value on the RuleContext. |
LanguageVersion |
getLanguageVersion()
Get the LanguageVersion associated with the current source file. |
Report |
getReport()
Get the Report to which Rule Violations are sent. |
File |
getSourceCodeFile()
Get the File associated with the current source file. |
String |
getSourceCodeFilename()
Get the file name associated with the current source file. |
Object |
removeAttribute(String name)
Remove an attribute value on the RuleContext. |
boolean |
setAttribute(String name,
Object value)
Set an attribute value on the RuleContext, if it does not already exist. |
void |
setLanguageVersion(LanguageVersion languageVersion)
Set the LanguageVersion associated with the current source file. |
void |
setReport(Report report)
Set the Report to which Rule Violations are sent. |
void |
setSourceCodeFile(File sourceCodeFile)
Set the File associated with the current source file. |
void |
setSourceCodeFilename(String filename)
Set the file name associated with the current source file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RuleContext()
public RuleContext(RuleContext ruleContext)
Method Detail |
---|
public Report getReport()
public void setReport(Report report)
report
- The Report.public File getSourceCodeFile()
public void setSourceCodeFile(File sourceCodeFile)
null
, the exclude/include
facilities will not work properly without a File.
sourceCodeFile
- The File.public String getSourceCodeFilename()
public void setSourceCodeFilename(String filename)
filename
- The file name.public LanguageVersion getLanguageVersion()
null
if unknown.public void setLanguageVersion(LanguageVersion languageVersion)
null
to indicate the version is
unknown and should be automatically determined.
languageVersion
- The LanguageVersion.public boolean setAttribute(String name, Object value)
Attributes can be shared between RuleContext instances. This operation is thread-safe.
Attribute values should be modified directly via the reference provided.
It is not necessary to call setAttribute(String, Object)
to
update an attribute value. Modifications made to the attribute value
will automatically be seen by other threads. Because of this, you must
ensure the attribute values are themselves thread safe.
name
- The attribute name.value
- The attribute value.
true
if the attribute was set, false
otherwise.
IllegalArgumentException
- if name
or value
are null
public Object getAttribute(String name)
Attributes can be shared between RuleContext instances. This operation is thread-safe.
Attribute values should be modified directly via the reference provided.
It is not necessary to call setAttribute(String, Object)
to
update an attribute value. Modifications made to the attribute value
will automatically be seen by other threads. Because of this, you must
ensure the attribute values are themselves thread safe.
name
- The attribute name.
null
if the attribute does not exist.public Object removeAttribute(String name)
Attributes can be shared between RuleContext instances. This operation is thread-safe.
Attribute values should be modified directly via the reference provided.
It is not necessary to call setAttribute(String, Object)
to
update an attribute value. Modifications made to the attribute value
will automatically be seen by other threads. Because of this, you must
ensure the attribute values are themselves thread safe.
name
- The attribute name.
null
if the attribute does not exist.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |