01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.demo.data;
17:
18: import java.io.File;
19:
20: import javax.swing.filechooser.FileFilter;
21:
22: /**
23: * Filter used mostly figure to grab a list of shapefiles in a directory.
24: *
25: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/demo/data/src/main/java/org/geotools/demo/data/SimpleFileFilter.java $
26: */
27: class SimpleFileFilter extends FileFilter {
28:
29: private String fileExtWithDot = "";
30: private String desc = "";
31:
32: public SimpleFileFilter(String fileExt, String desc) {
33: if (fileExt.startsWith("."))
34: this .fileExtWithDot = fileExt;
35: else
36: this .fileExtWithDot = "." + fileExt;
37: this .desc = desc;
38: }
39:
40: public boolean accept(File f) {
41: if (f.isDirectory()) {
42: return true;
43: }
44: return (f.getName().endsWith(this .fileExtWithDot));
45: }
46:
47: public String getDescription() {
48: return (this.desc);
49: }
50:
51: }
|