KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > swing > svg > SVGFileFilter


1 /*
2
3    Copyright 2001,2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.swing.svg;
19
20 import java.io.File JavaDoc;
21
22 import javax.swing.filechooser.FileFilter JavaDoc;
23
24 /**
25  * This implementation of FileFilter will allows SVG files
26  * with extention '.svg' or '.svgz'.
27  *
28  * @author <a HREF="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
29  * @author <a HREF="mailto:cjolif@ilog.fr">Christophe Jolif</a>
30  * @version $Id: SVGFileFilter.java,v 1.5 2005/03/27 08:58:36 cam Exp $
31  */

32 public class SVGFileFilter extends FileFilter JavaDoc {
33     /**
34      * Returns true if <tt>f</tt> is an SVG file
35      */

36     public boolean accept(File JavaDoc f) {
37         boolean accept = false;
38         String JavaDoc fileName = null;
39         if (f != null) {
40             if (f.isDirectory()) {
41                 accept = true;
42             } else {
43                 fileName = f.getPath().toLowerCase();
44                 if (fileName.endsWith(".svg") || fileName.endsWith(".svgz"))
45                     accept = true;
46             }
47         }
48         return accept;
49     }
50
51     /**
52      * Returns the file description
53      */

54     public String JavaDoc getDescription() {
55         return ".svg, .svgz";
56     }
57 }
58
Popular Tags