KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dbforms > devgui > ExtensionFilter


1 /*
2  * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/devgui/ExtensionFilter.java,v 1.7 2004/08/18 12:25:57 hkollmann Exp $
3  * $Revision: 1.7 $
4  * $Date: 2004/08/18 12:25:57 $
5  *
6  * DbForms - a Rapid Application Development Framework
7  * Copyright (C) 2001 Joachim Peer <joepeer@excite.com>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  */

23
24 package org.dbforms.devgui;
25
26 import java.io.*;
27
28
29
30 class ExtensionFilter implements FilenameFilter {
31    String JavaDoc[] extensions;
32
33    /**
34     * Creates a new ExtensionFilter object.
35     *
36     * @param extensions DOCUMENT ME!
37     */

38    public ExtensionFilter(String JavaDoc[] extensions) {
39       this.extensions = extensions;
40    }
41
42    /**
43     * DOCUMENT ME!
44     *
45     * @param dir DOCUMENT ME!
46     * @param name DOCUMENT ME!
47     *
48     * @return DOCUMENT ME!
49     */

50    public boolean accept(File dir,
51                          String JavaDoc name) {
52       for (int i = 0; i < extensions.length; i++) {
53          String JavaDoc anExtension = extensions[i];
54
55          if ("*".equals(anExtension) || name.endsWith(anExtension)) {
56             return true;
57          }
58       }
59
60       return false;
61    }
62 }
63
Popular Tags