diff flys-backend/src/main/java/de/intevation/flys/importer/WstColumnValueKey.java @ 478:db430bd9e0e0

Implemented a WstColumnValue cache to speed up inserting WST files into database. flys-backend/trunk@1734 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 20 Apr 2011 07:21:03 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/WstColumnValueKey.java	Wed Apr 20 07:21:03 2011 +0000
@@ -0,0 +1,56 @@
+package de.intevation.flys.importer;
+
+import de.intevation.flys.model.WstColumnValue;
+
+
+public class WstColumnValueKey {
+
+    protected int    wstColumnId;
+    protected double position;
+    protected double w;
+
+
+    public WstColumnValueKey(WstColumnValue value) {
+        this.wstColumnId = value.getWstColumn().getId();
+        this.position    = value.getPosition().doubleValue();
+        this.w           = value.getW().doubleValue();
+    }
+
+
+    public WstColumnValueKey(int wstColumnId, double position, double w) {
+        this.wstColumnId = wstColumnId;
+        this.position    = position;
+        this.w           = w;
+    }
+
+
+    public int hashCode() {
+        int a = new Integer(wstColumnId).hashCode();
+        int b = new Double(position).hashCode();
+        int c = new Double(w).hashCode();
+
+        return (a ^ (b << 3) ^ (c << 6));
+    }
+
+
+    public boolean equals(Object obj) {
+        if (!(obj instanceof WstColumnValueKey)) {
+            return false;
+        }
+
+        WstColumnValueKey other = (WstColumnValueKey) obj;
+
+        if (this.wstColumnId != other.wstColumnId) {
+            return false;
+        }
+        else if (this.position != other.position) {
+            return false;
+        }
+        else if (this.w != other.w) {
+            return false;
+        }
+
+        return true;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org