public class FileSelector
extends java.lang.Object
abort()
and getFileCounter()
should
not be called by concurrently running Threads.Constructor and Description |
---|
FileSelector() |
Modifier and Type | Method and Description |
---|---|
void |
abort()
This method may be called by a concurently running thread to abort a search
started with the
listFiles() . |
int |
getFileCounter()
Allows to retreive the number of files found by the
listFiles()
method, when called from a different thread. |
java.io.FilenameFilter |
getFilter(java.util.regex.Pattern pattern,
java.io.File baseDirectory)
Returns the
FilenameFilter for the specified pattern
and base directory. |
int |
getMaxSearchDepth()
Returns the maximal depth for file searches.
|
int |
getTotalCounter()
Allows to retreive the number of files tested by the
listFiles()
method, when called from a different thread. |
java.util.Set<java.io.File> |
listFiles(java.util.regex.Pattern pattern,
java.io.File baseDirectory)
Returns the set of files under the indicated directory
that matches the specified file name pattern.
|
java.util.Set<java.io.File> |
listFiles(java.util.regex.Pattern pattern,
java.io.File baseDirectory,
java.util.Date after,
java.util.Date before,
java.util.regex.Pattern directoryMatcher)
Returns the set of files under the indicated directory
that matches the specified file name pattern.
|
java.io.File |
rename(java.io.File file,
java.util.regex.Pattern pattern,
ReplacementString replacement)
Renames the file using the "pattern" to
generate capturing groups that may be used in the replacement string.
|
static java.lang.String |
rename(java.lang.String input,
java.util.regex.Pattern pattern,
ReplacementString replacement)
Allows to test the result of a renaming operation.
|
void |
setDirectoriesExcluded(java.util.regex.Pattern excludedNames)
Directories matching the specified pattern will be excluded from further search.
|
void |
setMaxSearchDepth(int depth)
Sets the maximal depth for file searches with the
listFiles() operations. |
public java.util.Set<java.io.File> listFiles(java.util.regex.Pattern pattern, java.io.File baseDirectory) throws PatternException, java.io.IOException
pattern
- applied to file namebaseDirectory
- must not be nullPatternException
- if the pattern is invalidjava.io.IOException
- if baseDirectory denotes a file and not a directorypublic java.util.Set<java.io.File> listFiles(java.util.regex.Pattern pattern, java.io.File baseDirectory, java.util.Date after, java.util.Date before, java.util.regex.Pattern directoryMatcher) throws PatternException, java.io.IOException
pattern
- applied to file namebaseDirectory
- must not be nullafter
- file filter. Files before this date will be discarded. May be null.before
- file filter. Files after this date will be discarded. May be null.directoryMatcher
- if not null, only files with an ancestor directory (below the base directory) matching this pattern will be included in the resultPatternException
- if the pattern is invalidjava.io.IOException
- if baseDirectory denotes a file and not a directorypublic java.io.FilenameFilter getFilter(java.util.regex.Pattern pattern, java.io.File baseDirectory) throws java.io.IOException
FilenameFilter
for the specified pattern
and base directory. If the argument 'baseDirectory' is null, the filter
won't take the directory into consideration. Otherwise it will only filter
files below the specified directory.pattern
- applied to file namebaseDirectory
- if null the filter will ignore the directory.FilenameFilter
that for specified patternjava.io.IOException
- if baseDirectory denotes a file and not a directorypublic void setDirectoriesExcluded(java.util.regex.Pattern excludedNames)
excludedNames
- directories to be excludedpublic java.io.File rename(java.io.File file, java.util.regex.Pattern pattern, ReplacementString replacement) throws java.io.IOException, PatternException
file
- to be renamedpattern
- applied on each file name to find capturing groupsreplacement
- defining the new file namejava.io.IOException
- if the file could not be renamed because a file with that name allready
exists, because the file is write protected or because it does not existPatternException
- if the replacement string is invalidUnmatchedGroupReferenceException
- if the replacement string references more groups than
capturing groups defined in the pattern.public static java.lang.String rename(java.lang.String input, java.util.regex.Pattern pattern, ReplacementString replacement)
input
- to be replacedpattern
- matching the string, possibly containing capturing groupsreplacement
- replacement string, possibly containing group referencespublic void setMaxSearchDepth(int depth)
listFiles()
operations.depth
- maximal depth for file searchespublic int getMaxSearchDepth()
public int getFileCounter()
listFiles()
method, when called from a different thread. Returns 0 (zero) after
the listFiles()
method terminates.listFiles()
is running in a different thread.public int getTotalCounter()
listFiles()
method, when called from a different thread. Returns 0 (zero) after
the listFiles()
method terminates.listFiles()
is running in a different thread.public void abort()
listFiles()
.