Class AbstractPathAction

All Implemented Interfaces:
Runnable, Action
Direct Known Subclasses:
DeleteAction, PosixViewAttributeAction

public abstract class AbstractPathAction extends AbstractAction
Abstract action for processing files that are accepted by the specified PathFilters.
  • Constructor Details

    • AbstractPathAction

      protected AbstractPathAction(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.
      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).
  • Method Details

    • execute

      public boolean execute() throws IOException
      Description copied from class: AbstractAction
      Performs action.
      Specified by:
      execute in interface Action
      Specified by:
      execute in class AbstractAction
      true if successful.
      IOException - if IO error.
    • execute

      public boolean execute(FileVisitor<Path> visitor) throws IOException
    • createFileVisitor

      protected abstract FileVisitor<Path> createFileVisitor(Path visitorBaseDir, 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.

      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 process
      conditions - filters that determine if a file should be processed
      a new FileVisitor<Path>
    • getBasePath

      public Path getBasePath()
      Returns the base path from where to start scanning for files to delete. Lookups are resolved, so if the configuration was <Delete basePath="${sys:user.home}/abc" /> then this method returns a path to the "abc" file or directory in the user's home directory.
      the base path (all lookups resolved)
    • getBasePathString

      public String getBasePathString()
      Returns the base path as it was specified in the configuration. Lookups are not resolved.
      the base path as it was specified in the configuration
    • getStrSubstitutor

      public StrSubstitutor getStrSubstitutor()
    • getOptions

      public Set<FileVisitOption> getOptions()
      Returns whether to follow symbolic links or not.
      the options
    • isFollowSymbolicLinks

      public boolean isFollowSymbolicLinks()
      Returns whether to follow symbolic links or not.
      whether to follow symbolic links or not
    • getMaxDepth

      public int getMaxDepth()
      Returns the maximum number of directory levels to visit.
      the maxDepth
    • getPathConditions

      public List<PathCondition> getPathConditions()
      Returns the list of PathCondition objects.
      the pathFilters
    • toString

      public String toString()
      toString in class Object