KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > codehaus > loom > components > util > ExtensionFileFilter


1 /*
2  * Copyright (C) The Loom Group. All rights reserved.
3  *
4  * This software is published under the terms of the Loom
5  * Software License version 1.1, a copy of which has been included
6  * with this distribution in the LICENSE.txt file.
7  */

8 package org.codehaus.loom.components.util;
9
10 import java.io.File JavaDoc;
11 import java.io.FilenameFilter JavaDoc;
12
13 /**
14  * @author Peter Donald
15  * @version $Revision: 1.2 $ $Date: 2004/05/01 12:48:33 $
16  */

17 public class ExtensionFileFilter
18     implements FilenameFilter JavaDoc
19 {
20     private String JavaDoc[] m_extensions;
21
22     public ExtensionFileFilter( final String JavaDoc[] extensions )
23     {
24         m_extensions = extensions;
25     }
26
27     public ExtensionFileFilter( final String JavaDoc extension )
28     {
29         m_extensions = new String JavaDoc[]{extension};
30     }
31
32     public boolean accept( final File JavaDoc file, final String JavaDoc name )
33     {
34         for( int i = 0; i < m_extensions.length; i++ )
35         {
36             if( name.endsWith( m_extensions[ i ] ) )
37             {
38                 return true;
39             }
40         }
41         return false;
42     }
43 }
44
Popular Tags