comparison 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
comparison
equal deleted inserted replaced
2599:fb7975828ffa 2600:3f1cc396d253
16 import org.hibernate.SessionFactory; 16 import org.hibernate.SessionFactory;
17 import org.hibernate.impl.SessionFactoryImpl; 17 import org.hibernate.impl.SessionFactoryImpl;
18 18
19 import gnu.trove.TDoubleArrayList; 19 import gnu.trove.TDoubleArrayList;
20 import gnu.trove.TIntArrayList; 20 import gnu.trove.TIntArrayList;
21 import gnu.trove.TLongArrayList;
21 22
22 import de.intevation.artifacts.Artifact; 23 import de.intevation.artifacts.Artifact;
23 import de.intevation.artifacts.CallContext; 24 import de.intevation.artifacts.CallContext;
24 25
25 import de.intevation.artifacts.common.utils.Config; 26 import de.intevation.artifacts.common.utils.Config;
810 return integers.toNativeArray(); 811 return integers.toNativeArray();
811 } 812 }
812 813
813 814
814 /** 815 /**
816 * This method transform a string into a long array. Therefore, the string
817 * <i>raw</i> must consist of int values separated by a <i>';'</i>.
818 *
819 * @param raw The raw long array as string separated by a ';'.
820 *
821 * @return an array of int values.
822 */
823 public static long[] longArrayFromString(String raw) {
824 String[] splitted = raw != null ? raw.split(";") : null;
825
826 if (splitted == null || splitted.length == 0) {
827 logger.warn("No long values found in '" + raw + "'");
828 return new long[0];
829 }
830
831 TLongArrayList longs = new TLongArrayList(splitted.length);
832
833 for (String value: splitted) {
834 try {
835 longs.add(Long.valueOf(value));
836 }
837 catch (NumberFormatException nfe) {
838 logger.warn("Parsing long failed: " + nfe);
839 }
840 }
841
842 return longs.toNativeArray();
843 }
844
845
846 /**
815 * This method transform a string into an double array. Therefore, the 847 * This method transform a string into an double array. Therefore, the
816 * string <i>raw</i> must consist of double values separated by a 848 * string <i>raw</i> must consist of double values separated by a
817 * <i>';'</i>. 849 * <i>';'</i>.
818 * 850 *
819 * @param raw The raw double array as string separated by a ';'. 851 * @param raw The raw double array as string separated by a ';'.

http://dive4elements.wald.intevation.org