Class PatternFileFilter

All Implemented Interfaces:
FileFilter, Filter<File>

public class PatternFileFilter extends AbstractPatternFilter<File> implements FileFilter

AbstractPatternFilter and FileFilter combination, using a set of Regular expressions to accept the canonical absolute paths to Files.

Since:
2.0
  • Field Details

    • PATTERN_LETTER_DIGIT_PUNCT

      public static final String PATTERN_LETTER_DIGIT_PUNCT
      Java RegExp pattern matching one or more letters/digits/punctuation characters. It can be flexibly used to separate normative text in a pattern:
      1. Pattern matching ends of strings. PATTERN_LETTER_DIGIT_PUNCT + "txt" matches all file paths ending in "txt", such as "some/foobar.txt"
      2. Pattern matching strings containing patterns. PATTERN_LETTER_DIGIT_PUNCT + "foobar" + PATTERN_LETTER_DIGIT_PUNCT matches all file paths containing "foobar" such as "the/file/in/directory/foobar/blah.java"
      3. Pattern matching start of strings. "/some/prefix" + PATTERN_LETTER_DIGIT_PUNCT matches all file paths starting in "/some/prefix", such as "some/prefix/another/specification.xsd"
      See Also:
    • FILE_PATH_CONVERTER

      public static final StringConverter<File> FILE_PATH_CONVERTER
      Converter returning the canonical and absolute path for a File.
  • Constructor Details

    • PatternFileFilter

      public PatternFileFilter(boolean processNullValues, String patternPrefix, List<String> patterns, StringConverter<File> converter, boolean acceptCandidateOnPatternMatch)
      Compound constructor creating an PatternFileFilter from the supplied parameters.
      Parameters:
      processNullValues - if true, this PatternFileFilter process null candidate values.
      patternPrefix - a prefix to be prepended to any patterns submitted to this PatternFileFilter
      patterns - The non-null list of Patters which should be applied within this PatternFileFilter.
      converter - The StringConverter which converts Files to Strings for Pattern matching.
      acceptCandidateOnPatternMatch - if true, this PatternFileFilter will matchAtLeastOnce candidate objects that match at least one of the supplied patterns. if false, this PatternFileFilter will noFilterMatches candidates that match at least one of the supplied patterns.
    • PatternFileFilter

      public PatternFileFilter(List<String> patternStrings, boolean acceptCandidateOnPatternMatch)
      Creates a new PatternFileFilter using the supplied patternStrings which are interpreted as file suffixes. (I.e. prepended with PATTERN_LETTER_DIGIT_PUNCT and compiled to Patterns). The FILE_PATH_CONVERTER is used to convert Files to strings. The supplied acceptCandidateOnPatternMatch parameter indicates if this PatternFileFilter accepts or rejects candidates that match any of the supplied patternStrings.
      Parameters:
      patternStrings - The list of patternStrings to be used as file path suffixes.
      acceptCandidateOnPatternMatch - if true, this PatternFileFilter will matchAtLeastOnce candidate objects that match at least one of the supplied patterns. if false, this PatternFileFilter will noFilterMatches candidates that match at least one of the supplied patterns.
      See Also:
    • PatternFileFilter

      public PatternFileFilter(List<String> patterns)
      Creates a new PatternFileFilter using the supplied patternStrings which are interpreted as file suffixes. (I.e. prepended with PATTERN_LETTER_DIGIT_PUNCT and compiled to Patterns). The FILE_PATH_CONVERTER is used to convert Files to strings. The retrieved PatternFileFilter accepts candidates that match any of the supplied patternStrings.
      Parameters:
      patterns - The list of patternStrings to be used as file path suffixes.
    • PatternFileFilter

      public PatternFileFilter()

      Creates a new PatternFileFilter with no patternStrings List, implying that calling this constructor must be followed by a call to the #setPatterns method.

      The default prefix is PATTERN_LETTER_DIGIT_PUNCT, the default StringConverter is FILE_PATH_CONVERTER and this PatternFileFilter does by default accept candidates that match any of the supplied PatternStrings (i.e. an include-mode filter)

  • Method Details

    • createExcludeFilterList

      public static List<Filter<File>> createExcludeFilterList(org.apache.maven.plugin.logging.Log log, String... patterns)
      Creates a new List containing an exclude-mode PatternFileFilter using the supplied patternStrings which are interpreted as file suffixes. (I.e. prepended with PATTERN_LETTER_DIGIT_PUNCT and compiled to Patterns). The FILE_PATH_CONVERTER is used to convert Files to strings.
      Parameters:
      log - The active Maven Log.
      patterns - A List of suffix patterns to be used in creating a new ExclusionRegularExpressionFileFilter.
      Returns:
      A List containing a PatternFileFilter using the supplied suffix patterns to match Files.
      See Also:
    • createIncludeFilterList

      public static List<Filter<File>> createIncludeFilterList(org.apache.maven.plugin.logging.Log log, String... patterns)
      Creates a new List containing an include-mode PatternFileFilter using the supplied patternStrings which are interpreted as file suffixes. (I.e. prepended with PATTERN_LETTER_DIGIT_PUNCT and compiled to Patterns). The FILE_PATH_CONVERTER is used to convert Files to strings.
      Parameters:
      log - The active Maven Log.
      patterns - A List of suffix patterns to be used in creating a new ExclusionRegularExpressionFileFilter.
      Returns:
      A List containing a PatternFileFilter using the supplied suffix patterns to match Files.
      See Also:
    • createFilterList

      private static List<Filter<File>> createFilterList(org.apache.maven.plugin.logging.Log log, boolean includeOperation, String... patterns)