org.openbp.common.string.shellmatcher
Class ShellFilenameFilter

java.lang.Object
  extended by org.openbp.common.string.shellmatcher.ShellFilenameFilter
All Implemented Interfaces:
java.io.FilenameFilter

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

The ShellFilenameFilter class implements a UNIX-shell-compatible file name filter. The filter can be used with the list method of the java.io.File class or AWT's file dialog component.

Author:
Heiko Erhardt

Constructor Summary
ShellFilenameFilter()
          Default constructor.
ShellFilenameFilter(java.lang.String pattern)
          Value constructor.
 
Method Summary
 boolean accept(java.io.File dir, java.lang.String name)
          Tests if a specified file should be included in a file list
 void setIgnoreCase(boolean ignoreCase)
          Sets the ignore case option.
 void setPattern(java.lang.String pattern)
          Sets the pattern.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShellFilenameFilter

public ShellFilenameFilter()
Default constructor.


ShellFilenameFilter

public ShellFilenameFilter(java.lang.String pattern)
Value constructor.

Parameters:
pattern - The pattern to match the file names against.
For a description of the meta characters that can be used in the pattern, see the ShellMatcher.setPattern(java.lang.String) method.
Method Detail

setPattern

public void setPattern(java.lang.String pattern)
Sets the pattern.

Parameters:
pattern - The pattern to match the file names against.
For a description of the meta characters that can be used in the pattern, see the ShellMatcher.setPattern(java.lang.String) method.

setIgnoreCase

public void setIgnoreCase(boolean ignoreCase)
Sets the ignore case option.

Parameters:
ignoreCase - true The character case will be ignored when comparing literals.
false The pattern matcher will distinguish between lower and upper case.

accept

public boolean accept(java.io.File dir,
                      java.lang.String name)
Tests if a specified file should be included in a file list

Specified by:
accept in interface java.io.FilenameFilter
Parameters:
dir - The directory in which the file was found
name - The name of the file
Returns:
@return true if the name should be included in the file list
false otherwise


Copyright © 2011. All Rights Reserved.