Class FileImportControl
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.checks.imports.AbstractImportControl
-
- com.puppycrawl.tools.checkstyle.checks.imports.FileImportControl
-
class FileImportControl extends AbstractImportControl
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 Modifier and Type Field Description private String
name
The name for the file.private Pattern
patternForExactMatch
The regex pattern for exact matches - only not null if regex is true.private boolean
regex
If this file name represents a regular expression.
-
Constructor Summary
Constructors Constructor Description FileImportControl(PkgImportControl parent, String name, boolean regex)
Construct a file node.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static Pattern
createPatternForExactMatch(String expression)
Creates a Pattern fromexpression
.AbstractImportControl
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 Detail
-
patternForExactMatch
private final Pattern patternForExactMatch
The regex pattern for exact matches - only not null if regex is true.
-
regex
private final boolean regex
If this file name represents a regular expression.
-
-
Constructor Detail
-
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 Detail
-
createPatternForExactMatch
private static Pattern createPatternForExactMatch(String expression)
Creates a Pattern fromexpression
.- Parameters:
expression
- a self-contained regular expression matching the full file name exactly.- Returns:
- a Pattern.
-
locateFinest
public AbstractImportControl locateFinest(String forPkg, String forFileName)
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
protected boolean matchesExactly(String pkg, String fileName)
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.
-
-