public class FilepathFilter
extends java.lang.Object
implements java.io.FilenameFilter
FilenameFilter or java.io.FilenFilter but deals with CharSequences exclusively.
The constructor prepares a String given path mask (with wild cards). The methods
checks whether a path matches to the mask.| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
FilepathFilter.NameFilter |
(package private) static class |
FilepathFilter.PathFilter |
| Modifier and Type | Field and Description |
|---|---|
(package private) boolean |
bAllTree
If set then the path contains path/before/** /path/after.
|
(package private) java.util.List<FilepathFilter.NameFilter> |
listExcludeNameFilter
One or more entries for checking excluding the file name or null to exlude nothing.
|
(package private) java.util.List<FilepathFilter.NameFilter> |
listNameFilter
One or more entries for checking the file name or null to accept all names.
|
(package private) FilepathFilter.NameFilter |
nameFilter
Only one name possiblity.
|
(package private) FilepathFilter.PathFilter |
pathFilter |
static java.lang.String |
version
Version, history and license.
|
| Constructor and Description |
|---|
FilepathFilter(java.lang.CharSequence mask)
Creates an instance which can check whether any path or name matches to the given path.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
accept(java.io.File dir,
java.lang.String name) |
private static void |
check(boolean result) |
boolean |
checkDir(java.lang.CharSequence sPath)
Checks whether a given directory path matches to the mask.
|
boolean |
checkName(java.lang.String name)
Checks whether a given name matches to the mask.
|
static void |
test()
This routine tests some examples.
|
public static final java.lang.String version
FileFunctions.addFileToList(String, List) and its derived methods
have used an adequate algorithm. The idea to mark a deeper directory tree with "/** /" is an old idea.
Now this algorithm has a frame in a class.
final FilepathFilter.PathFilter pathFilter
final FilepathFilter.NameFilter nameFilter
listNameFilter null, saves memory and time.final java.util.List<FilepathFilter.NameFilter> listNameFilter
final java.util.List<FilepathFilter.NameFilter> listExcludeNameFilter
final boolean bAllTree
public FilepathFilter(java.lang.CharSequence mask)
checkName(String) returns true for any name. All names matches.
checkDir(CharSequence) returns true in an case.
path/start*middle*end
path/*middle*end
path/*end
path/start*
path/start*end
start, contains the middle after the start and before the end part,
and ends with the end. If one of the parts are empty, it is not tested.
*.txt: The name should end with ".txt".
my*year*.txt: The name "myear_1984.txt" does not match. It starts with "my", contains "year"
but it should contain "year" after "my".
: , any further name part
should start with a next : . It is possible to write or not write a space before and after ':' for better readability.
path/ : *.txt : *.log: 2 possibilities of names.
: *.txt : *.log: 2 possibilities of names, no directory path.
:, then it is an exclusive mask. The second ':' should be written without following space!
: save* : :*.bak: All files "save*" but not "*.bak"-files.
: :*.bak: All files exclusively "*.bak"
path/part**end/end, usual in form start/** /end:
** /name: All directories in the tree.
projectX/** /src* /name: All directories below "projectX" which starts with "src"
mask - public boolean checkName(java.lang.String name)
name - given namepublic boolean checkDir(java.lang.CharSequence sPath)
sPath - public boolean accept(java.io.File dir,
java.lang.String name)
accept in interface java.io.FilenameFilterprivate static void check(boolean result)
public static void test()
JZcmd /path/to/srcJava_vishiaBase/org/vishia/util/FilepathFilter.java