org.progeeks.util
Class RegexFileFilter

java.lang.Object
  extended by javax.swing.filechooser.FileFilter
      extended by org.progeeks.util.RegexFileFilter
All Implemented Interfaces:
java.io.FileFilter

public class RegexFileFilter
extends javax.swing.filechooser.FileFilter
implements java.io.FileFilter

Implementations of the various file filters that uses a regex against the file's path to determine inclusion.

Version:
$Revision: 1.5 $
Author:
Paul Speed

Constructor Summary
RegexFileFilter(java.lang.String regex)
           
RegexFileFilter(java.lang.String description, java.lang.String regex)
           
 
Method Summary
 boolean accept(java.io.File f)
          Returns true if the specified file matches this filter's regex.
 java.lang.String getDescription()
          Returns this filter's description.
 void setBasePath(java.io.File base)
          Sets a base path that can be used to construct relative paths.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RegexFileFilter

public RegexFileFilter(java.lang.String description,
                       java.lang.String regex)

RegexFileFilter

public RegexFileFilter(java.lang.String regex)
Method Detail

setBasePath

public void setBasePath(java.io.File base)
Sets a base path that can be used to construct relative paths. When set, the regular expression will be applied to the full relative path instead of just the file name.


accept

public boolean accept(java.io.File f)
Returns true if the specified file matches this filter's regex. Directories will have a "/" appended to them so that they can be filtered through the regex. Also, any relative paths will have their directory separators normalized to /.

Specified by:
accept in interface java.io.FileFilter
Specified by:
accept in class javax.swing.filechooser.FileFilter

getDescription

public java.lang.String getDescription()
Returns this filter's description.

Specified by:
getDescription in class javax.swing.filechooser.FileFilter

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2002-2003 Paul Speed. All Rights Reserved.