| 1 |
|
package org.apache.torque.util; |
| 2 |
|
|
| 3 |
|
import java.io.File; |
| 4 |
|
import java.util.List; |
| 5 |
|
|
| 6 |
|
import org.apache.commons.logging.Log; |
| 7 |
|
import org.apache.commons.logging.LogFactory; |
| 8 |
|
|
|
|
|
| 0% |
Uncovered Elements: 29 (29) |
Complexity: 9 |
Complexity Density: 0.5 |
|
| 9 |
|
public class ChangeDetector { |
| 10 |
|
|
| 11 |
|
private static final Log log = LogFactory.getLog(ChangeDetector.class); |
| 12 |
|
File controlFile; |
| 13 |
|
List<File> files; |
| 14 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 15 |
0
|
public ChangeDetector() {... |
| 16 |
0
|
this(null, null); |
| 17 |
|
} |
| 18 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 19 |
0
|
public ChangeDetector(File controlFile, List<File> files) {... |
| 20 |
0
|
super(); |
| 21 |
0
|
this.controlFile = controlFile; |
| 22 |
0
|
this.files = files; |
| 23 |
|
} |
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 3 |
Complexity Density: 0.3 |
|
| 29 |
0
|
public boolean isChanged() {... |
| 30 |
0
|
if (!getControlFile().exists()) { |
| 31 |
0
|
log.debug("File " + getControlFile().getAbsolutePath() + " does not exist. Returning true"); |
| 32 |
0
|
return true; |
| 33 |
|
} |
| 34 |
0
|
long lastModified = getControlFile().lastModified(); |
| 35 |
0
|
for (File file : getFiles()) { |
| 36 |
0
|
if (file.lastModified() > lastModified) { |
| 37 |
0
|
log.debug("File " + file.getAbsolutePath() + " was modified after " + getControlFile().getAbsolutePath() + " was last modified"); |
| 38 |
0
|
return true; |
| 39 |
|
} |
| 40 |
|
} |
| 41 |
0
|
log.debug("No files were modified."); |
| 42 |
0
|
return false; |
| 43 |
|
} |
| 44 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 45 |
0
|
public File getControlFile() {... |
| 46 |
0
|
return controlFile; |
| 47 |
|
} |
| 48 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 49 |
0
|
public void setControlFile(File controlFile) {... |
| 50 |
0
|
this.controlFile = controlFile; |
| 51 |
|
} |
| 52 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 53 |
0
|
public List<File> getFiles() {... |
| 54 |
0
|
return files; |
| 55 |
|
} |
| 56 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 57 |
0
|
public void setFiles(List<File> files) {... |
| 58 |
0
|
this.files = files; |
| 59 |
|
} |
| 60 |
|
} |