Class ExclusionUtils

java.lang.Object
org.apache.rat.config.exclusion.ExclusionUtils

public final class ExclusionUtils extends Object
Utilities for exclusion processing.
  • Field Details

    • COMMENT_PREFIXES

      public static final List<String> COMMENT_PREFIXES
      The list of comment prefixes that are used to filter comment lines.
    • NEGATION_PREFIX

      public static final String NEGATION_PREFIX
      Prefix used to negate a given pattern.
      See Also:
      Constant Field Values
    • NOT_MATCH_FILTER

      public static final Predicate<String> NOT_MATCH_FILTER
      A predicate that filters out lines that do NOT start with NEGATION_PREFIX.
    • MATCH_FILTER

      public static final Predicate<String> MATCH_FILTER
      A predicate that filters out lines that start with NEGATION_PREFIX.
  • Method Details

    • commentFilter

      public static Predicate<String> commentFilter​(Iterable<String> commentPrefixes)
      Creates predicate that filters out comment and blank lines. Leading spaces are removed and if the line then starts with a commentPrefix string it is considered a comment and will be removed
      Parameters:
      commentPrefixes - the list of comment prefixes.
      Returns:
      the Predicate that returns false for lines that start with commentPrefixes or are empty.
    • commentFilter

      public static Predicate<String> commentFilter​(String commentPrefix)
      Creates predicate that filters out comment and blank lines. Leading spaces are removed and if the line then starts with a commentPrefix string it is considered a comment and will be removed
      Parameters:
      commentPrefix - the prefix string for comments.
      Returns:
      the Predicate that returns false for lines that start with commentPrefixes or are empty.
    • asFileFilter

      public static FileFilter asFileFilter​(DocumentName parent, DocumentNameMatcher nameMatcher)
      Create a FileFilter from a PathMatcher.
      Parameters:
      parent - the document name for the parent of the file to be filtered.
      nameMatcher - the path matcher to convert.
      Returns:
      a FileFilter.
    • asIterator

      public static ExtendedIterator<String> asIterator​(File patternFile, Predicate<String> commentFilters)
      Creates an iterator of Strings from a file of patterns. Removes comment lines.
      Parameters:
      patternFile - the file to read.
      commentFilters - A predicate returning true for non-comment lines.
      Returns:
      the iterable of Strings from the file.
    • asIterable

      public static Iterable<String> asIterable​(File patternFile, String commentPrefix)
      Creates an iterable of Strings from a file of patterns. Removes comment lines.
      Parameters:
      patternFile - the file to read.
      commentPrefix - the prefix string for comments.
      Returns:
      the iterable of Strings from the file.
    • asIterable

      public static Iterable<String> asIterable​(File patternFile, Predicate<String> commentFilters)
      Creates an iterable of Strings from a file of patterns. Removes comment lines.
      Parameters:
      patternFile - the file to read.
      commentFilters - A predicate returning true for non-comment lines.
      Returns:
      the iterable of Strings from the file.
    • isHidden

      public static boolean isHidden​(String fileName)
      Returns true if the filename represents a hidden file
      Parameters:
      fileName - the file to check.
      Returns:
      true if it is the name of a hidden file.
    • qualifyPattern

      public static String qualifyPattern​(DocumentName documentName, String pattern)
      Modifies the MatchPattern formatted pattern argument by expanding the pattern and by adjusting the pattern to include the basename from the documentName argument.
      Parameters:
      documentName - the name of the file being read.
      pattern - the pattern to format.
      Returns:
      the completely formatted pattern
    • convertSeparator

      public static String convertSeparator​(String source, String from, String to)
      Tokenizes the string based on the directory separator.
      Parameters:
      source - the source to tokenize.
      from - the directory separator for the source.
      to - the directory separator for the result.
      Returns:
      the source string with the separators converted.