public class FilepathFilterM extends java.lang.Object implements ToStringBuilder
[[src/**|result/**]/[~#*|~*#]|~_*]
src
or result
, form no other sub directory.
But from the root level the valid mask for files is ~_*
, it means should not start with "_".
For all deeper levels the files should not start or end with an #
.
Hence all source files are gathered, but not commented files with #
.Modifier and Type | Field and Description |
---|---|
FilepathFilterM |
aFilterChild
This is the next part in the original path between /child/
|
boolean |
bAllTree
True if the filter path on ctor has contained "**".
|
boolean |
bLast |
(package private) boolean |
bNotBegin
up to 32 bit for negation of variants, bit 0 for first text etc.
|
private boolean |
bNoWildcard |
(package private) int |
mNotEnd |
private java.lang.String |
sBegin |
private java.lang.String |
sContain |
private java.lang.String |
sEnd |
static java.lang.String |
sVersion
Version, history and license.
|
(package private) java.util.List<FilepathFilterM> |
variantsBegin
Variants either instead sBefore or instead sBehind.
|
(package private) java.util.List<java.lang.String> |
variantsEnd |
(package private) int |
zBegin |
(package private) int |
zContain |
(package private) int |
zEnd |
Modifier | Constructor and Description |
---|---|
protected |
FilepathFilterM(java.lang.String sMask,
boolean bLast,
FilepathFilterM filterChild)
Creates a FilepathFilterM for one level.
|
Modifier and Type | Method and Description |
---|---|
FilepathFilterM |
check(java.lang.String name,
boolean bDir)
Checks the given name against the current Level of this FilepathFilterM.
|
private FilepathFilterM |
checkVariants(java.lang.String name,
boolean bDir,
int[] posEndBegin,
int posStartEnd) |
private int |
checkVariantsEnd(java.lang.String name,
int zName) |
static FilepathFilterM |
createWildcardFilter(java.lang.String maskP)
Creates a FilepathFilterM with given mask.
|
private static FilepathFilterM |
createWildcardFilter(java.lang.String maskP,
FilepathFilterM filterChildP) |
FilepathFilterM |
nextChild() |
private static java.lang.String |
parseVariants(java.lang.String sPart,
int posBracket,
java.util.List<FilepathFilterM> list,
FilepathFilterM filterChild) |
private static int |
parseVariantsEnd(java.lang.String sPart,
int posBracket,
java.util.List<java.lang.String> list) |
boolean |
selAllDirEntries()
Returns true if this filter selects all sub directories till end of tree.
|
boolean |
selAllEntries()
returns true if this filter will select all entries of this level.
|
boolean |
selAllFilesInDir()
returns true if this filter will select all files asked from a dir level.
|
java.lang.String |
toString() |
java.lang.StringBuilder |
toString(java.lang.StringBuilder app,
java.lang.String... cond)
This is a better version of a toString() concept for elaborately outputs.
|
boolean |
XXaccept(java.io.File dir,
java.lang.String name)
Checks whether the name matches due to this filter.
|
public static final java.lang.String sVersion
selAllFilesInDir()
, selAllDirEntries()
. selAllEntries()
It is used for quest delete a directory entry, only if the first two conditions are met.
It checks the given mask.
check(String, boolean)
, test is done.
Adaption in application necessary (since 2 weeks...)
FilepathFilter
with the multi selection.
The idea is old, it was present in the path as WildcardFilter
in FileFunctions
but not used. Now it es tested, and used for the FileList
.
public final FilepathFilterM aFilterChild
private final java.lang.String sBegin
private final java.lang.String sContain
private final java.lang.String sEnd
int zBegin
int zContain
int zEnd
public final boolean bAllTree
private final boolean bNoWildcard
public final boolean bLast
java.util.List<FilepathFilterM> variantsBegin
java.util.List<java.lang.String> variantsEnd
final boolean bNotBegin
int mNotEnd
protected FilepathFilterM(java.lang.String sMask, boolean bLast, FilepathFilterM filterChild)
createWildcardFilter(String)
.
fix |
The filter accepts only this name |
begin* |
The filter accepts names starting with "begin" and "begin" itself.
Familiar example: "myfile.*", all files with this name and any extension. Or "myFile.c*" accepts also "myFile.cpp", but also for example "myFile.ci" if given. |
*end |
The filter accepts names ending with "end" and "end" itself. Familiar example: "*.cpp", all files with extension "cpp" |
begin*end |
The filter accepts names starting with "begin" and ending with end after before.
Familiar examples: "file*.cpp": All files starting with "file" with extension ".cpp" |
begin*mid*end |
The filter accepts names starting with "begin", ending with end after before
and containing "mid" between "begin" and "end".
Familiar examples: "file*.cpp": All files starting with "file" with extension ".cpp" |
begin*mid* |
The filter accepts names starting with "begin" and containing "mid" after "begin".
Familiar examples: "file*.c*": All files starting with "file" with extension ".c" but also ".cpp" This is a special case of begin*mid*end . |
*mid* |
The filter accepts names which contains "mid" but also only "mid".
Familiar examples: "*.c*": All fileswith extension ".c" but also ".cpp" This is a special case of begin*mid*end . |
* |
The filter accepts all names, returns always true. |
**
aFilterChild
is used.
*
)
** |
The filter accepts all names, returns always true. This stands for any deepness of a directory tree till the following child pattern does also match. It means the child pattern is tested. If it does match, it (and the following children) is used for further checking. If the child pattern does not match, matching is true and the child pattern is not used for this level. |
begin** |
The filter accepts names starting with "begin" and "begin" itself.
It the next level starts also with begin, it is preconditional. But nevertheless the next child level is checked. If it matches, it is used. |
begin**mid*end |
It is similar for all other wildcard variants.
Note: The "**" must be written on the first wildcard position. |
FilepathFilter
.
Variants are written in [var1|var2]
for positive variants
for the begin
and end
parts or as part of them between the wildcards.
[~var1|~var2]
for negative variants.
Then not only one given string for begin
and end
are valid (matching)
but either one of the possible, or all Strings exclusively the given. Look on examples:
createWildcardFilter(String)
.
This path is then continued with the following parts after '/' if given.
But parts after asterisk are not used:
[dirA/**|dirB/spec]/*.c* |
Here all *.c* files either from dirA in any deepness or from dirB/spec/*.c* are matching |
[dirA/[spec1|spec2]|dirB/spec]/*.c* |
The parts of the path can be also nested. |
[...part...|
is evaluated as an own expression in createWildcardFilter(String)
.
Hence any nesting is possible.
'*'
can only be simple texts:
*.[~bak|~old] |
The filter does not accept names ending with this both
Note: Either a positive or a negative variant choice is possible. Both is nonsense. |
*.[c|cpp] |
The filter accepts names ending with ".c" or ".cpp".
This is the better possibility instead *.c* to accept C and C++ files.
Note: The list to check variantsEnd contains ".c " and ".cpp ",
the complete text.
The writing style with the ". " outside of the variants is only an abbreviation for writing. |
FileFunctions#createWildcardFilter(String)
for a whole path
and see #accept(File, String)
.sMask
- mask due to given examplesfilterChild
- null or a child filter for the next level. Note: Parsing is done backward.private static java.lang.String parseVariants(java.lang.String sPart, int posBracket, java.util.List<FilepathFilterM> list, FilepathFilterM filterChild)
private static int parseVariantsEnd(java.lang.String sPart, int posBracket, java.util.List<java.lang.String> list)
public FilepathFilterM nextChild()
public boolean XXaccept(java.io.File dir, java.lang.String name)
nextChild()
and also not a path separated with '/' or '\'.
See FileFunctions#checkPathTODOpublic FilepathFilterM check(java.lang.String name, boolean bDir)
name
- The name of a file or directory to check.bDir
- true then it is a directory name what is to check.public boolean selAllFilesInDir()
public boolean selAllDirEntries()
public boolean selAllEntries()
bAllTree
.private FilepathFilterM checkVariants(java.lang.String name, boolean bDir, int[] posEndBegin, int posStartEnd)
private int checkVariantsEnd(java.lang.String name, int zName)
public static FilepathFilterM createWildcardFilter(java.lang.String maskP)
maskP
- as examples above, for possibilities in each level see FilepathFilterM#FilepathFilterM(String, FilepathFilterM)
private static FilepathFilterM createWildcardFilter(java.lang.String maskP, FilepathFilterM filterChildP)
maskP
- bEnd
- true if [internal] is parsed in sEnd rangepublic java.lang.StringBuilder toString(java.lang.StringBuilder app, java.lang.String... cond)
ToStringBuilder
toString
in interface ToStringBuilder
app
- an Appendable, especially a StringBuilder which have no additional tyry.catch necessitiescond
- Any string optional, for conditions to control the output.
// * @throws IOException This is the necessity of Appendable.append(CharSequence)
.
// * It may be caught to throw new RuntimeException(exc) it not expected.
// * Especially a StringBuilder.append(CharSequence)
does not throw an exception.public java.lang.String toString()
toString
in class java.lang.Object