public class PatternFileSelector extends Object implements FileSelector
FileSelector
that selects based on regular expressions.
The regular expression specified in one of the constructors is
matched against FileName.getPath()
of all candidate files. If you want to match only against the base file name,
make sure to prefix the pattern with ".\*\/"
.
Constructor and Description |
---|
PatternFileSelector(Pattern pattern)
Creates a new selector for the given pattern.
|
PatternFileSelector(String regex)
Creates a new selector for the given pattern.
|
PatternFileSelector(String regex,
int flags)
Creates a new selector for the given Pattern and flags.
|
Modifier and Type | Method and Description |
---|---|
boolean |
includeFile(FileSelectInfo fileInfo)
Determines if a file or folder should be selected.
|
String |
toString() |
boolean |
traverseDescendents(FileSelectInfo fileInfo)
Determines whether a folder should be traversed.
|
public PatternFileSelector(Pattern pattern)
See PatternFileSelector
for a specification how the pattern is matched.
pattern
- The regular expressed used by this selector.public PatternFileSelector(String regex)
See PatternFileSelector
for a specification how the pattern is matched.
regex
- The regular expressed used by this selector.Pattern.compile(String, int)
public PatternFileSelector(String regex, int flags)
See PatternFileSelector
for a specification how the pattern is matched.
regex
- The expression to be compiledflags
- Match flags, a bit mask.Pattern.compile(String, int)
public boolean includeFile(FileSelectInfo fileInfo) throws Exception
See PatternFileSelector
for a specification how the pattern is matched.
includeFile
in interface FileSelector
fileInfo
- The file selection information.Exception
- if an error occurs.public boolean traverseDescendents(FileSelectInfo fileInfo) throws Exception
This implementation always returns true to make sure all leafs are inspected.
traverseDescendents
in interface FileSelector
fileInfo
- The file selection information.Exception
- if an error occurs.Copyright © 2002–2020 The Apache Software Foundation. All rights reserved.