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

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

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

Filters files using the supplied wildcards. 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 Jason Anderson

See Also:
Serialized Form

Constructor Summary
WildcardFileFilter(java.util.List<java.lang.String> wildcards)
          Construct a new case-sensitive wildcard filter for a list of wildcards.
WildcardFileFilter(java.util.List<java.lang.String> wildcards, org.apache.commons.io.IOCase caseSensitivity)
          Construct a new wildcard filter for a list of wildcards specifying case-sensitivity.
WildcardFileFilter(java.lang.String wildcard)
          Construct a new case-sensitive wildcard filter for a single wildcard.
WildcardFileFilter(java.lang.String[] wildcards)
          Construct a new case-sensitive wildcard filter for an array of wildcards.
WildcardFileFilter(java.lang.String[] wildcards, org.apache.commons.io.IOCase caseSensitivity)
          Construct a new wildcard filter for an array of wildcards specifying case-sensitivity.
WildcardFileFilter(java.lang.String wildcard, org.apache.commons.io.IOCase caseSensitivity)
          Construct a new wildcard filter for a single wildcard specifying case-sensitivity.
 
Method Summary
 boolean accept(FileIf file)
          Checks to see if the filename matches one of the wildcards.
 java.lang.String toString()
          Provide a String representaion of this file filter.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WildcardFileFilter

public WildcardFileFilter(java.lang.String wildcard)
Construct a new case-sensitive wildcard filter for a single wildcard.

Parameters:
wildcard - the wildcard to match
Throws:
java.lang.IllegalArgumentException - if the pattern is null

WildcardFileFilter

public WildcardFileFilter(java.lang.String wildcard,
                          org.apache.commons.io.IOCase caseSensitivity)
Construct a new wildcard filter for a single wildcard specifying case-sensitivity.

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

WildcardFileFilter

public WildcardFileFilter(java.lang.String[] wildcards)
Construct a new case-sensitive wildcard filter for an array of wildcards.

The array is not cloned, so could be changed after constructing the instance. This would be inadvisable however.

Parameters:
wildcards - the array of wildcards to match
Throws:
java.lang.IllegalArgumentException - if the pattern array is null

WildcardFileFilter

public WildcardFileFilter(java.lang.String[] wildcards,
                          org.apache.commons.io.IOCase caseSensitivity)
Construct a new wildcard filter for an array of wildcards specifying case-sensitivity.

The array is not cloned, so could be changed after constructing the instance. This would be inadvisable however.

Parameters:
wildcards - the array of wildcards to match, not null
caseSensitivity - how to handle case sensitivity, null means case-sensitive
Throws:
java.lang.IllegalArgumentException - if the pattern array is null

WildcardFileFilter

public WildcardFileFilter(java.util.List<java.lang.String> wildcards)
Construct a new case-sensitive wildcard filter for a list of wildcards.

Parameters:
wildcards - the list of wildcards to match, not null
Throws:
java.lang.IllegalArgumentException - if the pattern list is null
java.lang.ClassCastException - if the list does not contain Strings

WildcardFileFilter

public WildcardFileFilter(java.util.List<java.lang.String> wildcards,
                          org.apache.commons.io.IOCase caseSensitivity)
Construct a new wildcard filter for a list of wildcards specifying case-sensitivity.

Parameters:
wildcards - the list of wildcards to match, not null
caseSensitivity - how to handle case sensitivity, null means case-sensitive
Throws:
java.lang.IllegalArgumentException - if the pattern list is null
java.lang.ClassCastException - if the list does not contain Strings
Method Detail

accept

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

Specified by:
accept in interface IOFileFilter
Parameters:
file - the file to check
Returns:
true if the filename matches one of the wildcards

toString

public java.lang.String toString()
Provide a String representaion of this file filter.

Overrides:
toString in class java.lang.Object
Returns:
a String representaion