Class FileImportControl
java.lang.Object
com.puppycrawl.tools.checkstyle.checks.imports.AbstractImportControl
com.puppycrawl.tools.checkstyle.checks.imports.FileImportControl
Represents an import rules for a specific file. Only the file name is
considered and only files processed by TreeWalker. The file's
extension is ignored.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFileImportControl
(PkgImportControl parent, String name, boolean regex) Construct a file node. -
Method Summary
Modifier and TypeMethodDescriptionprivate static Pattern
createPatternForExactMatch
(String expression) Creates a Pattern fromexpression
.locateFinest
(String forPkg, String forFileName) Search down the tree to locate the finest match for a supplied package.protected boolean
matchesExactly
(String pkg, String fileName) Check for equality of this with pkg.Methods inherited from class com.puppycrawl.tools.checkstyle.checks.imports.AbstractImportControl
addImportRule, checkAccess
-
Field Details
-
name
The name for the file. -
patternForExactMatch
The regex pattern for exact matches - only not null if regex is true. -
regex
If this file name represents a regular expression.
-
-
Constructor Details
-
FileImportControl
FileImportControl(PkgImportControl parent, String name, boolean regex) Construct a file node.- Parameters:
parent
- the parent node.name
- the name of the file.regex
- flags interpretation of name as regex pattern.
-
-
Method Details
-
createPatternForExactMatch
Creates a Pattern fromexpression
.- Parameters:
expression
- a self-contained regular expression matching the full file name exactly.- Returns:
- a Pattern.
-
locateFinest
Description copied from class:AbstractImportControl
Search down the tree to locate the finest match for a supplied package.- Specified by:
locateFinest
in classAbstractImportControl
- Parameters:
forPkg
- the package to search for.forFileName
- the file name to search for.- Returns:
- the finest match, or null if no match at all.
-
matchesExactly
Description copied from class:AbstractImportControl
Check for equality of this with pkg.- Specified by:
matchesExactly
in classAbstractImportControl
- Parameters:
pkg
- the package to compare with.fileName
- the file name to compare with.- Returns:
- if it matches.
-