Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/Access.java @ 5151:240ff7aeb6de
DoubleUtil: Use tolerance when comparing doubles in explode(). Fixes flys/issue1132.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 01 Mar 2013 10:04:57 +0100 |
parents | cbd0fafcb26b |
children |
rev | line source |
---|---|
3208
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.access; |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import de.intevation.artifactdatabase.data.StateData; |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 import de.intevation.flys.artifacts.FLYSArtifact; |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 |
3210
ae14f412ba10
SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3209
diff
changeset
|
7 import de.intevation.flys.artifacts.model.DateRange; |
3208
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.flys.utils.FLYSUtils; |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 import gnu.trove.TDoubleArrayList; |
4152
5ff3b2f5fb1c
Added evaluation timerange to subtitle of historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3259
diff
changeset
|
12 import gnu.trove.TLongArrayList; |
3208
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 import java.util.ArrayList; |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 import java.util.Date; |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 import org.apache.log4j.Logger; |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 |
3209
03fc05655258
SQ: Added artifact access stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3208
diff
changeset
|
19 public class Access |
3208
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 private static Logger log = Logger.getLogger(Access.class); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 protected FLYSArtifact artifact; |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 public Access() { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 public Access(FLYSArtifact artifact) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 this.artifact = artifact; |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 public FLYSArtifact getArtifact() { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 return artifact; |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 public void setArtifact(FLYSArtifact artifact) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 this.artifact = artifact; |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 |
4528
cbd0fafcb26b
Documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4152
diff
changeset
|
40 |
cbd0fafcb26b
Documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4152
diff
changeset
|
41 /** Get a data entry as string. */ |
3208
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 protected String getString(String key) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 StateData sd = artifact.getData(key); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 if (sd == null) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 log.warn("missing '" + key + "' value"); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 return null; |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 return (String)sd.getValue(); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 |
4528
cbd0fafcb26b
Documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4152
diff
changeset
|
51 /** Get a data entry as double, returns null if string not double valueoffable. */ |
3208
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 protected Double getDouble(String key) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 StateData sd = artifact.getData(key); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 if (sd == null) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 log.warn("missing '" + key + "' value"); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 return null; |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 try { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 return Double.valueOf((String)sd.getValue()); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 catch (NumberFormatException nfe) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 log.warn(key + " '" + sd.getValue() + "' is not numeric."); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 return null; |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 protected Long getLong(String key) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 StateData sd = artifact.getData(key); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 if (sd == null) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 log.warn("missing '" + key + "' value"); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 return null; |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 try { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 return Long.valueOf((String)sd.getValue()); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 catch (NumberFormatException nfe) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 log.warn(key + " '" + sd.getValue() + "' is not a long integer."); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
79 return null; |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
80 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
81 |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
82 protected Integer getInteger(String key) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
83 StateData sd = artifact.getData(key); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
84 if (sd == null) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
85 log.warn("missing '" + key + "' value"); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
86 return null; |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
87 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
88 try { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
89 return Integer.valueOf((String)sd.getValue()); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
90 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
91 catch (NumberFormatException nfe) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
92 log.warn(key + " '" + sd.getValue() + "' is not a integer."); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
93 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 return null; |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
97 protected int [] getIntArray(String key) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
98 StateData sd = artifact.getData(key); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
99 if (sd == null) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
100 log.warn("missing '" + key +"' value"); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 return null; |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
102 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
103 return FLYSUtils.intArrayFromString((String)sd.getValue()); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
104 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
105 |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
106 protected DateRange [] getDateRange(String key) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
107 |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
108 StateData sd = artifact.getData(key); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
109 |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
110 if (sd == null) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
111 log.warn("missing '" + key + "'"); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
112 return null; |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
113 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
114 |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
115 String data = (String)sd.getValue(); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
116 String[] pairs = data.split("\\s*;\\s*"); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
117 |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
118 ArrayList<DateRange> aPs = new ArrayList<DateRange>(pairs.length); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
119 |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
120 for (int i = 0; i < pairs.length; i++) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
121 String[] fromTo = pairs[i].split("\\s*,\\s*"); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
122 if (fromTo.length >= 2) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
123 try { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
124 Date from = new Date(Long.parseLong(fromTo[0])); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
125 Date to = new Date(Long.parseLong(fromTo[1])); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
126 DateRange aP = new DateRange(from, to); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
127 if (!aPs.contains(aP)) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
128 aPs.add(aP); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
129 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
130 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
131 catch (NumberFormatException nfe) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
132 log.warn(key + " contains no long values.", nfe); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
133 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
134 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
135 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
136 |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
137 DateRange [] result = aPs.toArray(new DateRange[aPs.size()]); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
138 |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
139 if (log.isDebugEnabled()) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
140 for (int i = 0; i < result.length; ++i) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
141 DateRange ap = result[i]; |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
142 log.debug("period " + |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
143 ap.getFrom() + " - " + ap.getTo()); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
144 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
145 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
146 |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
147 return result; |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
148 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
149 |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
150 protected Boolean getBoolean(String key) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
151 StateData sd = artifact.getData(key); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
152 if (sd == null) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
153 log.warn("missing '" + key + "' value"); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
154 return null; |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
155 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
156 return Boolean.valueOf((String)sd.getValue()); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
157 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
158 |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
159 protected double [] getDoubleArray(String key) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
160 StateData sd = artifact.getData(key); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
161 if (sd == null) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
162 log.warn("missing '" + key + "'"); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
163 return null; |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
164 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
165 String [] parts = ((String)sd.getValue()).split("[\\s;]+"); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
166 TDoubleArrayList list = new TDoubleArrayList(parts.length); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
167 for (String part: parts) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
168 try { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
169 list.add(Double.parseDouble(part)); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
170 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
171 catch (NumberFormatException nfe) { |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
172 log.warn("'" + part + "' is not numeric."); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
173 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
174 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
175 return list.toNativeArray(); |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
176 } |
4152
5ff3b2f5fb1c
Added evaluation timerange to subtitle of historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3259
diff
changeset
|
177 |
5ff3b2f5fb1c
Added evaluation timerange to subtitle of historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3259
diff
changeset
|
178 protected long [] getLongArray(String key) { |
5ff3b2f5fb1c
Added evaluation timerange to subtitle of historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3259
diff
changeset
|
179 StateData sd = artifact.getData(key); |
5ff3b2f5fb1c
Added evaluation timerange to subtitle of historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3259
diff
changeset
|
180 if (sd == null) { |
5ff3b2f5fb1c
Added evaluation timerange to subtitle of historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3259
diff
changeset
|
181 log.warn("missing '" + key + "'"); |
5ff3b2f5fb1c
Added evaluation timerange to subtitle of historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3259
diff
changeset
|
182 return null; |
5ff3b2f5fb1c
Added evaluation timerange to subtitle of historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3259
diff
changeset
|
183 } |
5ff3b2f5fb1c
Added evaluation timerange to subtitle of historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3259
diff
changeset
|
184 String [] parts = ((String)sd.getValue()).split("[\\s;]+"); |
5ff3b2f5fb1c
Added evaluation timerange to subtitle of historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3259
diff
changeset
|
185 TLongArrayList list = new TLongArrayList(parts.length); |
5ff3b2f5fb1c
Added evaluation timerange to subtitle of historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3259
diff
changeset
|
186 for (String part: parts) { |
5ff3b2f5fb1c
Added evaluation timerange to subtitle of historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3259
diff
changeset
|
187 try { |
5ff3b2f5fb1c
Added evaluation timerange to subtitle of historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3259
diff
changeset
|
188 list.add(Long.parseLong(part)); |
5ff3b2f5fb1c
Added evaluation timerange to subtitle of historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3259
diff
changeset
|
189 } |
5ff3b2f5fb1c
Added evaluation timerange to subtitle of historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3259
diff
changeset
|
190 catch (NumberFormatException nfe) { |
5ff3b2f5fb1c
Added evaluation timerange to subtitle of historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3259
diff
changeset
|
191 log.warn("'" + part + "' is not numeric."); |
5ff3b2f5fb1c
Added evaluation timerange to subtitle of historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3259
diff
changeset
|
192 } |
5ff3b2f5fb1c
Added evaluation timerange to subtitle of historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3259
diff
changeset
|
193 } |
5ff3b2f5fb1c
Added evaluation timerange to subtitle of historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3259
diff
changeset
|
194 return list.toNativeArray(); |
5ff3b2f5fb1c
Added evaluation timerange to subtitle of historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3259
diff
changeset
|
195 } |
3208
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
196 } |
90c4ce100ce1
Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
197 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |