Clover coverage report - PMD - 3.7 Coverage timestamp: Wed May 31 2006 09:25:59 EDT FRAMES NO FRAMES |

file stats: | LOC: | 55 |  | Methods: | 5
| NCLOC: | 37 |  | Classes: | 1

Source file | Conditionals | Statements | Methods | TOTAL
FileDataSource.java | 0% | 0% | 0% | 0% |

1 |  | /**
2 |  | * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3 |  | */
4 |  | package net.sourceforge.pmd;
5 |  |
6 |  | import java.io.File;
7 |  | import java.io.FileInputStream;
8 |  | import java.io.IOException;
9 |  | import java.io.InputStream;
10 |  |
11 |  | /**
12 |  | * DataSource implementation to read data from a file.
13 |  | */
14 |  | public class FileDataSource implements DataSource {
15 |  | private File file;
16 |  |
17 |  | /**
18 |  | * @param file the file to read
19 |  | */
20 | 0 | public FileDataSource(File file) {
21 | 0 | this.file = file;
22 |  | }
23 |  |
24 | 0 | public InputStream getInputStream() throws IOException {
25 | 0 | return new FileInputStream(file);
26 |  | }
27 |  |
28 | 0 | public String getNiceFileName(boolean shortNames, String inputFileName) {
29 | 0 | return glomName(shortNames, inputFileName, file);
30 |  | }
31 |  |
32 | 0 | private String glomName(boolean shortNames, String inputFileName, File file) {
33 | 0 | if (shortNames && inputFileName.indexOf(',') == -1) {
34 | 0 | if ((new File(inputFileName)).isDirectory()) {
35 | 0 | return trimAnyPathSep(file.getAbsolutePath().substring(inputFileName.length()));
36 |  | } else {
37 | 0 | if (inputFileName.indexOf(System.getProperty("file.separator").charAt(0)) == -1) {
38 | 0 | return inputFileName;
39 |  | }
40 | 0 | return trimAnyPathSep(inputFileName.substring(inputFileName.lastIndexOf(System.getProperty("file.separator"))));
41 |  | }
42 |  | } else {
43 | 0 | return file.getAbsolutePath();
44 |  | }
45 |  | }
46 |  |
47 | 0 | private String trimAnyPathSep(String name) {
48 | 0 | if (name.startsWith(System.getProperty("file.separator"))) {
49 | 0 | return name.substring(1);
50 |  | }
51 | 0 | return name;
52 |  | }
53 |  |
54 |  |
55 |  | }