- All Implemented Interfaces:
FileFilter
,FilenameFilter
FilenameFilter
or FileFilter
.
Implements the file Filter-related interfaces, and allows to use wildcards as Filter specifications.
Note for Windows users: while Java allows compatibility with Unix-style paths
of the type C:/path/to/file
, this filter does not allow this and
requires the typical DOS paths (C:\path\to\file
).
-
Constructor Summary
ConstructorDescriptionDefault Constructor.WildcardFilter
(FilesystemInfo filesystemInfo) Constructor with FilesystemInfo argument. -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
boolean
String[]
Gives an array of all directories matching the wildcard path.Gives the list of all directories matching the wildcard path.String[]
getFilterDirs
(String path) mergeWildcard
(String path) Try to merge this path with wildcards.void
setWildcardPath
(String path) Set the wildcard path to be used.
-
Constructor Details
-
WildcardFilter
public WildcardFilter()Default Constructor. Tries to guess the current filesystem properties as for a Unix/Windows system. -
WildcardFilter
Constructor with FilesystemInfo argument.- Parameters:
filesystemInfo
- the FilesystemInfo object appropriate for the filesystem.
-
-
Method Details
-
getFilePatternSpec
-
setWildcardPath
Set the wildcard path to be used.- Parameters:
path
- The path with wildcards.
-
getCanonWildcardPath
- Returns:
- the wildcard path, qualified with disk label and disk separator if applicable
-
accept
- Specified by:
accept
in interfaceFilenameFilter
-
accept
- Specified by:
accept
in interfaceFileFilter
-
accept
-
getFilterDirs
- Parameters:
path
- Absolute path with first-level wildcards.- Returns:
- list of directories that match the wildcard path. Returns
null
if path is null, or if path parent is not a directory. Returns a zero-length array if no matching directories found.
-
getAllDirs
Gives an array of all directories matching the wildcard path.The reason to give directories (merged with file part of the wildcard path) is to lower memory consumption when using very generic wildcards, as for example it is not the same to return all the directories in a Filesystem than returning all the directories and all the files.
- Returns:
- array of all directories that match the full wildcard path, merged
with the file part of the wildcard path, or
null
if none matches.
-
getAllMatchingDirectories
Gives the list of all directories matching the wildcard path.The reason to give directories (merged with file part of the wildcard path) is to lower memory consumption when using very generic wildcards, as for example it is not the same to return all the directories in a Filesystem than returning all the directories and all the files.
- Returns:
- list of all the directories that match the full wildcard path, merged with the file part of the wildcard path.
-
mergeWildcard
Try to merge this path with wildcards.If matches, return the merged path, otherwise
null
.- Parameters:
path
- the path to merge.- Returns:
- the merged path, or
null
if path does not match wildcard.
-