Package org.codehaus.plexus.util
Interface Scanner
- All Known Implementing Classes:
AbstractScanner
,DirectoryScanner
public interface Scanner
Scan a directory tree for files, with specified inclusions and exclusions.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds default exclusions to the current exclusions set.Returns the base directory to be scanned.String[]
Returns the names of the directories which matched at least one of the include patterns and none of the exclude patterns.String[]
Returns the names of the files which matched at least one of the include patterns and none of the exclude patterns.void
scan()
Scans the base directory for files which match at least one include pattern and don't match any exclude patterns.void
setExcludes
(String[] excludes) Sets the list of exclude patterns to use.void
setFilenameComparator
(Comparator<String> filenameComparator) Use a filename comparator in each directory when scanning.void
setIncludes
(String[] includes) Sets the list of include patterns to use.
-
Method Details
-
setIncludes
Sets the list of include patterns to use. All '/' and '\' characters are replaced byFile.separatorChar
, so the separator used need not matchFile.separatorChar
.When a pattern ends with a '/' or '\', "**" is appended.
- Parameters:
includes
- A list of include patterns. May benull
, indicating that all files should be included. If a non-null
list is given, all elements must be non-null
.
-
setExcludes
Sets the list of exclude patterns to use. All '/' and '\' characters are replaced byFile.separatorChar
, so the separator used need not matchFile.separatorChar
.When a pattern ends with a '/' or '\', "**" is appended.
- Parameters:
excludes
- A list of exclude patterns. May benull
, indicating that no files should be excluded. If a non-null
list is given, all elements must be non-null
.
-
addDefaultExcludes
void addDefaultExcludes()Adds default exclusions to the current exclusions set. -
scan
void scan()Scans the base directory for files which match at least one include pattern and don't match any exclude patterns.- Throws:
IllegalStateException
- if the base directory was set incorrectly (i.e. if it isnull
, doesn't exist, or isn't a directory).
-
getIncludedFiles
String[] getIncludedFiles()Returns the names of the files which matched at least one of the include patterns and none of the exclude patterns. The names are relative to the base directory.- Returns:
- the names of the files which matched at least one of the include patterns and none of the exclude patterns.
-
getIncludedDirectories
String[] getIncludedDirectories()Returns the names of the directories which matched at least one of the include patterns and none of the exclude patterns. The names are relative to the base directory.- Returns:
- the names of the directories which matched at least one of the include patterns and none of the exclude patterns.
-
getBasedir
File getBasedir()Returns the base directory to be scanned. This is the directory which is scanned recursively.- Returns:
- the base directory to be scanned
-
setFilenameComparator
Use a filename comparator in each directory when scanning.- Parameters:
filenameComparator
- the Comparator instance to use- Since:
- 3.3.0
-