com.mindprod.filter
Class JunkFilter

java.lang.Object
  extended by com.mindprod.filter.JunkFilter
All Implemented Interfaces:
java.io.FilenameFilter
Direct Known Subclasses:
AvoidJunkFilter

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

Filter to detect junk files.

accept only junk files. Can define junk files by name, extension, starts with or endsWith lists.

Since:
2007-08-28
Version:
2.7 2010-11-22 - add optional invert parameter on a number of the filters.
Author:
Roedy Green, Canadian Mind Products

Constructor Summary
JunkFilter()
          Defines which filenames and extensions are considered junk, to be deleted.
 
Method Summary
 boolean accept(java.io.File dir, java.lang.String name)
          Accept only junk files to be deleted.
 void setEndsWith(java.lang.String... junkEndsWith)
          Set the list of junk ends-with criteria.
 void setExtensions(java.lang.String... junkExtensions)
          Set the list of just extensions.
 void setFilenames(java.lang.String... junkFilenames)
          Set the list of junk filenames.
 void setStartsWith(java.lang.String... junkStartsWith)
          Set the list of junk start -with criteria.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JunkFilter

public JunkFilter()
Defines which filenames and extensions are considered junk, to be deleted.

Method Detail

accept

public boolean accept(java.io.File dir,
                      java.lang.String name)
Accept only junk files to be deleted.

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:
true if and only if the name should be included in the file list; false otherwise.

setEndsWith

public void setEndsWith(java.lang.String... junkEndsWith)
Set the list of junk ends-with criteria. Replaces previous list, does not add to it.

Parameters:
junkEndsWith - Array of strings. If file starts this way, it considered junk.

setExtensions

public void setExtensions(java.lang.String... junkExtensions)
Set the list of just extensions. Replaces previous list, does not add to it.

Parameters:
junkExtensions - Array of strings defining unqualified, dotless filename extensions considered junk.

setFilenames

public void setFilenames(java.lang.String... junkFilenames)
Set the list of junk filenames. Replaces previous list, does not add to it.

Parameters:
junkFilenames - Array of strings defining the unqualified, extensionless filenames considered junk.

setStartsWith

public void setStartsWith(java.lang.String... junkStartsWith)
Set the list of junk start -with criteria. Replaces previous list, does not add to it.

Parameters:
junkStartsWith - Array of strings. If file starts this way, it considered junk.