public class ImportControlCheck extends AbstractCheck implements ExternalResourceHolder
Modifier and Type | Field and Description |
---|---|
private ImportControl |
currentImportControl
The package controller for the current file.
|
private java.lang.String |
fileLocation
Location of import control file.
|
static java.lang.String |
MSG_DISALLOWED
A key is pointing to the warning message text in "messages.properties"
file.
|
static java.lang.String |
MSG_MISSING_FILE
A key is pointing to the warning message text in "messages.properties"
file.
|
static java.lang.String |
MSG_UNKNOWN_PKG
A key is pointing to the warning message text in "messages.properties"
file.
|
private java.lang.String |
packageName
The package doing the import.
|
private java.util.regex.Pattern |
path
The filepath pattern this check applies to.
|
private boolean |
processCurrentFile
Whether to process the current file.
|
private ImportControl |
root
The root package controller.
|
private static java.lang.String |
UNABLE_TO_LOAD
A part of message for exception.
|
Constructor and Description |
---|
ImportControlCheck() |
Modifier and Type | Method and Description |
---|---|
void |
beginTree(DetailAST rootAST)
Called before the starting to process a tree.
|
int[] |
getAcceptableTokens()
The configurable token set.
|
int[] |
getDefaultTokens()
Returns the default token a check is interested in.
|
java.util.Set<java.lang.String> |
getExternalResourceLocations()
Returns a set of external configuration resource locations which are used by the module.
|
private static java.lang.String |
getImportText(DetailAST ast)
Returns import text.
|
private static java.lang.String |
getPackageText(DetailAST ast)
Returns package text.
|
int[] |
getRequiredTokens()
The tokens that this check must be registered for.
|
void |
setFile(java.net.URI uri)
Set the name for the file containing the import control
configuration.
|
void |
setPath(java.util.regex.Pattern pattern)
Set the file path pattern that this check applies to.
|
void |
setUrl(java.net.URI uri)
Deprecated.
use
setFile(URI uri) to load URLs instead |
void |
visitToken(DetailAST ast)
Called to process a token.
|
destroy, finishTree, getClassLoader, getFileContents, getLine, getLines, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens
getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverity
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
public static final java.lang.String MSG_MISSING_FILE
public static final java.lang.String MSG_UNKNOWN_PKG
public static final java.lang.String MSG_DISALLOWED
private static final java.lang.String UNABLE_TO_LOAD
private java.lang.String fileLocation
private java.util.regex.Pattern path
private boolean processCurrentFile
private ImportControl root
private java.lang.String packageName
private ImportControl currentImportControl
public int[] getDefaultTokens()
AbstractCheck
getDefaultTokens
in class AbstractCheck
TokenTypes
public int[] getAcceptableTokens()
AbstractCheck
getAcceptableTokens
in class AbstractCheck
TokenTypes
public int[] getRequiredTokens()
AbstractCheck
getRequiredTokens
in class AbstractCheck
TokenTypes
public void beginTree(DetailAST rootAST)
AbstractCheck
beginTree
in class AbstractCheck
rootAST
- the root of the treepublic void visitToken(DetailAST ast)
AbstractCheck
visitToken
in class AbstractCheck
ast
- the token to processpublic java.util.Set<java.lang.String> getExternalResourceLocations()
ExternalResourceHolder
NullPointerException
in Checker
.
Such behaviour will signal that your module (check or filter) is designed incorrectly.
It make sense to return an empty set from 'getExternalResourceLocations()'
only for composite modules like TreeWalker
.getExternalResourceLocations
in interface ExternalResourceHolder
private static java.lang.String getPackageText(DetailAST ast)
ast
- PACKAGE_DEF ast nodeprivate static java.lang.String getImportText(DetailAST ast)
ast
- ast node that represents importpublic void setFile(java.net.URI uri)
uri
- the uri of the file to load.java.lang.IllegalArgumentException
- on error loading the file.public void setPath(java.util.regex.Pattern pattern)
pattern
- the file path regex this check should apply to.@Deprecated public void setUrl(java.net.URI uri)
setFile(URI uri)
to load URLs insteaduri
- the uri of the file to load.org.apache.commons.beanutils.ConversionException
- on error loading the file.