Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/MinMaxState.java @ 2211:5400631d2f96
Fixed problems with unformatted numbers in error message.
flys-artifacts/trunk@3845 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 31 Jan 2012 16:26:30 +0000 |
parents | a22e0cb6eace |
children | ee5310134463 |
rev | line source |
---|---|
2190
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.states; |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import org.w3c.dom.Element; |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 |
2202
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
5 import org.apache.log4j.Logger; |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
6 |
2190
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import de.intevation.artifacts.Artifact; |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import de.intevation.artifacts.CallContext; |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 import de.intevation.artifactdatabase.ProtocolUtils; |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.flys.artifacts.FLYSArtifact; |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 /** |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 */ |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 public abstract class MinMaxState extends DefaultState { |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 |
2202
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
23 private static final Logger logger = Logger.getLogger(MinMaxState.class); |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
24 |
2190
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 @Override |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 protected void appendItems( |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 Artifact artifact, |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 ElementCreator creator, |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 String name, |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 CallContext context, |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 Element select |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 ) { |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 FLYSArtifact flys = (FLYSArtifact) artifact; |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 select.setAttributeNS( |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 ArtifactNamespaceContext.NAMESPACE_URI, |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 "art:type", |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 getType()); |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 |
2202
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
40 String[] defMinMax = getDefaults(artifact, name); |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
41 |
2190
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 Element min = ProtocolUtils.createArtNode( |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 creator, |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 "min", |
2202
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
45 new String[] { "value", "default" }, |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
46 new String[] { String.valueOf(getLower(flys)), defMinMax[0] }); |
2190
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 Element max = ProtocolUtils.createArtNode( |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 creator, |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 "max", |
2202
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
51 new String[] { "value", "default" }, |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
52 new String[] { String.valueOf(getUpper(flys)), defMinMax[1] }); |
2190
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 select.appendChild(min); |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 select.appendChild(max); |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 } |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 |
2202
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
59 /** |
2205
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
60 * @param cc |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
61 * @param name |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
62 * @param value |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
63 * @param type |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
64 * |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
65 * @return |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
66 */ |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
67 @Override |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
68 protected String getLabelFor( |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
69 CallContext cc, |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
70 String name, |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
71 String value, |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
72 String type |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
73 ) { |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
74 if (type.indexOf("range") > 0) { |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
75 String[] minmax = extractRangeAsString(value); |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
76 |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
77 if (minmax != null) { |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
78 return minmax[0] + " - " + minmax[1]; |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
79 } |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
80 } |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
81 |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
82 return super.getLabelFor(cc, name, value, type); |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
83 } |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
84 |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
85 |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
86 /** |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
87 * Returns a string array with [min,max] from <i>rawValue</i>. |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
88 * <i>rawValue</i> should be a string like "1999;2001". |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
89 * |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
90 * @param rawValue A string with min and max separated by a ';'. |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
91 * |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
92 * @return the min and max as string array ([min,max]). |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
93 */ |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
94 protected String[] extractRangeAsString(String rawValue) { |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
95 return rawValue.split(";"); |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
96 } |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
97 |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
98 |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
99 /** |
2202
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
100 * This method returns the default values for min and max. If the static |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
101 * field DefaultState.USE_DEFAULTS is set, the minimum and maximum inserted |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
102 * by the user is returned as string. Otherwise, the absolute minimum and |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
103 * maximum are returned. |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
104 * |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
105 * @param artifact The FLYSArtifact. |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
106 * @param name The name of the parameter. |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
107 * |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
108 * @return a string array [min,max] that contains the minimum and maximum |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
109 * values for the parameter <i>name</i>. |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
110 */ |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
111 protected String[] getDefaults(Artifact artifact, String name) { |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
112 if (DefaultState.USE_DEFAULTS) { |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
113 String[] tmp = getMinMaxByParameter(artifact, name); |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
114 |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
115 return tmp != null ? tmp : getMinMaxDefaults(artifact, name); |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
116 } |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
117 else { |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
118 return getMinMaxDefaults(artifact, name); |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
119 } |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
120 } |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
121 |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
122 |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
123 /** |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
124 * Returns a string array with minimum and maximum inserted by the user as |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
125 * [min,max]. |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
126 * |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
127 * @param artifact The FLYSArtifact that stores the parameter. |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
128 * @param name The name of the parameter for raw min/max value string. |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
129 * |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
130 * @return a string array [min,max]. |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
131 */ |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
132 protected String[] getMinMaxByParameter(Artifact artifact, String name) { |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
133 FLYSArtifact flys = (FLYSArtifact) artifact; |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
134 String rawValue = flys.getDataAsString(name); |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
135 |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
136 if (rawValue == null) { |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
137 logger.debug("No value for '" + rawValue + "' existing."); |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
138 return null; |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
139 } |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
140 |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
141 logger.debug("Raw value for '" + name + "' = " + rawValue); |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
142 |
2205
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
143 return extractRangeAsString(rawValue); |
2202
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
144 } |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
145 |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
146 |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
147 /** |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
148 * Returns a string array with absolute minimum and maximum as [min,max]. |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
149 * |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
150 * @param artifact The FLYSArtifact (not used in this implementation). |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
151 * @param name The parameter name (not used in this implementation). |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
152 * |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
153 * @return a string array [min,max]. |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
154 */ |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
155 protected String[] getMinMaxDefaults(Artifact artifact, String name) { |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
156 FLYSArtifact flys = (FLYSArtifact) artifact; |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
157 |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
158 Object lower = getLower(flys); |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
159 Object upper = getUpper(flys); |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
160 |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
161 return new String[] { String.valueOf(lower), String.valueOf(upper) }; |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
162 } |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
163 |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
164 |
2190
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
165 protected abstract Object getLower(FLYSArtifact flys); |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
166 |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
167 protected abstract Object getUpper(FLYSArtifact flys); |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
168 |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
169 protected abstract String getType(); |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
170 } |
2792d2617be9
Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
171 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |