View Javadoc

1   package org.catacomb.druid.swing;
2   
3   import java.io.File;
4   
5   import javax.swing.filechooser.FileFilter;
6   
7   
8   class ExtFileFilter extends FileFilter {
9   
10      String extensions;
11      String description;
12  
13      public ExtFileFilter(String se, String sd) {
14          extensions = ":" + se + ":";
15          description = sd;
16  
17      }
18  
19      public boolean accept(File f) {
20          String s = f.getName();
21          boolean ok = false;
22          if (f.isDirectory()) {
23              ok = true;
24          }
25          int l = s.lastIndexOf(".");
26          if (l > 0) {
27              String ext = s.substring(l+1, s.length());
28              if (extensions.indexOf(":" + ext + ":") >= 0) {
29                  ok = true;
30              }
31          }
32          return ok;
33      }
34  
35      public String getDescription() {
36          return description;
37  
38      }
39  }
40