View Javadoc

1   /* 
2    * Copyright 2002-2006 The Apache Software Foundation
3    * Licensed  under the  Apache License,  Version 2.0  (the "License");
4    * you may not use  this file  except in  compliance with the License.
5    * You may obtain a copy of the License at 
6    * 
7    *   http://www.apache.org/licenses/LICENSE-2.0
8    * 
9    * Unless required by applicable law or agreed to in writing, software
10   * distributed  under the  License is distributed on an "AS IS" BASIS,
11   * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
12   * implied.
13   * 
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.james.util.io;
18  
19  import java.io.File;
20  import java.io.FilenameFilter;
21  
22  /***
23   * This takes a <code>FilenameFilter<code> as input and inverts the selection.
24   * This is used in retrieving files that are not accepted by a filter.
25   *
26   * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
27   * @version CVS $Revision: 365582 $ $Date: 2006-01-03 08:51:21 +0000 (mar, 03 gen 2006) $
28   * @since 4.0
29   */
30  public class InvertedFileFilter
31      implements FilenameFilter
32  {
33      private final FilenameFilter m_originalFilter;
34  
35      public InvertedFileFilter( final FilenameFilter originalFilter )
36      {
37          m_originalFilter = originalFilter;
38      }
39  
40      public boolean accept( final File file, final String name )
41      {
42          return !m_originalFilter.accept( file, name );
43      }
44  }
45  
46