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 |
|
|
|
|
| 0% |
Uncovered Elements: 48 (48) |
Complexity: 10 |
Complexity Density: 0.29 |
|
9 |
|
public class MisplacedXMLPrologDetector { |
10 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
11 |
0
|
public static void main(String[] args) {... |
12 |
0
|
new MisplacedXMLPrologDetector().exec(args); |
13 |
|
} |
14 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 3 |
Complexity Density: 0.17 |
|
15 |
0
|
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 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
39 |
0
|
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 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
49 |
0
|
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 |
|
} |