Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/MultiIntArrayState.java @ 2697:8a6ce15ced7f
Fixed constructor in class 'Function'.
flys-artifacts/trunk@4407 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Tue, 15 May 2012 13:04:01 +0000 |
parents | 1bc35de0b786 |
children | 71f072d8b3d8 |
rev | line source |
---|---|
2696
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.states; |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import org.w3c.dom.Element; |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import org.apache.log4j.Logger; |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import de.intevation.artifacts.Artifact; |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import de.intevation.artifacts.CallContext; |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.artifacts.common.model.KVP; |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 /** |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 * State that holds minimun and maximum (for validation). |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 * |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 */ |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 public abstract class MultiIntArrayState extends DefaultState { |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 private static final Logger logger = |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 Logger.getLogger(MultiIntArrayState.class); |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 @Override |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 protected void appendItems( |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 Artifact artifact, |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 ElementCreator creator, |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 String name, |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 CallContext context, |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 Element select |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 ) { |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 try { |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 creator.addAttr(select, "type", "intoptions", true); |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 Element choices = creator.create("choices"); |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 for (KVP kvp: getOptions(artifact, name)) { |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 Element item = creator.create("item"); |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 creator.addAttr(item, "label", kvp.getValue().toString(), true); |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 item.setTextContent(kvp.getKey().toString()); |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 choices.appendChild(item); |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 } |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 select.appendChild(choices); |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 } |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 catch (IllegalArgumentException iae) { |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 logger.warn("Illegal argument", iae); |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 } |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 } |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 protected abstract KVP<Integer, String>[] getOptions( |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 Artifact artifact, |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 String parameterName |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 ) |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 throws IllegalArgumentException; |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 } |