annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/CalculationSelect.java @ 383:dcc3cd962c0e

Enhanced the transition model to reach a state that creates duration curves. flys-artifacts/trunk@1799 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 02 May 2011 16:58:04 +0000
parents b33ba2cd4a3e
children 929137ee8154
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
323
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
3 import java.util.Map;
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
4
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import org.apache.log4j.Logger;
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import org.w3c.dom.Element;
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8
313
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
9 import de.intevation.artifacts.Artifact;
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 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
11 import de.intevation.artifacts.CallMeta;
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 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
14
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import de.intevation.artifactdatabase.ProtocolUtils;
323
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
16 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
17
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
18 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
19
127
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 * @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
22 */
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 public class CalculationSelect extends DefaultState {
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 /** The logger that is used in this class.*/
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 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
27
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28
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
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
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
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
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
37 /** Constant value for the flood map calculation.*/
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
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
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
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
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
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
49 /** An array that holds all available calculation modes.*/
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
50 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
51 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
52 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
53 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
54 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
55 CALCULATION_DISCHARGE_LONGITUDINAL_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
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
57
323
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
58 /** Error message that is thrown if no mode has been chosen.*/
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
59 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
60 "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
61
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
62 /** Error message that is thrown if an invalid calculation mode has been
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
63 * chosen.*/
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_INVALID_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_invalid_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
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 protected Element[] createItems(
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 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
70 Artifact artifact,
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 String name,
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 CallContext context)
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 {
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
74 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
75 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
76
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
77 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
78
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
79 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
80 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
81 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
82 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
83 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
84 });
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 }
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
86
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 return calcs;
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88 }
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91 protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93 Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96 String[] arr = (String[]) obj;
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98 label.setTextContent(arr[0]);
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99 value.setTextContent(arr[1]);
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 item.appendChild(label);
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 item.appendChild(value);
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104 return item;
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105 }
323
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
106
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
107
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
108 @Override
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
109 public boolean validate(Artifact artifact, CallContext context)
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
110 throws IllegalArgumentException
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
111 {
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
112 logger.debug("CalculationSelect.validate");
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 Map<String, StateData> data = getData();
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
115
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
116 String calc = (String) data.get("calculation_mode").getValue();
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
117
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
118 if (calc == null) {
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
119 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
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 calc = calc.trim().toLowerCase();
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
123
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
124 for (String mode: CALCULATIONS) {
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
125 if (mode.equals(calc)) {
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
126 return true;
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
127 }
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
128 }
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
129
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
130 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
131 }
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
132 }
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
133 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org