Class MatchRegularExpression


public class MatchRegularExpression
extends FilePathMatcher
Predicates that matches a file-path against a regular expression.
Author:
Owen Feehan
  • Constructor Details

  • Method Details

    • checkMisconfigured

      public void checkMisconfigured​(BeanInstanceMap defaultInstances) throws BeanMisconfiguredException
      Overrides:
      checkMisconfigured in class AnchorBean<FilePathMatcher>
      Throws:
      BeanMisconfiguredException
    • createMatcherFile

      protected CheckedPredicate<Path,​IOException> createMatcherFile​(Path directory, Optional<InputContextParameters> inputContext)
      Description copied from class: FilePathMatcher
      Create a predicate to be used for matching against path.
      Specified by:
      createMatcherFile in class FilePathMatcher
      Parameters:
      directory - the directory being searched. Only paths in this directory (or its subdirectories) will ever be passed to the predicate.
      inputContext - the input-context.
      Returns:
      a predicate that can be used to accept or reject a path (contained in directory.
    • canMatchSubdirectories

      protected boolean canMatchSubdirectories()
      Description copied from class: FilePathMatcher
      Determines if it possible to match a file in a subdirectory.

      If it impossible to match a subdirectory, this allows us to disable any recursive search, as it is pointless effort.

      Specified by:
      canMatchSubdirectories in class FilePathMatcher
      Returns:
      true if its possible for the predicate returned by createMatcherFile to match a file in a subdirectory, false otherwise.
    • isApplyToPath

      public boolean isApplyToPath()
      If true, the filter is applied to the path, not just the filename (using forward slashes as directory separators)

      By path, we refer to the relative-path to the file being considered, relative to the directory in which the search started.

      e.g. if a file /a/b/c/d.txt is encountered, then the regular-expression will match against c/d.txt when applyToPath==true, and d.txt otherwise.

    • setApplyToPath

      public void setApplyToPath​(boolean applyToPath)
      If true, the filter is applied to the path, not just the filename (using forward slashes as directory separators)

      By path, we refer to the relative-path to the file being considered, relative to the directory in which the search started.

      e.g. if a file /a/b/c/d.txt is encountered, then the regular-expression will match against c/d.txt when applyToPath==true, and d.txt otherwise.

    • getExpression

      public String getExpression()
      The regular-expression, Java-style as described in Pattern.

      Regular expressions should be written to expect a forward-slash as the directory-separator, irrespective of operating system. This guarantees consistent behavior across operating systems.

      Backslashes are not permitted as directory-seperators, only as escape characters.

    • setExpression

      public void setExpression​(String expression)
      The regular-expression, Java-style as described in Pattern.

      Regular expressions should be written to expect a forward-slash as the directory-separator, irrespective of operating system. This guarantees consistent behavior across operating systems.

      Backslashes are not permitted as directory-seperators, only as escape characters.