Package com.iizix.util
Class WindowsLikeFilenameFilter
- java.lang.Object
-
- com.iizix.util.WindowsLikeFilenameFilter
-
- All Implemented Interfaces:
java.io.FilenameFilter
public class WindowsLikeFilenameFilter extends java.lang.Object implements java.io.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
Constructors Constructor Description WindowsLikeFilenameFilter(java.lang.String filter)
Creates the instance of the file name filter that is case sensitive.WindowsLikeFilenameFilter(java.lang.String filter, boolean isCaseSensitive)
Creates the instance of the file name filter that is case sensitive.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accept(java.io.File dir, java.lang.String name)
Tests if a specified file should be included in a file list with the current filter.boolean
getCaseSensitivity()
Gets the case sensitivity flag.java.lang.String
getFilter()
Gets the current filter string.boolean
isMatching(java.lang.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(java.lang.String name, int namePos, java.lang.String filter, int filterPos, boolean isCaseSensitive)
Checks for a partial match.static boolean
isMatching(java.lang.String name, java.lang.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(java.lang.String name, java.lang.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
setFilter(java.lang.String filter)
Sets a new filter string.
-
-
-
Constructor Detail
-
WindowsLikeFilenameFilter
public WindowsLikeFilenameFilter(java.lang.String filter)
Creates the instance of the file name filter that is case sensitive. Setting thefilter
parameter to null will include all files.
-
WindowsLikeFilenameFilter
public WindowsLikeFilenameFilter(java.lang.String filter, boolean isCaseSensitive)
Creates the instance of the file name filter that is case sensitive. Setting thefilter
parameter to null will include all files.
-
-
Method Detail
-
setFilter
public void setFilter(java.lang.String filter)
Sets a new filter string. Setting thefilter
parameter to null will include all files.
-
getFilter
public java.lang.String 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
public boolean accept(java.io.File dir, java.lang.String name)
Tests if a specified file should be included in a file list with the current filter.- Specified by:
accept
in interfacejava.io.FilenameFilter
- 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
public boolean isMatching(java.lang.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).Note: "*.*" is replaced with "*" as filter if equal.
-
isMatching
public static boolean isMatching(java.lang.String name, java.lang.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).Note: "*.*" is replaced with "*" as filter if equal.
-
isMatching
public static boolean isMatching(java.lang.String name, java.lang.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(java.lang.String name, int namePos, java.lang.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.
-
-