Mercurial > dive4elements > river
changeset 3001:619fe13e2397
FixA: Fixed access to analysis periods.
flys-artifacts/trunk@4557 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 30 May 2012 13:03:22 +0000 (2012-05-30) |
parents | 3dd1c320cf81 |
children | e54dd69d306f |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/FixationArtifactAccess.java |
diffstat | 2 files changed, 25 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Wed May 30 12:12:45 2012 +0000 +++ b/flys-artifacts/ChangeLog Wed May 30 13:03:22 2012 +0000 @@ -1,3 +1,8 @@ +2012-05-30 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/FixationArtifactAccess.java: + Fixed access to analysis periods. + 2012-05-30 Raimund Renkert <raimund.renkert@intevation.de> * doc/conf/artifacts/fixanalysis.xml:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FixationArtifactAccess.java Wed May 30 12:12:45 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FixationArtifactAccess.java Wed May 30 13:03:22 2012 +0000 @@ -1,5 +1,6 @@ package de.intevation.flys.artifacts; +import java.util.ArrayList; import java.util.Arrays; import de.intevation.artifactdatabase.data.StateData; @@ -298,7 +299,6 @@ public long [][] getAnalysisPeriods() { if (analysisPeriods == null) { - /** TODO: Use real arrays here! */ StateData sd = artifact.getData("ana_data"); if (sd == null) { @@ -306,21 +306,27 @@ return null; } - try { - String data = (String)sd.getValue(); - String[] pairs = data.split(";"); - for (int i = 0; i < pairs.length; i++) { - String[] fromTo = pairs[i].split(","); - analysisPeriods = new long [][] { - { Long.parseLong(fromTo[0]), - Long.parseLong(fromTo[1]) } - }; + String data = (String)sd.getValue(); + String[] pairs = data.split(";"); + + ArrayList<long[]> aPs = new ArrayList<long[]>(pairs.length); + + for (int i = 0; i < pairs.length; i++) { + String[] fromTo = pairs[i].split(","); + if (fromTo.length >= 2) { + try { + aPs.add(new long [] { + Long.parseLong(fromTo[0]), + Long.parseLong(fromTo[1]) + }); + } + catch (NumberFormatException nfe) { + log.warn("ana_data contains no long values.", nfe); + } } } - catch (NumberFormatException nfe) { - log.warn("ana_data contains no long values."); - return null; - } + + analysisPeriods = aPs.toArray(new long[aPs.size()][]); } if (log.isDebugEnabled()) {