Package com.iizix.util
Class WindowsLikeFilenameFilter
java.lang.Object
com.iizix.util.WindowsLikeFilenameFilter
- All Implemented Interfaces:
FilenameFilter
Filters file names like under Windows, with '?' being any character, '*' being any characters and '^' the escape character (the meaning of '?' and '*' becomes the actual character, and two escape characters for a single).
Constructor Summary
ConstructorDescriptionWindowsLikeFilenameFilter
(String filter) Creates the instance of the file name filter that is case sensitive.WindowsLikeFilenameFilter
(String filter, boolean isCaseSensitive) Creates the instance of the file name filter that is case sensitive.Method Summary
Modifier and TypeMethodDescriptionboolean
Tests if a specified file should be included in a file list with the current filter.boolean
Gets the case sensitivity flag.Gets the current filter string.boolean
isMatching
(String name) Checks if a name matches a filter string like under Windows, with '?' being any character, '*' being any characters and '^' the escape character (the meaning of '?' and '*' becomes the actual character, and two escape characters for a single).static boolean
isMatching
(String name, int namePos, String filter, int filterPos, boolean isCaseSensitive) Checks for a partial match.static boolean
isMatching
(String name, String filter) Checks if a name matches a filter string like under Windows, with '?' being any character, '*' being any characters and '^' the escape character (the meaning of '?' and '*' becomes the actual character, and two escape characters for a single).static boolean
isMatching
(String name, String filter, boolean isCaseSensitive, boolean replaceStarDotStar) Checks if a name matches a filter string like under Windows, with '?' being any character, '*' being any characters and '^' the escape character (the meaning of '?' and '*' becomes the actual character, and two escape characters for a single).void
setCaseSensitivity
(boolean on) Sets the case sensitivity flag.void
Sets a new filter string.
Constructor Details
WindowsLikeFilenameFilter
Creates the instance of the file name filter that is case sensitive. Setting thefilter
parameter to null will include all files.WindowsLikeFilenameFilter
Creates the instance of the file name filter that is case sensitive. Setting thefilter
parameter to null will include all files.
Method Details
setFilter
Sets a new filter string. Setting thefilter
parameter to null will include all files.getFilter
Gets the current filter string.- Returns:
- null if all files are included, otherwise the current filter string.
setCaseSensitivity
public void setCaseSensitivity(boolean on) Sets the case sensitivity flag.getCaseSensitivity
public boolean getCaseSensitivity()Gets the case sensitivity flag.accept
Tests if a specified file should be included in a file list with the current filter.- Specified by:
accept
in interfaceFilenameFilter
- Parameters:
dir
- - the directory in which the file was found.name
- - the name of the file.- Returns:
- true if the name should be included in the file list; false otherwise.
isMatching
Checks if a name matches a filter string like under Windows, with '?' being any character, '*' being any characters and '^' the escape character (the meaning of '?' and '*' becomes the actual character, and two escape characters for a single).Note: "*.*" is replaced with "*" as filter if equal.
isMatching
Checks if a name matches a filter string like under Windows, with '?' being any character, '*' being any characters and '^' the escape character (the meaning of '?' and '*' becomes the actual character, and two escape characters for a single).Note: "*.*" is replaced with "*" as filter if equal.
isMatching
public static boolean isMatching(String name, String filter, boolean isCaseSensitive, boolean replaceStarDotStar) Checks if a name matches a filter string like under Windows, with '?' being any character, '*' being any characters and '^' the escape character (the meaning of '?' and '*' becomes the actual character, and two escape characters for a single).isMatching
public static boolean isMatching(String name, int namePos, String filter, int filterPos, boolean isCaseSensitive) Checks for a partial match. This function is recursive. The parameters are the file name string and starting position in it and then the filter string with a starting filter position.- Returns:
- true for a match; false otherwise.