annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/CalculationSelect.java @ 648:d4c4fefb095b

The matrix that is used to transform chart image coordinates into chart coordinates supports inverted x-axis now. flys-artifacts/trunk@2037 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 01 Jun 2011 09:18:00 +0000
parents 929137ee8154
children 627be3ca1ab6
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
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 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
14 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
15
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
16 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
17 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
18
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 /**
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 * @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
21 */
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 public class CalculationSelect extends DefaultState {
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 /** 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
25 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
26
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27
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
28
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
29 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
30
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
31 /** 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
32 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
33 "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
34
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
35 /** 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
36 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
37 "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
38
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 /** 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
40 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
41 "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
42
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
43 /** 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
44 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
45 "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
46
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
47 /** 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
48 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
49 "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
50
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
51 /** 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
52 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
53 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
54 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
55 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
56 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
57 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
58
7f909429ccc8 Added some more calculation types (to the DESCRIBE in the calculation select state).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
59
323
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
60 /** 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
61 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
62 "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
63
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
64 /** 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
65 * chosen.*/
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
66 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
67 "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
68
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
69
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 protected Element[] createItems(
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 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
72 Artifact artifact,
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 String name,
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 CallContext context)
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 {
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
76 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
77 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
78
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
79 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
80
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 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
82 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
83 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
84 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
85 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
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 }
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 return calcs;
127
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
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93 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
94 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
95 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
96 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
97
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98 String[] arr = (String[]) obj;
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 label.setTextContent(arr[0]);
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 value.setTextContent(arr[1]);
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 item.appendChild(label);
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104 item.appendChild(value);
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106 return item;
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107 }
323
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
108
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
109
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
110 @Override
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
111 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
112 throws IllegalArgumentException
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 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
115 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
116
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
117 StateData data = getData(flys, FIELD_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
118 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
119
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
120 if (calc == null) {
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
121 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
122 }
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 calc = calc.trim().toLowerCase();
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
125
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
126 for (String mode: CALCULATIONS) {
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
127 if (mode.equals(calc)) {
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
128 return true;
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 }
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
131
b33ba2cd4a3e The calculation method is validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
132 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
133 }
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
134 }
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
135 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org