public class RegexMetadataFilter extends MetadataFilterImpl
MetadataFilter
Each of the configured include
or exclude
elements is considered a regular expression as defined by
Pattern
. These are then matched against the key portion of the MetadataElement
.
All the includes are processed first to generate a subset of metadata that is then used to process any exclusions. The
include
and excludes
should be in String
regular expression format. If you do not specify
any includes, then this implicitly means all elements are included. If you do not specify any excludes then nothing is excluded
from the inclusion subset.
Typically, you shouldn't need both includes
and excludes
because your skill with regular expressions
mean that you can handle everything you need in either an includes
or an excludes
block. It is
processed this way for completeness.
In the adapter configuration file this class is aliased as regex-metadata-filter which is the preferred alternative to the fully qualified classname when building your configuration.
Constructor and Description |
---|
RegexMetadataFilter() |
Modifier and Type | Method and Description |
---|---|
void |
addExcludePattern(java.lang.String pattern) |
void |
addIncludePattern(java.lang.String pattern) |
MetadataCollection |
filter(MetadataCollection original)
Return all the metadata that matches the filter.
|
java.util.List<java.lang.String> |
getExcludePatterns() |
java.util.List<java.lang.String> |
getIncludePatterns() |
static boolean |
matches(MetadataElement element,
java.util.List<java.util.regex.Pattern> patterns) |
void |
setExcludePatterns(java.util.List<java.lang.String> excludes) |
void |
setIncludePatterns(java.util.List<java.lang.String> includes) |
static java.util.List<java.util.regex.Pattern> |
validatePatterns(java.util.List<java.lang.String> patternSpec,
java.util.List<java.util.regex.Pattern> existingPatterns) |
RegexMetadataFilter |
withExcludePatterns(java.lang.String... patterns) |
RegexMetadataFilter |
withIncludePatterns(java.lang.String... patterns) |
filter, filter
public MetadataCollection filter(MetadataCollection original)
MetadataFilter
original
- the original set of metadata.MetadataCollection
instance that has been filtered.public java.util.List<java.lang.String> getIncludePatterns()
public void setIncludePatterns(java.util.List<java.lang.String> includes)
public java.util.List<java.lang.String> getExcludePatterns()
public void setExcludePatterns(java.util.List<java.lang.String> excludes)
public void addIncludePattern(java.lang.String pattern)
public void addExcludePattern(java.lang.String pattern)
public RegexMetadataFilter withExcludePatterns(java.lang.String... patterns)
public RegexMetadataFilter withIncludePatterns(java.lang.String... patterns)
public static java.util.List<java.util.regex.Pattern> validatePatterns(java.util.List<java.lang.String> patternSpec, java.util.List<java.util.regex.Pattern> existingPatterns)
public static boolean matches(MetadataElement element, java.util.List<java.util.regex.Pattern> patterns)