public abstract class AbstractPathAction extends AbstractAction
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
basePathString |
private int |
maxDepth |
private java.util.Set<java.nio.file.FileVisitOption> |
options |
private java.util.List<PathCondition> |
pathConditions |
private StrSubstitutor |
subst |
LOGGER
Modifier | Constructor and Description |
---|---|
protected |
AbstractPathAction(java.lang.String basePath,
boolean followSymbolicLinks,
int maxDepth,
PathCondition[] pathFilters,
StrSubstitutor subst)
Creates a new AbstractPathAction that starts scanning for files to process from the specified base path.
|
Modifier and Type | Method and Description |
---|---|
protected abstract java.nio.file.FileVisitor<java.nio.file.Path> |
createFileVisitor(java.nio.file.Path visitorBaseDir,
java.util.List<PathCondition> conditions)
Creates a new
FileVisitor<Path> to pass to the Files.walkFileTree(Path, Set, int, FileVisitor)
method when the execute() method is invoked. |
boolean |
execute()
Performs action.
|
boolean |
execute(java.nio.file.FileVisitor<java.nio.file.Path> visitor) |
java.nio.file.Path |
getBasePath()
Returns the base path from where to start scanning for files to delete.
|
java.lang.String |
getBasePathString()
Returns the base path as it was specified in the configuration.
|
int |
getMaxDepth()
Returns the the maximum number of directory levels to visit.
|
java.util.Set<java.nio.file.FileVisitOption> |
getOptions()
Returns whether to follow symbolic links or not.
|
java.util.List<PathCondition> |
getPathConditions()
Returns the list of PathCondition objects.
|
StrSubstitutor |
getStrSubstitutor() |
boolean |
isFollowSymbolicLinks()
Returns whether to follow symbolic links or not.
|
java.lang.String |
toString() |
close, isComplete, isInterrupted, reportException, run
private final java.lang.String basePathString
private final java.util.Set<java.nio.file.FileVisitOption> options
private final int maxDepth
private final java.util.List<PathCondition> pathConditions
private final StrSubstitutor subst
protected AbstractPathAction(java.lang.String basePath, boolean followSymbolicLinks, int maxDepth, PathCondition[] pathFilters, StrSubstitutor subst)
basePath
- base path from where to start scanning for files to process.followSymbolicLinks
- whether to follow symbolic links. Default is false.maxDepth
- The maxDepth parameter is the maximum number of levels of directories to visit. A value of 0
means that only the starting file is visited, unless denied by the security manager. A value of
MAX_VALUE may be used to indicate that all levels should be visited.pathFilters
- an array of path filters (if more than one, they all need to accept a path before it is
processed).public boolean execute() throws java.io.IOException
AbstractAction
execute
in interface Action
execute
in class AbstractAction
java.io.IOException
- if IO error.public boolean execute(java.nio.file.FileVisitor<java.nio.file.Path> visitor) throws java.io.IOException
java.io.IOException
protected abstract java.nio.file.FileVisitor<java.nio.file.Path> createFileVisitor(java.nio.file.Path visitorBaseDir, java.util.List<PathCondition> conditions)
FileVisitor<Path>
to pass to the Files.walkFileTree(Path, Set, int, FileVisitor)
method when the execute()
method is invoked.
The visitor is responsible for processing the files it encounters that are accepted by all filters.
visitorBaseDir
- base dir from where to start scanning for files to processconditions
- filters that determine if a file should be processedFileVisitor<Path>
public java.nio.file.Path getBasePath()
<Delete basePath="${sys:user.home}/abc" />
then this method returns a path
to the "abc" file or directory in the user's home directory.public java.lang.String getBasePathString()
public StrSubstitutor getStrSubstitutor()
public java.util.Set<java.nio.file.FileVisitOption> getOptions()
public boolean isFollowSymbolicLinks()
public int getMaxDepth()
public java.util.List<PathCondition> getPathConditions()
public java.lang.String toString()
toString
in class java.lang.Object