@Plugin(name="IfFileName", category="Core", printObject=true) public final class IfFileName extends java.lang.Object implements PathCondition
The regular expression is a pattern as defined by the Pattern
class. A glob is a simplified pattern
expression described in FileSystem.getPathMatcher(String)
.
Modifier and Type | Field and Description |
---|---|
private static Logger |
LOGGER |
private PathCondition[] |
nestedConditions |
private java.nio.file.PathMatcher |
pathMatcher |
private java.lang.String |
syntaxAndPattern |
Modifier | Constructor and Description |
---|---|
private |
IfFileName(java.lang.String glob,
java.lang.String regex,
PathCondition[] nestedConditions)
Constructs a FileNameFilter filter.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(java.nio.file.Path basePath,
java.nio.file.Path relativePath,
java.nio.file.attribute.BasicFileAttributes attrs)
Returns
true if the specified candidate path should be deleted, false otherwise. |
void |
beforeFileTreeWalk()
Invoked before a new file
tree walk is started.
|
static IfFileName |
createNameCondition(java.lang.String glob,
java.lang.String regex,
PathCondition... nestedConditions)
Creates a IfFileName condition that returns true if either the specified
glob pattern or the regular expression matches the relative path.
|
(package private) static java.lang.String |
createSyntaxAndPatternString(java.lang.String glob,
java.lang.String regex) |
java.util.List<PathCondition> |
getNestedConditions() |
java.lang.String |
getSyntaxAndPattern()
Returns the baseDir-relative path pattern of the files to delete.
|
java.lang.String |
toString() |
private static final Logger LOGGER
private final java.nio.file.PathMatcher pathMatcher
private final java.lang.String syntaxAndPattern
private final PathCondition[] nestedConditions
private IfFileName(java.lang.String glob, java.lang.String regex, PathCondition[] nestedConditions)
glob
- the baseDir-relative path pattern of the files to delete (may contain '*' and '?' wildcarts)regex
- the regular expression that matches the baseDir-relative path of the file(s) to deletenestedConditions
- nested conditions to evaluate if this condition accepts a pathstatic java.lang.String createSyntaxAndPatternString(java.lang.String glob, java.lang.String regex)
public java.lang.String getSyntaxAndPattern()
syntax:pattern
where syntax is one of "glob" or "regex" and the pattern is either a regular expression or a simplified pattern expression described under "glob" in
FileSystem.getPathMatcher(String)
.public java.util.List<PathCondition> getNestedConditions()
public boolean accept(java.nio.file.Path basePath, java.nio.file.Path relativePath, java.nio.file.attribute.BasicFileAttributes attrs)
PathCondition
true
if the specified candidate path should be deleted, false
otherwise.accept
in interface PathCondition
basePath
- the directory from where to start scanning for deletion candidate filesrelativePath
- the candidate for deletion. This path is relative to the baseDir.attrs
- attributes of the candidate pathpublic void beforeFileTreeWalk()
PathCondition
beforeFileTreeWalk
in interface PathCondition
@PluginFactory public static IfFileName createNameCondition(@PluginAttribute(value="glob") java.lang.String glob, @PluginAttribute(value="regex") java.lang.String regex, @PluginElement(value="PathConditions") PathCondition... nestedConditions)
glob
- the baseDir-relative path pattern of the files to delete (may contain '*' and '?' wildcarts)regex
- the regular expression that matches the baseDir-relative path of the file(s) to deletenestedConditions
- nested conditions to evaluate if this condition accepts a pathFileSystem.getPathMatcher(String)
public java.lang.String toString()
toString
in class java.lang.Object