Clover Coverage Report - Kuali Spring Utilities 1.1.2-SNAPSHOT
Coverage timestamp: Fri Nov 4 2011 09:10:25 EST
../../../img/srcFileCovDistChart0.png 61% of files have more coverage
34   66   10   8.5
10   60   0.29   4
4     2.5  
1    
 
  MisplacedXMLPrologDetector       Line # 9 34 0% 10 48 0% 0.0
 
No Tests
 
1    package org.springframework.beans;
2   
3    import java.io.File;
4    import java.io.FileFilter;
5    import java.io.IOException;
6    import java.util.ArrayList;
7    import java.util.List;
8   
 
9    public class MisplacedXMLPrologDetector {
10   
 
11  0 toggle public static void main(String[] args) {
12  0 new MisplacedXMLPrologDetector().exec(args);
13    }
14   
 
15  0 toggle protected void exec(String[] args) {
16  0 try {
17  0 long beg = System.currentTimeMillis();
18  0 String dir = "c:/eclipse/sts/2.6.1/ide/ws/rice-trunk";
19  0 FileFilter exclude = new CommonIgnoresFilter();
20  0 FileFilter include = new FilenameContainsDotXFilter();
21  0 FileFilter problem = new MisplacedXMLPrologFilter();
22  0 List<File> files = getFiles(new File(dir), exclude, include);
23  0 System.out.println(files.size());
24  0 List<File> problemFiles = getProblemFiles(files, problem);
25  0 System.out.println(problemFiles.size());
26  0 for (int i = 0; i < problemFiles.size(); i++) {
27  0 File problemFile = problemFiles.get(i);
28  0 System.out.println(problemFile.getAbsolutePath());
29    }
30  0 long end = System.currentTimeMillis();
31  0 long elapsed = end - beg;
32  0 double seconds = elapsed / 1000D;
33  0 System.out.println(seconds);
34    } catch (Throwable t) {
35  0 t.printStackTrace();
36    }
37    }
38   
 
39  0 toggle protected List<File> getProblemFiles(List<File> files, FileFilter problem) throws IOException {
40  0 List<File> problemFiles = new ArrayList<File>();
41  0 for (File file : files) {
42  0 if (problem.accept(file)) {
43  0 problemFiles.add(file);
44    }
45    }
46  0 return problemFiles;
47    }
48   
 
49  0 toggle protected List<File> getFiles(File dir, FileFilter exclude, FileFilter include) {
50  0 File[] contents = dir.listFiles();
51  0 List<File> files = new ArrayList<File>();
52  0 for (File file : contents) {
53  0 if (exclude.accept(file)) {
54  0 continue;
55    }
56  0 if (file.isDirectory()) {
57  0 files.addAll(getFiles(file, exclude, include));
58    } else {
59  0 if (include.accept(file)) {
60  0 files.add(file);
61    }
62    }
63    }
64  0 return files;
65    }
66    }