public class DefaultDirectoryScanner extends Object implements DirectoryScanner
Constructor and Description |
---|
DefaultDirectoryScanner() |
Modifier and Type | Method and Description |
---|---|
protected File[] |
listEligibleFiles(File directory)
Subclasses may refine the listing strategy by overriding this method.
|
List<File> |
listFiles(File directory)
Scans the directory according to the strategy particular to this
implementation and returns the selected files as a File array.
|
void |
setFilter(FileListFilter<File> filter)
Sets a custom filter to be used by this scanner.
|
void |
setLocker(FileLocker locker)
Sets a custom locker to be used by this scanner.
|
boolean |
tryClaim(File file)
Claim the file to process.
|
public void setFilter(FileListFilter<File> filter)
DirectoryScanner
setFilter
in interface DirectoryScanner
filter
- the custom filter to be usedpublic final void setLocker(FileLocker locker)
setLocker
in interface DirectoryScanner
locker
- the custom locker to be usedpublic final boolean tryClaim(File file)
lock
method
and MUST return false
if the locker did not grant the lock.
This class takes the minimal implementation and merely delegates to the locker if set.
tryClaim
in interface DirectoryScanner
file
- file to be claimedpublic final List<File> listFiles(File directory) throws IllegalArgumentException
DirectoryScanner
listFiles
in interface DirectoryScanner
directory
- the directory to scan for filesIllegalArgumentException
- if the input is incorrect