01: /*
02: * transformica 2
03: * Code generator
04: * Copyright (C) 2004 Hammurapi Group
05: *
06: * This program is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2 of the License, or (at your option) any later version.
10: *
11: * This program is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: *
20: * URL: http://www.pavelvlasov.com/pv/content/menu.show@id=products.transformica.html
21: * e-Mail: support@hammurapi.biz
22: */
23: package biz.hammurapi.transformica;
24:
25: import java.io.File;
26:
27: import org.apache.tools.ant.BuildException;
28:
29: /**
30: * File info file. Channel generates a file only if a file doesn't exist or
31: * if file's timestamp, size and checksum are equal to ones stored in timestamp repository.
32: * This guarantees that no manual changes will not be overwritten. There can be only only one
33: * touch detector per channel/task. Touch detector defined at channel level overrides task detector
34: * defined at task level.
35: * @ant.element name="filetouchdetector"
36: * @author Pavel Vlasov
37: * @version $Revision: 1.1 $
38: */
39: public class FileTouchDetectorFactory implements TouchDetectorFactory {
40:
41: /* (non-Javadoc)
42: * @see biz.hammurapi.mda.TimeStampRepoFactory#newTimeStampRepo()
43: */
44: public TouchDetector newTimeStampRepo() throws BuildException {
45: if (fileInfoFile == null) {
46: throw new BuildException("Timesamp file is not set");
47: }
48: return new FileTouchDetector(fileInfoFile, genRoot,
49: ignoreTimeStamp);
50: }
51:
52: private File fileInfoFile;
53: private boolean ignoreTimeStamp = false;
54:
55: /**
56: * File info file.
57: * @ant.required
58: * @param timeStampFile
59: */
60: public void setFileInfoFile(File fileInfoFile) {
61: this .fileInfoFile = fileInfoFile;
62: }
63:
64: private File genRoot;
65:
66: /**
67: * Generation root to calculate relative file names.
68: * If not set then absolute file names are used.
69: * @ant.non-required
70: * @param timeStampFile
71: */
72: public void setGenRoot(File genRoot) {
73: this .genRoot = genRoot;
74: }
75:
76: /**
77: * Ignore file time and use only size and checksum to detect whether file was modified.
78: * Default is false.
79: * @param ignoreTimeStamp
80: * @ant.non-required
81: */
82: public void setIgnoreTimeStamp(boolean ignoreTimeStamp) {
83: this.ignoreTimeStamp = ignoreTimeStamp;
84: }
85: }
|