Clover Coverage Report - Impex Parent 1.0.21-SNAPSHOT (Aggregated)
Coverage timestamp: Tue Feb 8 2011 11:33:53 EST
../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
18   60   9   2.57
4   45   0.5   7
7     1.29  
1    
 
  ChangeDetector       Line # 9 18 0% 9 29 0% 0.0
 
No Tests
 
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   
 
9    public class ChangeDetector {
10   
11    private static final Log log = LogFactory.getLog(ChangeDetector.class);
12    File controlFile;
13    List<File> files;
14   
 
15  0 toggle public ChangeDetector() {
16  0 this(null, null);
17    }
18   
 
19  0 toggle public ChangeDetector(File controlFile, List<File> files) {
20  0 super();
21  0 this.controlFile = controlFile;
22  0 this.files = files;
23    }
24   
25    /**
26    * Return true if any file in the list of files has a last modified timestamp newer than the control file or if the
27    * control file does not exist
28    */
 
29  0 toggle 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   
 
45  0 toggle public File getControlFile() {
46  0 return controlFile;
47    }
48   
 
49  0 toggle public void setControlFile(File controlFile) {
50  0 this.controlFile = controlFile;
51    }
52   
 
53  0 toggle public List<File> getFiles() {
54  0 return files;
55    }
56   
 
57  0 toggle public void setFiles(List<File> files) {
58  0 this.files = files;
59    }
60    }