KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > apps > svgbrowser > SquiggleInputHandlerFilter


1 /*
2
3    Copyright 2002-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.apps.svgbrowser;
19
20 import java.io.File JavaDoc;
21
22 import javax.swing.filechooser.FileFilter JavaDoc;
23
24 /**
25  * This class filters file for a given <tt>SquiggleInputHandler</tt>
26  *
27  * @author <a mailto="vincent.hardy@sun.com">Vincent Hardy</a>
28  * @version $Id: SquiggleInputHandlerFilter.java,v 1.4 2004/08/18 07:12:27 vhardy Exp $
29  */

30 public class SquiggleInputHandlerFilter extends FileFilter JavaDoc {
31     protected SquiggleInputHandler handler;
32
33     public SquiggleInputHandlerFilter(SquiggleInputHandler handler) {
34         this.handler = handler;
35     }
36
37     public boolean accept(File JavaDoc f) {
38         return f.isDirectory() || handler.accept(f);
39     }
40
41     public String JavaDoc getDescription() {
42         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
43         String JavaDoc extensions[] = handler.getHandledExtensions();
44         int n = extensions != null ? extensions.length : 0;
45         for (int i=0; i<n; i++) {
46             if (i > 0) {
47                 sb.append(", ");
48             }
49             sb.append(extensions[i]);
50         }
51
52         if (n > 0) {
53             sb.append(" ");
54         }
55
56         sb.append(handler.getDescription());
57         return sb.toString();
58     }
59 }
60
Popular Tags