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

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

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

Filters filenames for a certain prefix. 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 authors Stephen Colebourne, Federico Barbieri, Serge Knystautas, Peter Donald

See Also:
Serialized Form

Constructor Summary
PrefixFileFilter(java.util.List<java.lang.String> prefixes)
          Constructs a new Prefix file filter for a list of prefixes.
PrefixFileFilter(java.util.List<java.lang.String> prefixes, org.apache.commons.io.IOCase caseSensitivity)
          Constructs a new Prefix file filter for a list of prefixes specifying case-sensitivity.
PrefixFileFilter(java.lang.String prefix)
          Constructs a new Prefix file filter for a single prefix.
PrefixFileFilter(java.lang.String[] prefixes)
          Constructs a new Prefix file filter for any of an array of prefixes.
PrefixFileFilter(java.lang.String[] prefixes, org.apache.commons.io.IOCase caseSensitivity)
          Constructs a new Prefix file filter for any of an array of prefixes specifying case-sensitivity.
PrefixFileFilter(java.lang.String prefix, org.apache.commons.io.IOCase caseSensitivity)
          Constructs a new Prefix file filter for a single prefix specifying case-sensitivity.
 
Method Summary
 boolean accept(FileIf file)
          Checks to see if the filename starts with the prefix.
 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

PrefixFileFilter

public PrefixFileFilter(java.lang.String prefix)
Constructs a new Prefix file filter for a single prefix.

Parameters:
prefix - the prefix to allow, must not be null
Throws:
java.lang.IllegalArgumentException - if the prefix is null

PrefixFileFilter

public PrefixFileFilter(java.lang.String prefix,
                        org.apache.commons.io.IOCase caseSensitivity)
Constructs a new Prefix file filter for a single prefix specifying case-sensitivity.

Parameters:
prefix - the prefix to allow, must not be null
caseSensitivity - how to handle case sensitivity, null means case-sensitive
Throws:
java.lang.IllegalArgumentException - if the prefix is null

PrefixFileFilter

public PrefixFileFilter(java.lang.String[] prefixes)
Constructs a new Prefix file filter for any of an array of prefixes.

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

Parameters:
prefixes - the prefixes to allow, must not be null
Throws:
java.lang.IllegalArgumentException - if the prefix array is null

PrefixFileFilter

public PrefixFileFilter(java.lang.String[] prefixes,
                        org.apache.commons.io.IOCase caseSensitivity)
Constructs a new Prefix file filter for any of an array of prefixes specifying case-sensitivity.

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

Parameters:
prefixes - the prefixes to allow, must not be null
caseSensitivity - how to handle case sensitivity, null means case-sensitive
Throws:
java.lang.IllegalArgumentException - if the prefix is null

PrefixFileFilter

public PrefixFileFilter(java.util.List<java.lang.String> prefixes)
Constructs a new Prefix file filter for a list of prefixes.

Parameters:
prefixes - the prefixes to allow, must not be null
Throws:
java.lang.IllegalArgumentException - if the prefix list is null
java.lang.ClassCastException - if the list does not contain Strings

PrefixFileFilter

public PrefixFileFilter(java.util.List<java.lang.String> prefixes,
                        org.apache.commons.io.IOCase caseSensitivity)
Constructs a new Prefix file filter for a list of prefixes specifying case-sensitivity.

Parameters:
prefixes - the prefixes to allow, must not be null
caseSensitivity - how to handle case sensitivity, null means case-sensitive
Throws:
java.lang.IllegalArgumentException - if the prefix 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 starts with the prefix.

Specified by:
accept in interface IOFileFilter
Parameters:
file - the File to check
Returns:
true if the filename starts with one of our prefixes

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