@MinDoc(copyright="Copyright 1997 - 2005, 2009, 2016 A. Weinert", author="Albrecht Weinert", version="V.38", lastModified="16.04.2021", usage="use when files and directories are to be selected", purpose="file and directory criteria") public class FileCriteria extends Object implements Cloneable, Serializable, FilenameFilter, FileFilter, DirectoryStream.Filter<File>
PropMap
object.FilenameFilter
. The description of the
criteria in the documentation below related directly to their effect on
the java.io.FilenameFilter
; see also
accept()
.Modifier and Type | Field and Description |
---|---|
protected boolean |
allowDir
Acceptance of directories.
|
protected boolean |
allowFile
Acceptance of (real) files.
|
protected boolean |
ignoreCase
Ignore case in names.
|
protected long |
maxLen
The length criterion (maximal size).
|
protected long |
maxTime
The time criterion, maximal time ("until").
|
protected long |
minLen
The length criterion (minimal size).
|
protected long |
minTime
The time criterion, minimal time ("since").
|
protected String |
wildName
The name criterion (with wild cards).
|
Constructor and Description |
---|
FileCriteria()
The sole constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(File file)
Check, if a file (or directory) fulfils the criteria.
|
boolean |
accept(File dirf,
String name)
Check, if a named file (or directory) fulfils the criteria.
|
void |
addExcludeNames(CharSequence excludeNames)
Add exclude criteria for names (to the list).
|
void |
addTypes(CharSequence types)
Add to the file type criteria.
|
FileCriteria |
clone()
A copy of this object.
|
boolean |
equals(Object other)
Compare to other FileCriteria object.
|
FastStringSet |
getExcludeNames()
Exclude criteria for names (a list without wild cards).
|
FileFilter |
getFileFilter()
Get a javax.swing.filechooser.FileFilter.
|
long |
getMaxLen()
The length criterion (maximal size).
|
long |
getMaxTime()
The time criterion, maximal time ("until").
|
long |
getMinLen()
The length criterion (minimal size).
|
long |
getMinTime()
The time criterion, minimal time ("since").
|
FastStringSet |
getTypes()
The file type criterion.
|
String |
getWildName()
The name criterion (with wild cards).
|
int |
hashCode()
Hashcode for FileCriteria.
|
boolean |
isAllowDir()
Acceptance of directories.
|
boolean |
isAllowFile()
Acceptance of (real) files.
|
boolean |
isIgnoreCase()
Ignoring case in names.
|
boolean |
isLenSet()
The length criteria (minimal and maximal size) are given.
|
boolean |
isMaxTimeSet()
The time criterion (max) is set.
|
boolean |
isMinTimeSet()
The time criterion (minTime) is set.
|
boolean |
isTimeSet()
One time criterion is set.
|
String |
parse(String path)
Parse / separate a file specification into path and wildcard name.
|
String |
parse(String path,
CharSequence defTypes)
Parse / separate a file specification into path and wildcard name.
|
void |
set(String prefix,
PropMap prop)
Set the criteria according to a PropMap.
|
void |
setAllowDir(boolean allowDir)
Acceptance of directories.
|
void |
setAllowFile(boolean allowFile)
Acceptance of (real) files.
|
void |
setExcludeNames(CharSequence excludeNames)
Set exclude criteria for names (list without wild cards).
|
void |
setIgnoreCase(boolean ignoreCase)
Ignore case in names.
|
void |
setMaxLen(long maxLen)
Set the length criterion (maximal size).
|
void |
setMaxTime(CharSequence maxTime)
Set the time criterion, maximal time ("until") by String.
|
void |
setMaxTime(long maxTime)
The time criterion, maximal time ("until").
|
void |
setMinLen(long minLen)
The length criterion (minimal size).
|
void |
setMinTime(CharSequence minTime)
Set the time criterion, minimal time ("since") by String.
|
void |
setMinTime(long minTime)
The time criterion, minimal time ("since").
|
void |
setTypes(CharSequence types)
Set the file type criterion.
|
void |
setWildName(String wildName)
Set the name criterion (with wild cards).
|
String |
toString()
State as String.
|
protected String wildName
getWildName()
protected boolean ignoreCase
isIgnoreCase()
protected boolean allowFile
isAllowFile()
protected boolean allowDir
isAllowDir()
protected long minTime
getMinTime()
protected long maxTime
getMaxTime()
protected long minLen
getMinLen()
protected long maxLen
getMinLen()
public FileCriteria()
java.io.FilenameFilter
the object in this state will accept every file and every directory.accept()
public final String getWildName()
wildName
is not null, it is the (one)
criterion on the file's or directory's name. Default is null.ignoreCase
is true (default), the matching of
names to wildName
will be not case sensitive.TextHelper.WildEqual()
,
ignoreCase
public void setWildName(String wildName)
wildName
contains list separators (normally ; respectively :
at Linux) this method will set types
instead of
wildName
.wildName
- the name criterion (with wild cards)TextHelper.WildEqual()
,
wildName
,
getWildName()
public final boolean isIgnoreCase()
ComVar
.NOT_WINDOWS
wildName
public void setIgnoreCase(boolean ignoreCase)
ignoreCase
- true if case shall be ignored in namesisIgnoreCase()
public final FastStringSet getExcludeNames()
addExcludeNames(CharSequence)
,
igorecase
,
wildName
public void setExcludeNames(CharSequence excludeNames)
addExcludeNames(CharSequence)
.excludeNames
- exclude criteria for names
(a ; separated list without wild cards)getExcludeNames()
,
addExcludeNames(CharSequence)
public void addExcludeNames(CharSequence excludeNames)
ComVar
.PS
will be
used to separate #getExcludeNames() excludeNames
to token.ComVar
.FS
if not yet so and then added
to the list of exclude criteria for names.exclude criteria
they will be left
unmodified.excludeNames
- exclude criteria for names to be addedpublic final FastStringSet getTypes()
setTypes(CharSequence)
public void setTypes(CharSequence types)
addTypes(CharSequence)
.types
- the file type criteriongetTypes()
public void addTypes(CharSequence types)
types
- additional file type criteriagetTypes()
,
FastStringSet.addTypes(CharSequence)
,
FastStringSet.setTypes(CharSequence)
public final boolean isAllowFile()
public void setAllowFile(boolean allowFile)
allowFile
- states if (real) files are to be acceptedisAllowDir()
,
isAllowFile()
public final boolean isAllowDir()
isAllowFile()
public void setAllowDir(boolean allowDir)
allowDir
- states if directories are to be acceptedisAllowDir()
,
isAllowFile()
public final long getMinTime()
maxTime
.getMaxTime()
,
isTimeSet()
public void setMinTime(long minTime)
minTime
- the minimal (from) timegetMaxTime()
,
getMinTime()
public void setMinTime(CharSequence minTime)
minTime
will be set
to -1 .TimeHelper.parse()
.minTime
- the minimal (from) timepublic final long getMaxTime()
minTime
.getMinTime()
,
isTimeSet()
public void setMaxTime(long maxTime)
public void setMaxTime(CharSequence maxTime)
minTime
will be set
to -1 .TimeHelper.parse()
.maxTime
- the maximum (until) timesetMinTime()
public final boolean isTimeSet()
minTime
or maxTime
is effectual.
See there
.public final boolean isMinTimeSet()
minTime
is effectual.public final boolean isMaxTimeSet()
maxTime
is effectual.public final long getMinLen()
maxLen
public void setMinLen(long minLen)
minLen
- the minimum length (in bytes) criteriongetMaxLen()
,
getMinLen()
public long getMaxLen()
getMinLen()
public void setMaxLen(long maxLen)
maxLen
- the maximum length (in bytes) criteriongetMinLen()
public boolean isLenSet()
getMinLen()
public void set(String prefix, PropMap prop)
PropMap
object prop:prefix
- an optional prefix for the keys to search forprop
- the properties map to take the criteria frompublic boolean accept(File dirf, String name)
java.io.FilenameFilter
.accept
in interface FilenameFilter
dirf
- the directory in which the file resides (may be null)name
- the (pure) name of the file (null or empty returns false)public boolean accept(File file)
FileFilter
.accept()
.
accept
in interface FileFilter
accept
in interface DirectoryStream.Filter<File>
file
- the file or directorypublic final FileFilter getFileFilter()
FileCriteria
object.javax.swing.filechooser.FileFilter
is neither an interface nor does declare any interfaces not even the
partly identical java.io.FileFilter
.public FileCriteria clone()
excludeNames
and
types
are cloned in the process.public final boolean equals(Object other)
FilenameFilter
).public final int hashCode()
FilenameFilter
).hashCode
in class Object
equals(java.lang.Object)
public String toString()
public String parse(String path)
path
- the file denomination to start with (+ becomes *)public String parse(String path, CharSequence defTypes)
FileCriteria
object. Parameters path
likewildName
will be set null and
types
will be set to defTypes
.path
will be processed bay
TextHelper
.makeFNL()
.ComVar
.FS
\ or /) or at an colon :
if ComVar
.PS
is not a colon.wildName
and
types
will keep their values from step one
above.ComVar
.PS
.