# HG changeset patch # User Sascha L. Teichmann # Date 1405674334 -7200 # Node ID 9dce39cffab3d64c11e7d00653a9b79fbee88577 # Parent 9e79e384aa8b1871ce829ad5f73e1c559f711846 Sediment load access: Cache values. diff -r 9e79e384aa8b -r 9dce39cffab3 artifacts/src/main/java/org/dive4elements/river/artifacts/access/SedimentLoadAccess.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/access/SedimentLoadAccess.java Thu Jul 17 18:22:16 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/access/SedimentLoadAccess.java Fri Jul 18 11:05:34 2014 +0200 @@ -23,6 +23,10 @@ private String time; private String unit; + private int [][] epochs; + + private int [] period; + public SedimentLoadAccess(D4EArtifact artifact) { super(artifact); } @@ -46,6 +50,9 @@ /** [startyear, endyear] if its about years. */ public int[] getPeriod() { + if (period != null) { + return period; + } if (getYearEpoch().equals("year") ) { Integer start = getInteger("start"); Integer end = getInteger("end"); @@ -54,12 +61,17 @@ return null; } - return new int[]{start.intValue(), end.intValue()}; + period = new int[]{start.intValue(), end.intValue()}; } return null; } public int[][] getEpochs() { + + if (epochs != null) { + return epochs; + } + if (!getYearEpoch().equals("epoch") && !getYearEpoch().equals("off_epoch")) { return null; @@ -74,7 +86,7 @@ String[] parts = data.split(";"); - int[][] list = new int[parts.length][]; + epochs = new int[parts.length][]; for (int i = 0; i < parts.length; i++) { String[] values = parts[i].split(","); @@ -82,13 +94,13 @@ try { ints.add(Integer.parseInt(values[0])); ints.add(Integer.parseInt(values[1])); - list[i] = ints.toNativeArray(); + epochs[i] = ints.toNativeArray(); } catch (NumberFormatException nfe) { logger.warn("Cannot parse int from string: '" + values + "'"); } } - return list; + return epochs; } /** Returns the selected unit (t/a or m3/a). */