KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > pmd > cpd > AnyLanguage


1 /**
2  * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3  */

4 package net.sourceforge.pmd.cpd;
5
6 import java.io.File JavaDoc;
7 import java.io.FilenameFilter JavaDoc;
8
9 public class AnyLanguage implements Language {
10
11     public static class AnyFileOrDirectoryFilter implements FilenameFilter JavaDoc {
12         String JavaDoc extension;
13
14         public AnyFileOrDirectoryFilter(String JavaDoc extension) {
15             this.extension = extension;
16         }
17
18         public boolean accept(File JavaDoc dir, String JavaDoc filename) {
19             return filename.endsWith(extension) || (new File JavaDoc(dir.getAbsolutePath() + fileSeparator + filename).isDirectory());
20         }
21     }
22
23     private AnyTokenizer tokenizer;
24     private String JavaDoc extension;
25
26     public AnyLanguage(String JavaDoc extension) {
27         this.extension = extension;
28         tokenizer = new AnyTokenizer();
29     }
30
31     public Tokenizer getTokenizer() {
32         return tokenizer;
33     }
34
35     public FilenameFilter JavaDoc getFileFilter() {
36         return new AnyFileOrDirectoryFilter(this.extension);
37     }
38 }
39
Popular Tags