public class MatchGlob extends FilePathMatcher
Matches paths using a Java-style glob.

Please see FileSystem.getPathMatcher(java.lang.String) for the syntax of the glob.

In summary, a single wildcard like *.jpg will match only files in the top-level directory, whereas a double wildcard like **.jpg will match files in all subdirectories recursively.

Author:
Owen Feehan
  • Constructor Details

    • MatchGlob

      public MatchGlob()
    • MatchGlob

      public MatchGlob(String glob)
      Creates a new MatchGlob instance.
      Parameters:
      glob - The string describing a glob e.g. "*.jpg".

      If empty, then it is populated from the InputContextParameters where they exist.

  • Method Details

    • createMatcherFile

      protected CheckedPredicate<Path,IOException> createMatcherFile(Path directory, Optional<InputContextParameters> inputContext) throws InputReadFailedException
      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.
      Throws:
      InputReadFailedException - if the testing of the predicate fails.
    • 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.
    • getGlob

      public String getGlob()
      The string describing a glob e.g. "*.jpg".

      If empty, then it is populated from the InputContextParameters where they exist.

    • setGlob

      public void setGlob(String glob)
      The string describing a glob e.g. "*.jpg".

      If empty, then it is populated from the InputContextParameters where they exist.