KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  *
3  */

4 package net.sourceforge.pmd.cpd;
5
6 import net.sourceforge.pmd.SourceFileSelector;
7
8 import java.io.File JavaDoc;
9 import java.io.FilenameFilter JavaDoc;
10
11 /**
12  * Filtering of directories en wanted source files.
13  */

14 public class SourceFileOrDirectoryFilter implements FilenameFilter JavaDoc {
15     
16     private SourceFileSelector fileSelector;
17
18     private static final String JavaDoc fileSeparator = System.getProperty("file.separator");
19     
20     /**
21      * Public constructor
22      *
23      * @param fileSelector the FileSelector that knows what source files to accept
24      */

25     public SourceFileOrDirectoryFilter(SourceFileSelector fileSelector) {
26         this.fileSelector = fileSelector;
27     }
28
29     public boolean accept(File JavaDoc dir, String JavaDoc filename) {
30         return (fileSelector.isWantedFile(filename) || (new File JavaDoc(dir.getAbsolutePath() + fileSeparator + filename).isDirectory())) && !filename.equals("SCCS");
31 // Remark: Why not use "new File(dir, filename).isDirectory()" ?
32
}
33 }
Popular Tags