public class IncludeExcludeFileSelector extends java.lang.Object implements FileSelector
Modifier and Type | Field and Description |
---|---|
private static org.codehaus.plexus.util.MatchPatterns |
ALL_INCLUDES |
private org.codehaus.plexus.util.MatchPatterns |
computedExcludes |
private org.codehaus.plexus.util.MatchPatterns |
computedIncludes |
private java.lang.String[] |
excludes |
private java.lang.String[] |
includes |
private boolean |
isCaseSensitive |
static java.lang.String |
ROLE_HINT
The include/exclude file selectors role-hint: "standard".
|
private boolean |
useDefaultExcludes |
private static org.codehaus.plexus.util.MatchPatterns |
ZERO_EXCLUDES |
DEFAULT_ROLE_HINT, ROLE
Constructor and Description |
---|
IncludeExcludeFileSelector() |
Modifier and Type | Method and Description |
---|---|
private java.lang.String |
asPattern(java.lang.String pPattern) |
private static java.lang.String |
getCanonicalName(java.lang.String pName) |
java.lang.String[] |
getExcludes()
Returns the list of exclude patterns to use.
|
java.lang.String[] |
getIncludes()
Returns the list of include patterns to use.
|
boolean |
isCaseSensitive()
Returns, whether the include/exclude patterns are case sensitive.
|
protected boolean |
isExcluded(java.lang.String name)
Tests whether or not a name matches against at least one exclude
pattern.
|
protected boolean |
isIncluded(java.lang.String name)
Tests whether or not a name matches against at least one include
pattern.
|
boolean |
isSelected(FileInfo fileInfo)
Returns, whether the given file is selected.
|
boolean |
isUseDefaultExcludes()
Returns, whether to use the default excludes, as specified by
FileUtils.getDefaultExcludes() . |
protected boolean |
matchPath(java.lang.String pattern,
java.lang.String name,
boolean isCaseSensitive)
Tests, whether the given pattern is matching the given name.
|
void |
setCaseSensitive(boolean caseSensitive)
Sets, whether the include/exclude patterns are case sensitive.
|
void |
setExcludes(java.lang.String[] excludes)
Sets the list of exclude patterns to use.
|
void |
setIncludes(java.lang.String[] includes)
Sets the list of include patterns to use.
|
void |
setUseDefaultExcludes(boolean pUseDefaultExcludes)
Sets, whether to use the default excludes, as specified by
FileUtils.getDefaultExcludes() . |
public static final java.lang.String ROLE_HINT
private static final org.codehaus.plexus.util.MatchPatterns ALL_INCLUDES
private static final org.codehaus.plexus.util.MatchPatterns ZERO_EXCLUDES
private boolean isCaseSensitive
private boolean useDefaultExcludes
private java.lang.String[] includes
private java.lang.String[] excludes
private org.codehaus.plexus.util.MatchPatterns computedIncludes
private org.codehaus.plexus.util.MatchPatterns computedExcludes
protected boolean isExcluded(@Nonnull java.lang.String name)
name
- The name to match. Must not be null
.true
when the name matches against at least one
exclude pattern, or false
otherwise.public void setIncludes(@Nullable java.lang.String[] includes)
File.separatorChar
, so the separator used
need not match File.separatorChar
.
When a pattern ends with a '/' or '\', "**" is appended.
includes
- A list of include patterns.
May be null
, indicating that all files
should be included. If a non-null
list is given, all elements must be
non-null
.@Nonnull private static java.lang.String getCanonicalName(@Nonnull java.lang.String pName)
private java.lang.String asPattern(@Nonnull java.lang.String pPattern)
@Nullable public java.lang.String[] getIncludes()
null
, indicating that all files
should be included. If a non-null
list is given, all elements must be
non-null
.public void setExcludes(@Nullable java.lang.String[] excludes)
File.separatorChar
, so the separator used
need not match File.separatorChar
.
When a pattern ends with a '/' or '\', "**" is appended.
excludes
- A list of exclude patterns.
May be null
, indicating that no files
should be excluded. If a non-null
list is
given, all elements must be non-null
.@Nullable public java.lang.String[] getExcludes()
null
, indicating that no files
should be excluded. If a non-null
list is
given, all elements must be non-null
.protected boolean matchPath(@Nonnull java.lang.String pattern, @Nonnull java.lang.String name, boolean isCaseSensitive)
pattern
- The pattern to matchname
- The name to testisCaseSensitive
- Whether the pattern is case sensitive.protected boolean isIncluded(@Nonnull java.lang.String name)
name
- The name to match. Must not be null
.true
when the name matches against at least one
include pattern, or false
otherwise.public boolean isSelected(@Nonnull FileInfo fileInfo)
FileSelector
isSelected
in interface FileSelector
fileInfo
- An instance of FileInfo with the files meta data.
It is recommended, that the caller creates an instance
of PlexusIoResource
.public boolean isCaseSensitive()
public void setCaseSensitive(boolean caseSensitive)
caseSensitive
- True, if the patterns are case sensitive (default), or false.public boolean isUseDefaultExcludes()
FileUtils.getDefaultExcludes()
.public void setUseDefaultExcludes(boolean pUseDefaultExcludes)
FileUtils.getDefaultExcludes()
.