diff flys-aft/src/main/java/de/intevation/aft/TimeInterval.java @ 4089:859b4781554a

Prefetch existing time intervals from FLYS db. flys-aft/trunk@3574 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 03 Jan 2012 12:25:06 +0000
parents
children d556e29592f5
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-aft/src/main/java/de/intevation/aft/TimeInterval.java	Tue Jan 03 12:25:06 2012 +0000
@@ -0,0 +1,62 @@
+package de.intevation.aft;
+
+import java.util.Date;
+
+public class TimeInterval
+implements   Comparable<TimeInterval>
+{
+    protected int  id;
+    protected Date start;
+    protected Date stop;
+
+    public TimeInterval() {
+    }
+
+    public TimeInterval(int id, Date start, Date stop) {
+        this.id    = id;
+        this.start = start;
+        this.stop  = stop;
+    }
+
+    protected static int compare(Date d1, Date d2) {
+        long s1 = d1 != null ? d1.getTime()/1000L : 0L;
+        long s2 = d2 != null ? d2.getTime()/1000L : 0L;
+        long diff = s1 - s2;
+        return diff < 0L 
+            ? -1
+            : diff > 0L ? 1 : 0;
+    }
+
+    @Override
+    public int compareTo(TimeInterval other) {
+        int cmp = compare(start, other.start);
+        return cmp != 0 
+            ? cmp
+            : compare(stop, other.stop);
+    }
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public Date getStart() {
+        return start;
+    }
+
+    public void setStart(Date start) {
+        this.start = start;
+    }
+
+    public Date getStop() {
+        return stop;
+    }
+
+    public void setStop(Date stop) {
+        this.stop = stop;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org