Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/access/HistoricalDischargeAccess.java @ 5838:5aa05a7a34b7
Rename modules to more fitting names.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 15:23:37 +0200 |
parents | flys-artifacts/src/main/java/org/dive4elements/river/artifacts/access/HistoricalDischargeAccess.java@bd047b71ab37 |
children | 4897a58c8746 |
comparison
equal
deleted
inserted
replaced
5837:d9901a08d0a6 | 5838:5aa05a7a34b7 |
---|---|
1 package org.dive4elements.river.artifacts.access; | |
2 | |
3 import java.util.Date; | |
4 | |
5 import org.dive4elements.river.artifacts.FLYSArtifact; | |
6 import org.dive4elements.river.artifacts.model.Timerange; | |
7 | |
8 | |
9 public class HistoricalDischargeAccess extends RiverAccess { | |
10 | |
11 public static enum EvaluationMode { | |
12 W, Q | |
13 } | |
14 | |
15 public static final String DATA_EVALUATION_TIME = "year_range"; | |
16 public static final String DATA_EVALUATION_MODE = "historical_mode"; | |
17 public static final String DATA_INPUT_VALUES = "historical_values"; | |
18 | |
19 private Timerange evaluationTimerange; | |
20 private EvaluationMode evaluationMode; | |
21 | |
22 private double[] qs; | |
23 private double[] ws; | |
24 | |
25 public HistoricalDischargeAccess(FLYSArtifact artifact) { | |
26 super(artifact); | |
27 } | |
28 | |
29 /** | |
30 * This method returns the evaluation mode. The evaluation mode W is set, if | |
31 * the <b>DATA_EVALUATION_MODE</b> is 0. Otherwise, the evaluation mode Q is | |
32 * set. | |
33 * | |
34 * @return EvaluationMode.W if the parameter <i>historical_mode</i> is set | |
35 * to 0, otherwise EvaluationMode.Q. | |
36 */ | |
37 public EvaluationMode getEvaluationMode() { | |
38 if (evaluationMode == null) { | |
39 int mode = getInteger(DATA_EVALUATION_MODE); | |
40 evaluationMode = mode == 0 ? EvaluationMode.W : EvaluationMode.Q; | |
41 } | |
42 | |
43 return evaluationMode; | |
44 } | |
45 | |
46 /** | |
47 * This method returns the time range specified by <i>year_range</i> | |
48 * parameter. This parameter has to be a string that consists of two long | |
49 * values (time millis since 1970) separated by a ';'. | |
50 * | |
51 * @return the evaluation time range specified by <i>year_range</i>. | |
52 */ | |
53 public Timerange getEvaluationTimerange() { | |
54 if (evaluationTimerange == null) { | |
55 long[] startend = getLongArray(DATA_EVALUATION_TIME); | |
56 | |
57 if (startend != null && startend.length > 1) { | |
58 Date start = new Date(startend[0]); | |
59 Date end = new Date(startend[1]); | |
60 | |
61 evaluationTimerange = new Timerange(start, end); | |
62 } | |
63 } | |
64 | |
65 return evaluationTimerange; | |
66 } | |
67 | |
68 /** | |
69 * This method returns the input Q values if the evaluation mode Q is set. | |
70 * Otherwise, this method will return a double array of length 0. The values | |
71 * returned by this method are extracted from string parameter | |
72 * <i>historical_values</i>. | |
73 * | |
74 * @return the input Q values or a double array of length 0. | |
75 */ | |
76 public double[] getQs() { | |
77 if (qs == null) { | |
78 if (getEvaluationMode() == EvaluationMode.Q) { | |
79 qs = getDoubleArray(DATA_INPUT_VALUES); | |
80 } | |
81 else { | |
82 qs = new double[0]; | |
83 } | |
84 } | |
85 | |
86 return qs; | |
87 } | |
88 | |
89 /** | |
90 * This method returns the input W values if the evaluation mode W is set. | |
91 * Otherwise, this method will return a double array of length 0. The values | |
92 * returned by this method are extracted from string parameter | |
93 * <i>historical_values</i>. | |
94 * | |
95 * @return the input W values or a double array of length 0. | |
96 */ | |
97 public double[] getWs() { | |
98 if (ws == null) { | |
99 if (getEvaluationMode() == EvaluationMode.W) { | |
100 ws = getDoubleArray(DATA_INPUT_VALUES); | |
101 } | |
102 else { | |
103 ws = new double[0]; | |
104 } | |
105 } | |
106 | |
107 return ws; | |
108 } | |
109 } |