Sharkysoft home

lava.io
Class WildcardFilenameFilter

java.lang.Object
  |
  +--lava.io.WildcardFilenameFilter
All Implemented Interfaces:
java.io.FilenameFilter

public class WildcardFilenameFilter
extends java.lang.Object
implements java.io.FilenameFilter

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.

Since:
1997
Version:
1999.04.01

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(java.io.File 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

WildcardFilenameFilter

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.
Parameters:
mask - the filename mask
file_separators - a list of characters that should not be allowed to match '*' or '?'

WildcardFilenameFilter

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

accept

public boolean accept(java.io.File 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 java.io.FilenameFilter
Parameters:
dir - ignored, set to null
filename - the filename to test
Returns:
true if the filename passes, false otherwise

normalizeMask

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.

Parameters:
mask - the mask to adjust
Returns:
the adjusted mask
Since:
1999.04.01

Sharkysoft home