com.armatiek.infofuze.stream.filesystem.filefilter
Class RegexFileFilter

java.lang.Object
  extended by com.armatiek.infofuze.stream.filesystem.filefilter.RegexFileFilter
All Implemented Interfaces:
IOFileFilter, java.io.Serializable

public class RegexFileFilter
extends java.lang.Object
implements IOFileFilter, java.io.Serializable

Filters files using supplied regular expression(s). Based on code from Apache Commons IO version 2.01. The main difference is that this class filters objects that implement FileIf, not File. Original author Oliver Siegmar

See Also:
Serialized Form

Constructor Summary
RegexFileFilter(java.util.regex.Pattern pattern)
          Construct a new regular expression filter for a compiled regular expression
RegexFileFilter(java.lang.String pattern)
          Construct a new regular expression filter.
RegexFileFilter(java.lang.String pattern, int flags)
          Construct a new regular expression filter with the specified flags.
RegexFileFilter(java.lang.String pattern, org.apache.commons.io.IOCase caseSensitivity)
          Construct a new regular expression filter with the specified flags case sensitivity.
 
Method Summary
 boolean accept(FileIf file)
          Checks to see if the filename matches one of the regular expressions.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegexFileFilter

public RegexFileFilter(java.lang.String pattern)
Construct a new regular expression filter.

Parameters:
pattern - regular string expression to match
Throws:
java.lang.IllegalArgumentException - if the pattern is null

RegexFileFilter

public RegexFileFilter(java.lang.String pattern,
                       org.apache.commons.io.IOCase caseSensitivity)
Construct a new regular expression filter with the specified flags case sensitivity.

Parameters:
pattern - regular string expression to match
caseSensitivity - how to handle case sensitivity, null means case-sensitive
Throws:
java.lang.IllegalArgumentException - if the pattern is null

RegexFileFilter

public RegexFileFilter(java.lang.String pattern,
                       int flags)
Construct a new regular expression filter with the specified flags.

Parameters:
pattern - regular string expression to match
flags - pattern flags - e.g. Pattern.CASE_INSENSITIVE
Throws:
java.lang.IllegalArgumentException - if the pattern is null

RegexFileFilter

public RegexFileFilter(java.util.regex.Pattern pattern)
Construct a new regular expression filter for a compiled regular expression

Parameters:
pattern - regular expression to match
Throws:
java.lang.IllegalArgumentException - if the pattern is null
Method Detail

accept

public boolean accept(FileIf file)
Checks to see if the filename matches one of the regular expressions.

Specified by:
accept in interface IOFileFilter
Parameters:
dir - the file directory
name - the filename
Returns:
true if the filename matches one of the regular expressions