Class FileProcessor

java.lang.Object
org.apache.rat.config.exclusion.FileProcessor
All Implemented Interfaces:
Function<DocumentName,Iterable<String>>
Direct Known Subclasses:
DescendingFileProcessor

public class FileProcessor extends Object implements Function<DocumentName,Iterable<String>>
The file processor reads the file specified in the DocumentName. It must return a list of fully qualified strings for the MatchPattern to process. It may return either Ant or Regex style strings, or a mixture of both. See SelectorUtils for a description of the formats. It may also generate custom DocumentNameMatchers which are added to the customMatchers instance variable.
  • Field Details

    • REGEX_FMT

      public static final String REGEX_FMT
      A String format pattern to print a regex string
      See Also:
    • EMPTY

      public static final FileProcessor EMPTY
      An empty file processor returning no entries.
    • NEGATION_PREFIX

      public static final String NEGATION_PREFIX
      Prefix used to negate the given pattern.
      See Also:
    • customMatchers

      protected final List<DocumentNameMatcher> customMatchers
      The collection of custom DocumentNameMatchers generated by this processor
  • Constructor Details

    • FileProcessor

      protected FileProcessor()
      Protected constructor.
    • FileProcessor

      public FileProcessor(Iterable<String> patterns)
      Create a file processor out of a list of file patterns.
      Parameters:
      patterns - the patterns to simulate the file from.
  • Method Details

    • apply

      public Iterable<String> apply(DocumentName documentName)
      Specified by:
      apply in interface Function<DocumentName,Iterable<String>>
    • customDocumentNameMatchers

      public final Iterable<DocumentNameMatcher> customDocumentNameMatchers()
      If this FileProcessor builds custom matchers to handles special cases this method returns them to the processing stream.
      Returns:
      A collection of DocumentNameMatchers. Default returns an empty list.
    • modifyEntry

      protected String modifyEntry(DocumentName documentName, String entry)
      Allows modification of the file entry to match the MatchPattern format. Default implementation returns the @{code entry} argument.
      Parameters:
      documentName - the name of the document that the file was read from.
      entry - the entry from that document.
      Returns:
      the modified string or null to skip the string.
    • localizePattern

      protected final String localizePattern(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