You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2003/02/17 15:35:44 UTC
cvs commit: ant/src/main/org/apache/tools/ant/types/selectors SelectorUtils.java
bodewig 2003/02/17 06:35:44
Modified: src/main/org/apache/tools/ant/types/selectors
SelectorUtils.java
Log:
Add a Resource version of isOutOfDate
Revision Changes Path
1.9 +30 -0 ant/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java
Index: SelectorUtils.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- SelectorUtils.java 10 Feb 2003 14:14:35 -0000 1.8
+++ SelectorUtils.java 17 Feb 2003 14:35:44 -0000 1.9
@@ -58,6 +58,8 @@
import java.util.StringTokenizer;
import java.util.Vector;
+import org.apache.tools.ant.types.Resource;
+
/**
* <p>This is a utility class used by selectors and DirectoryScanner. The
* functionality more properly belongs just to selectors, but unfortunately
@@ -550,6 +552,34 @@
return true;
}
if ((src.lastModified() - granularity) > target.lastModified()) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Returns dependency information on these two resources. If src has been
+ * modified later than target, it returns true. If target doesn't exist,
+ * it likewise returns true. Otherwise, target is newer than src and
+ * is not out of date, thus the method returns false. It also returns
+ * false if the src file doesn't even exist, since how could the
+ * target then be out of date.
+ *
+ * @param src the original resource
+ * @param target the resource being compared against
+ * @param granularity the amount in seconds of slack we will give in
+ * determining out of dateness
+ * @return whether the target is out of date
+ */
+ public static boolean isOutOfDate(Resource src, Resource target,
+ int granularity) {
+ if (!src.isExists()) {
+ return false;
+ }
+ if (!target.isExists()) {
+ return true;
+ }
+ if ((src.getLastModified() - granularity) > target.getLastModified()) {
return true;
}
return false;