public abstract class AbstractCheck extends AbstractViolationReporter
| Modifier and Type | Class and Description |
|---|---|
private static class |
AbstractCheck.FileContext
The actual context holder.
|
AutomaticBean.OutputStreamOptions| Modifier and Type | Field and Description |
|---|---|
private java.lang.ThreadLocal<AbstractCheck.FileContext> |
context
The check context.
|
private int |
tabWidth
The tab width for column reporting.
|
private java.util.Set<java.lang.String> |
tokens
The tokens the check is interested in.
|
| Constructor and Description |
|---|
AbstractCheck() |
| Modifier and Type | Method and Description |
|---|---|
void |
beginTree(DetailAST rootAST)
Called before the starting to process a tree.
|
void |
clearViolations()
Clears the sorted set of
Violation of the check. |
void |
destroy()
Destroy the check.
|
void |
finishTree(DetailAST rootAST)
Called after finished processing a tree.
|
abstract int[] |
getAcceptableTokens()
The configurable token set.
|
abstract int[] |
getDefaultTokens()
Returns the default token a check is interested in.
|
FileContents |
getFileContents()
Deprecated.
Usage of this method is no longer accepted.
Please use AST based methods instead.
|
java.lang.String |
getLine(int index)
Returns the line associated with the tree.
|
int[] |
getLineCodePoints(int index)
Returns code point representation of file text from given line number.
|
java.lang.String[] |
getLines()
Returns the lines associated with the tree.
|
abstract int[] |
getRequiredTokens()
The tokens that this check must be registered for.
|
protected int |
getTabWidth()
Get tab width to report audit events with.
|
java.util.Set<java.lang.String> |
getTokenNames()
Returns the tokens registered for the check.
|
java.util.SortedSet<Violation> |
getViolations()
Returns the sorted set of
Violation. |
void |
init()
Initialize the check.
|
boolean |
isCommentNodesRequired()
Whether comment nodes are required or not.
|
void |
leaveToken(DetailAST ast)
Called after all the child nodes have been process.
|
void |
log(DetailAST ast,
java.lang.String key,
java.lang.Object... args)
Helper method to log a Violation.
|
void |
log(int lineNo,
int colNo,
java.lang.String key,
java.lang.Object... args)
Log a message that has column information.
|
void |
log(int line,
java.lang.String key,
java.lang.Object... args)
Log a message that has no column information.
|
void |
setFileContents(FileContents contents)
Set the file contents associated with the tree.
|
void |
setTabWidth(int tabWidth)
Set the tab width to report audit events with.
|
void |
setTokens(java.lang.String... strRep)
Adds a set of tokens the check is interested in.
|
void |
visitToken(DetailAST ast)
Called to process a token.
|
finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverityconfigure, contextualize, getConfiguration, setupChildprivate final java.lang.ThreadLocal<AbstractCheck.FileContext> context
private final java.util.Set<java.lang.String> tokens
private int tabWidth
public AbstractCheck()
public abstract int[] getDefaultTokens()
TokenTypespublic abstract int[] getAcceptableTokens()
TokenTypespublic abstract int[] getRequiredTokens()
TokenTypespublic boolean isCommentNodesRequired()
public final void setTokens(java.lang.String... strRep)
strRep - the string representation of the tokens interested inpublic final java.util.Set<java.lang.String> getTokenNames()
public java.util.SortedSet<Violation> getViolations()
Violation.Violation.public final void clearViolations()
Violation of the check.public void init()
public void destroy()
public void beginTree(DetailAST rootAST)
rootAST - the root of the treepublic void finishTree(DetailAST rootAST)
rootAST - the root of the treepublic void visitToken(DetailAST ast)
ast - the token to processpublic void leaveToken(DetailAST ast)
ast - the token leavingpublic final void setFileContents(FileContents contents)
contents - the manager@Deprecated public final FileContents getFileContents()
protected final int getTabWidth()
public final void setTabWidth(int tabWidth)
tabWidth - an int valuepublic final void log(int line, java.lang.String key, java.lang.Object... args)
AbstractViolationReporterlog in class AbstractViolationReporterline - the line number where the audit event was foundkey - the message that describes the audit eventargs - the details of the messageMessageFormatpublic final void log(int lineNo, int colNo, java.lang.String key, java.lang.Object... args)
AbstractViolationReporterlog in class AbstractViolationReporterlineNo - the line number where the audit event was foundcolNo - the column number where the audit event was foundkey - the message that describes the audit eventargs - the details of the messageMessageFormatpublic final void log(DetailAST ast, java.lang.String key, java.lang.Object... args)
ast - a node to get line id column numbers associated
with the violationkey - key to locale violation formatargs - arguments to formatpublic final java.lang.String[] getLines()
public final java.lang.String getLine(int index)
index - index of the linepublic final int[] getLineCodePoints(int index)
index - index of the lineCopyright © 2001-2022. All Rights Reserved.