Sharkysoft home
Class WildcardFilenameFilter

All Implemented Interfaces:

public class WildcardFilenameFilter
extends java.lang.Object

Filters filenames using a standard wildcard mask.

Details: WildcardFilenameFilter tests filenames to determine their membership in the group of filenames defined by a wildcard expression. The characters '?' and '*' take on their usual meanings; '?' means "any character" and '*' means "any string of zero or more characters."

Note that in this implementation, the wildcards may be used to match the platform's directory separator characters, so care should be taken to avoid this effect if it is not desired.


Constructor Summary
WildcardFilenameFilter(java.lang.String mask)
          Initializes a WildcardFilenameFilter using the given wildcard expression.
WildcardFilenameFilter(java.lang.String mask, java.lang.String file_separators)
          Reserved for future implementation.
Method Summary
 boolean accept( dir, java.lang.String filename)
          Determines if the given filename matches the expression associated with this FilenameFilter.
static java.lang.String normalizeMask(java.lang.String mask)
          Normalizes the filename mask.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public WildcardFilenameFilter(java.lang.String mask,
                              java.lang.String file_separators)
Reserved for future implementation. Initializes a WildcardFilenameFilter using the given wildcard expression and file separator.
mask - the filename mask
file_separators - a list of characters that should not be allowed to match '*' or '?'


public WildcardFilenameFilter(java.lang.String mask)
Initializes a WildcardFilenameFilter using the given wildcard expression. '*' and '?' may match any character, including file separators.
mask - the wildcard expression
Method Detail


public boolean accept( dir,
                      java.lang.String filename)
Determines if the given filename matches the expression associated with this FilenameFilter. The dir parameter is reserved for future use, and should be set to null to ensure compatibility with future releases of this class.
Specified by:
accept in interface
dir - ignored, set to null
filename - the filename to test
true if the filename passes, false otherwise


public static java.lang.String normalizeMask(java.lang.String mask)
Normalizes the filename mask.

Details: normalizeMask normalizes the given mask into a form suitable for filename comparison on the host platform. This means, in particular, that if the operating system does not support case-sensitive filename differentiation (as is the case with Windows and Mac), that the mask characters are converted to upper case. On a Unix-style operating system, the original value is returned because upper and lower case distinctions are significant.

If the mask is null, null is returned.

mask - the mask to adjust
the adjusted mask

Sharkysoft home