de.jstacs.io
Class SubstringFilenameFilter

java.lang.Object
  extended by javax.swing.filechooser.FileFilter
      extended by de.jstacs.io.SubstringFilenameFilter
All Implemented Interfaces:
FileFilter, FilenameFilter

public class SubstringFilenameFilter
extends FileFilter
implements FileFilter, FilenameFilter

A simple filter on Files that accepts Files with a specific substring in the filename.

Author:
Jens Keilwagen

Nested Class Summary
static class SubstringFilenameFilter.PartOfName
          This enum defines the different types of a String that can be part of an other String, i.e. the different types of substrings.
 
Constructor Summary
SubstringFilenameFilter(SubstringFilenameFilter.PartOfName type, String desc, boolean dir, boolean ignoreCase, String... substring)
          Creates a new SubstringFilenameFilter with given substring(s) of type type to be found in the filename of the Files to be filtered.
 
Method Summary
 boolean accept(File arg0)
           
 boolean accept(File dir, String name)
           
 String getDescription()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SubstringFilenameFilter

public SubstringFilenameFilter(SubstringFilenameFilter.PartOfName type,
                               String desc,
                               boolean dir,
                               boolean ignoreCase,
                               String... substring)
Creates a new SubstringFilenameFilter with given substring(s) of type type to be found in the filename of the Files to be filtered.

Parameters:
type - the type of the substring that will be searched
desc - the description of the filter, e.g. "text-files (*.txt)"
dir - a switch that allows directories to be accepted
ignoreCase - indicates whether to ignore the case of the filenames or not
substring - an array of substrings, at least one substring has to be found as specific part (type) of the filename so that a "real" File will be accepted
Method Detail

accept

public boolean accept(File arg0)
Specified by:
accept in interface FileFilter
Specified by:
accept in class FileFilter

accept

public boolean accept(File dir,
                      String name)
Specified by:
accept in interface FilenameFilter

getDescription

public String getDescription()
Specified by:
getDescription in class FileFilter