diff flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java @ 2600:3f1cc396d253

Issue 506. Use a complete date for istorical dischage curves instead of a year. flys-artifacts/trunk@4177 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 20 Mar 2012 15:08:01 +0000
parents efb2038783f9
children 79f6d0802b06
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java	Tue Mar 20 13:51:39 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java	Tue Mar 20 15:08:01 2012 +0000
@@ -18,6 +18,7 @@
 
 import gnu.trove.TDoubleArrayList;
 import gnu.trove.TIntArrayList;
+import gnu.trove.TLongArrayList;
 
 import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.CallContext;
@@ -812,6 +813,37 @@
 
 
     /**
+     * This method transform a string into a long array. Therefore, the string
+     * <i>raw</i> must consist of int values separated by a <i>';'</i>.
+     *
+     * @param raw The raw long array as string separated by a ';'.
+     *
+     * @return an array of int values.
+     */
+    public static long[] longArrayFromString(String raw) {
+        String[] splitted = raw != null ? raw.split(";") : null;
+
+        if (splitted == null || splitted.length == 0) {
+            logger.warn("No long values found in '" + raw + "'");
+            return new long[0];
+        }
+
+        TLongArrayList longs = new TLongArrayList(splitted.length);
+
+        for (String value: splitted) {
+            try {
+                longs.add(Long.valueOf(value));
+            }
+            catch (NumberFormatException nfe) {
+                logger.warn("Parsing long failed: " + nfe);
+            }
+        }
+
+        return longs.toNativeArray();
+    }
+
+
+    /**
      * This method transform a string into an double array. Therefore, the
      * string <i>raw</i> must consist of double values separated by a
      * <i>';'</i>.

http://dive4elements.wald.intevation.org