Package org.apache.rat.config.exclusion
Class ExclusionUtils
java.lang.Object
org.apache.rat.config.exclusion.ExclusionUtils
Utilities for Exclusion processing.
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe list of comment prefixes that are used to filter comment lines.A predicate that filters out lines that start withNEGATION_PREFIX
.static final String
Prefix used to negate a given pattern.A predicate that filters out lines that do NOT start withNEGATION_PREFIX
. -
Method Summary
Modifier and TypeMethodDescriptionstatic FileFilter
asFileFilter
(DocumentName parent, DocumentNameMatcher nameMatcher) Create a FileFilter from a PathMatcher.asIterable
(File patternFile, String commentPrefix) Creates an iterable of Strings from a file of patterns.asIterable
(File patternFile, Predicate<String> commentFilters) Creates an iterable of Strings from a file of patterns.static ExtendedIterator
<String> asIterator
(File patternFile, Predicate<String> commentFilters) Creates an iterator of Strings from a file of patterns.commentFilter
(Iterable<String> commentPrefixes) Creates predicate that filters out comment and blank lines.commentFilter
(String commentPrefix) Creates predicate that filters out comment and blank lines.static String
convertSeparator
(String source, String from, String to) Tokenizes the string based on the directory separator.static boolean
Returnstrue
if the filename represents a hidden filestatic String
qualifyPattern
(DocumentName documentName, String pattern) Modifies theMatchPattern
formattedpattern
argument by expanding the pattern and by adjusting the pattern to include the basename from thedocumentName
argument.
-
Field Details
-
COMMENT_PREFIXES
The list of comment prefixes that are used to filter comment lines. -
NEGATION_PREFIX
Prefix used to negate a given pattern.- See Also:
-
NOT_MATCH_FILTER
A predicate that filters out lines that do NOT start withNEGATION_PREFIX
. -
MATCH_FILTER
A predicate that filters out lines that start withNEGATION_PREFIX
.
-
-
Method Details
-
commentFilter
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
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
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 returningtrue
for non-comment lines.- Returns:
- the iterable of Strings from the file.
-
asIterable
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
Creates an iterable of Strings from a file of patterns. Removes comment lines.- Parameters:
patternFile
- the file to read.commentFilters
- A predicate returningtrue
for non-comment lines.- Returns:
- the iterable of Strings from the file.
-
isHidden
Returnstrue
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
Modifies theMatchPattern
formattedpattern
argument by expanding the pattern and by adjusting the pattern to include the basename from thedocumentName
argument.- Parameters:
documentName
- the name of the file being read.pattern
- the pattern to format.- Returns:
- the completely formatted pattern
-
convertSeparator
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.
-