de.dv.sbu.filefilter.buildin
Class FilterChain

java.lang.Object
  extended by de.dv.sbu.filefilter.buildin.FilterChain
All Implemented Interfaces:
IFileFilter

public class FilterChain
extends java.lang.Object
implements IFileFilter

Builds a chain of other filters. Possible modes are AND or OR (default). Filters can be added to the list. Empty lists on acceptFile(SourceFileInformation) calls will return false.

Author:
Daniel Vogtland

Nested Class Summary
static class FilterChain.Mode
          Modes for the chain: conjunction or disjunction.
 
Field Summary
 java.util.List<IFileFilter> filters
          The chained filters.
 FilterChain.Mode mode
          The chaining mode: OR or AND.
 
Constructor Summary
FilterChain()
           
 
Method Summary
 boolean acceptFile(SourceFileInformation fileInfo)
          Test the given file information object relative to some root directory.
 java.util.List<IFileFilter> getFilters()
          Returns the chained filters.
 FilterChain.Mode getMode()
          Returns the logical mode.
 void setFilters(java.util.List<IFileFilter> filters)
          Sets the wrapped filters.
 void setMode(FilterChain.Mode mode)
          Sets the logical mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filters

public java.util.List<IFileFilter> filters
The chained filters. Initialized with an empty list.


mode

public FilterChain.Mode mode
The chaining mode: OR or AND. Default is FilterChain.Mode.OR.

Constructor Detail

FilterChain

public FilterChain()
Method Detail

acceptFile

public boolean acceptFile(SourceFileInformation fileInfo)
Test the given file information object relative to some root directory.

Specified by:
acceptFile in interface IFileFilter
Parameters:
fileInfo - The file information to test.
Returns:
true if the file is accepted. false if the file is rejected.
See Also:
IFileFilter.acceptFile(de.dv.sbu.SourceFileInformation)

getMode

public FilterChain.Mode getMode()
Returns the logical mode.

Returns:
The logical mode.

setMode

public void setMode(FilterChain.Mode mode)
             throws java.lang.NullPointerException
Sets the logical mode.

Parameters:
mode - The mode to set.
Throws:
java.lang.NullPointerException - The argument is null.

getFilters

public java.util.List<IFileFilter> getFilters()
Returns the chained filters.

Returns:
The wrapped filters.

setFilters

public void setFilters(java.util.List<IFileFilter> filters)
                throws java.lang.NullPointerException
Sets the wrapped filters.

Parameters:
filters - The filters to set.
Throws:
java.lang.NullPointerException - The list is or contains null.