annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/Access.java @ 3626:d3e3a7aaeddf

issue729, show default line labels for line sin cross sections. flys-artifacts/trunk@5320 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 30 Aug 2012 15:16:49 +0000
parents 9422b559b2d5
children 5ff3b2f5fb1c
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;
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13 import java.util.ArrayList;
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 import java.util.Date;
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16 import org.apache.log4j.Logger;
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17
3209
03fc05655258 SQ: Added artifact access stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3208
diff changeset
18 public class Access
3208
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19 {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 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
21
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 protected FLYSArtifact artifact;
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24 public Access() {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 }
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 public Access(FLYSArtifact artifact) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 this.artifact = artifact;
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 }
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 public FLYSArtifact getArtifact() {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 return artifact;
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 }
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 public void setArtifact(FLYSArtifact artifact) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 this.artifact = artifact;
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 }
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 protected String getString(String key) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 StateData sd = artifact.getData(key);
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 if (sd == null) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 log.warn("missing '" + key + "' value");
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 return null;
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 }
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 return (String)sd.getValue();
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 }
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 protected Double getDouble(String key) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 StateData sd = artifact.getData(key);
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 if (sd == null) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51 log.warn("missing '" + key + "' value");
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 return null;
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 }
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 try {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55 return Double.valueOf((String)sd.getValue());
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 }
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 catch (NumberFormatException nfe) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58 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
59 }
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 return null;
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 }
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63 protected Long getLong(String key) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
64 StateData sd = artifact.getData(key);
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65 if (sd == null) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 log.warn("missing '" + key + "' value");
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67 return null;
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68 }
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69 try {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70 return Long.valueOf((String)sd.getValue());
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
71 }
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
72 catch (NumberFormatException nfe) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
73 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
74 }
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
75 return null;
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
76 }
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
77
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
78 protected Integer getInteger(String key) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
79 StateData sd = artifact.getData(key);
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
80 if (sd == null) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
81 log.warn("missing '" + key + "' value");
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
82 return null;
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
83 }
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
84 try {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
85 return Integer.valueOf((String)sd.getValue());
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
86 }
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
87 catch (NumberFormatException nfe) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
88 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
89 }
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
90 return null;
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
91 }
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
92
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
93 protected int [] getIntArray(String key) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
94 StateData sd = artifact.getData(key);
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
95 if (sd == null) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
96 log.warn("missing '" + key +"' value");
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
97 return null;
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
98 }
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
99 return FLYSUtils.intArrayFromString((String)sd.getValue());
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
100 }
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
101
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
102 protected DateRange [] getDateRange(String key) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
103
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
104 StateData sd = artifact.getData(key);
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 if (sd == null) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
107 log.warn("missing '" + key + "'");
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
108 return null;
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
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
111 String data = (String)sd.getValue();
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
112 String[] pairs = data.split("\\s*;\\s*");
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 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
115
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
116 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
117 String[] fromTo = pairs[i].split("\\s*,\\s*");
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
118 if (fromTo.length >= 2) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
119 try {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
120 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
121 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
122 DateRange aP = new DateRange(from, to);
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
123 if (!aPs.contains(aP)) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
124 aPs.add(aP);
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
125 }
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
126 }
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
127 catch (NumberFormatException nfe) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
128 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
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 }
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
132
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
133 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
134
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
135 if (log.isDebugEnabled()) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
136 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
137 DateRange ap = result[i];
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
138 log.debug("period " +
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
139 ap.getFrom() + " - " + ap.getTo());
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
140 }
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
141 }
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
142
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
143 return result;
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 protected Boolean getBoolean(String key) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
147 StateData sd = artifact.getData(key);
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
148 if (sd == null) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
149 log.warn("missing '" + key + "' value");
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
150 return null;
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
151 }
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
152 return Boolean.valueOf((String)sd.getValue());
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
153 }
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
154
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
155 protected double [] getDoubleArray(String key) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
156 StateData sd = artifact.getData(key);
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
157 if (sd == null) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
158 log.warn("missing '" + key + "'");
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
159 return null;
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
160 }
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
161 String [] parts = ((String)sd.getValue()).split("[\\s;]+");
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
162 TDoubleArrayList list = new TDoubleArrayList(parts.length);
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
163 for (String part: parts) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
164 try {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
165 list.add(Double.parseDouble(part));
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
166 }
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
167 catch (NumberFormatException nfe) {
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
168 log.warn("'" + part + "' is not numeric.");
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
169 }
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 return list.toNativeArray();
90c4ce100ce1 Added new base class for *Access
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
172 }
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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org