Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/CalculationSelect.java @ 1835:35e38e2afb22
Re-enabled mainvalue-recommendation for computed discharge curves.
flys-artifacts/trunk@3171 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 04 Nov 2011 13:29:15 +0000 |
parents | 47ecf98f09eb |
children | be06dbc2ed1d |
rev | line source |
---|---|
127
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.states; |
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import org.apache.log4j.Logger; |
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 |
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import org.w3c.dom.Element; |
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 |
313
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
157
diff
changeset
|
7 import de.intevation.artifacts.Artifact; |
127
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import de.intevation.artifacts.CallContext; |
141
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
9 import de.intevation.artifacts.CallMeta; |
127
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.artifacts.common.utils.XMLUtils; |
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 |
323
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
13 import de.intevation.artifactdatabase.data.StateData; |
127
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 |
624
929137ee8154
ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
323
diff
changeset
|
15 import de.intevation.flys.artifacts.FLYSArtifact; |
141
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
16 import de.intevation.flys.artifacts.resources.Resources; |
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
17 |
127
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 /** |
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 */ |
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 public class CalculationSelect extends DefaultState { |
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 |
1148
302461d5d071
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1050
diff
changeset
|
23 /** The logger that is used in this class. */ |
127
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 private static Logger logger = Logger.getLogger(CalculationSelect.class); |
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 |
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 |
624
929137ee8154
ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
323
diff
changeset
|
27 public static final String FIELD_MODE = "calculation_mode"; |
929137ee8154
ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
323
diff
changeset
|
28 |
1148
302461d5d071
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1050
diff
changeset
|
29 /** Constant value for the reference line calculation. */ |
157
b5c99532f898
Adapted the available calculation modes of WINFO and its order in the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
141
diff
changeset
|
30 public static final String CALCULATION_SURFACE_CURVE = |
b5c99532f898
Adapted the available calculation modes of WINFO and its order in the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
141
diff
changeset
|
31 "calc.surface.curve"; |
141
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
32 |
1148
302461d5d071
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1050
diff
changeset
|
33 /** Constant value for the differences calculation. */ |
157
b5c99532f898
Adapted the available calculation modes of WINFO and its order in the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
141
diff
changeset
|
34 public static final String CALCULATION_DURATION_CURVE = |
b5c99532f898
Adapted the available calculation modes of WINFO and its order in the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
141
diff
changeset
|
35 "calc.duration.curve"; |
141
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
36 |
1148
302461d5d071
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1050
diff
changeset
|
37 /** Constant value for the flood map calculation. */ |
141
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
38 public static final String CALCULATION_FLOOD_MAP = |
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
39 "calc.flood.map"; |
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
40 |
1148
302461d5d071
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1050
diff
changeset
|
41 /** Constant value for the profile calculation. */ |
157
b5c99532f898
Adapted the available calculation modes of WINFO and its order in the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
141
diff
changeset
|
42 public static final String CALCULATION_DISCHARGE_LONGITUDINAL_CURVE = |
b5c99532f898
Adapted the available calculation modes of WINFO and its order in the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
141
diff
changeset
|
43 "calc.discharge.longitudinal.section"; |
141
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
44 |
1148
302461d5d071
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1050
diff
changeset
|
45 /** Constant value for the state discharge curve calculation. */ |
157
b5c99532f898
Adapted the available calculation modes of WINFO and its order in the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
141
diff
changeset
|
46 public static final String CALCULATION_DISCHARGE_CURVE = |
b5c99532f898
Adapted the available calculation modes of WINFO and its order in the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
141
diff
changeset
|
47 "calc.discharge.curve"; |
141
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
48 |
1152
fc572b30f1b8
Added configuration to kick-in w-differences branch of winfo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1148
diff
changeset
|
49 /** Constant value for the state w differences calculation. */ |
fc572b30f1b8
Added configuration to kick-in w-differences branch of winfo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1148
diff
changeset
|
50 public static final String CALCULATION_W_DIFFERENCES = |
fc572b30f1b8
Added configuration to kick-in w-differences branch of winfo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1148
diff
changeset
|
51 "calc.w.differences"; |
fc572b30f1b8
Added configuration to kick-in w-differences branch of winfo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1148
diff
changeset
|
52 |
fc572b30f1b8
Added configuration to kick-in w-differences branch of winfo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1148
diff
changeset
|
53 /** An array that holds all available calculation modes. */ |
141
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
54 public static final String[] CALCULATIONS = { |
157
b5c99532f898
Adapted the available calculation modes of WINFO and its order in the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
141
diff
changeset
|
55 CALCULATION_SURFACE_CURVE, |
141
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
56 CALCULATION_FLOOD_MAP, |
157
b5c99532f898
Adapted the available calculation modes of WINFO and its order in the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
141
diff
changeset
|
57 CALCULATION_DISCHARGE_CURVE, |
b5c99532f898
Adapted the available calculation modes of WINFO and its order in the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
141
diff
changeset
|
58 CALCULATION_DURATION_CURVE, |
1152
fc572b30f1b8
Added configuration to kick-in w-differences branch of winfo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1148
diff
changeset
|
59 CALCULATION_DISCHARGE_LONGITUDINAL_CURVE, |
fc572b30f1b8
Added configuration to kick-in w-differences branch of winfo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1148
diff
changeset
|
60 CALCULATION_W_DIFFERENCES }; |
141
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
61 |
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
62 |
1148
302461d5d071
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1050
diff
changeset
|
63 /** Error message that is thrown if no mode has been chosen. */ |
323
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
64 public static final String ERROR_NO_CALCULATION_MODE = |
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
65 "error_feed_no_calculation_mode"; |
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
66 |
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
67 /** Error message that is thrown if an invalid calculation mode has been |
1148
302461d5d071
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1050
diff
changeset
|
68 * chosen. */ |
323
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
69 public static final String ERROR_INVALID_CALCULATION_MODE = |
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
70 "error_feed_invalid_calculation_mode"; |
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
71 |
742
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
660
diff
changeset
|
72 |
660
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
73 public CalculationSelect() { |
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
74 } |
323
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
75 |
660
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
76 |
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
77 @Override |
127
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 protected Element[] createItems( |
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 XMLUtils.ElementCreator cr, |
313
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
157
diff
changeset
|
80 Artifact artifact, |
127
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 String name, |
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 CallContext context) |
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 { |
141
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
84 CallMeta meta = context.getMeta(); |
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
85 Element[] calcs = new Element[CALCULATIONS.length]; |
127
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 |
141
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
87 int i = 0; |
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
88 |
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
89 for (String calc: CALCULATIONS) { |
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
90 calcs[i++] = createItem( |
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
91 cr, new String[] { |
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
92 Resources.getMsg(meta, calc, calc), |
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
93 calc |
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
94 }); |
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
95 } |
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
96 |
7f909429ccc8
Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
127
diff
changeset
|
97 return calcs; |
127
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
98 } |
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
99 |
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
100 |
323
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
101 @Override |
1050
eccf966fb677
State engine: Removed CallContext from state validation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
742
diff
changeset
|
102 public boolean validate(Artifact artifact) |
323
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
103 throws IllegalArgumentException |
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
104 { |
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
105 logger.debug("CalculationSelect.validate"); |
624
929137ee8154
ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
323
diff
changeset
|
106 FLYSArtifact flys = (FLYSArtifact) artifact; |
323
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
107 |
624
929137ee8154
ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
323
diff
changeset
|
108 StateData data = getData(flys, FIELD_MODE); |
1148
302461d5d071
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1050
diff
changeset
|
109 String calc = (data != null) ? (String) data.getValue() : null; |
323
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
110 |
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
111 if (calc == null) { |
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
112 throw new IllegalArgumentException(ERROR_NO_CALCULATION_MODE); |
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
113 } |
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
114 |
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
115 calc = calc.trim().toLowerCase(); |
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
116 |
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
117 for (String mode: CALCULATIONS) { |
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
118 if (mode.equals(calc)) { |
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
119 return true; |
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
120 } |
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
121 } |
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
122 |
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
123 throw new IllegalArgumentException(ERROR_INVALID_CALCULATION_MODE); |
b33ba2cd4a3e
The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
124 } |
127
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
125 } |
21d791e21aca
Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
126 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |