Class MatchExtensions


public class MatchExtensions extends FilePathMatcher
Maybe imposes a file-extension condition, optionally on top of an existing matcher.

The extensions are always checked in a case-insensitive manner.

Author:
Owen Feehan
  • Constructor Details

    • MatchExtensions

      public MatchExtensions(String... extension)
      Create for specific extensions.
      Parameters:
      extension - an extension.
    • MatchExtensions

      public MatchExtensions()
  • 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.
    • getMatcher

      public FilePathMatcher getMatcher()
      A secondary matcher, which is required additionally match (as well as the extension).
    • setMatcher

      public void setMatcher(FilePathMatcher matcher)
      A secondary matcher, which is required additionally match (as well as the extension).
    • getExtensions

      public StringSet getExtensions()
      A set of file-extensions (without the period), one of which must match the end of a path.

      If an empty set is passed then, no check occurs, and no extension is checked.

    • setExtensions

      public void setExtensions(StringSet extensions)
      A set of file-extensions (without the period), one of which must match the end of a path.

      If an empty set is passed then, no check occurs, and no extension is checked.

    • isPrioritizeInputContext

      public boolean isPrioritizeInputContext()
      When true, any extensions available in the input-context are prioritized ahead of extensions.
    • setPrioritizeInputContext

      public void setPrioritizeInputContext(boolean prioritizeInputContext)
      When true, any extensions available in the input-context are prioritized ahead of extensions.