Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/parsers/WaterlevelDifferencesParser.java @ 6752:f275aae00c55
issue1433: Do not emit warning when tolerated empty string as value.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 06 Aug 2013 10:54:41 +0200 |
parents | 6c41a4ca2876 |
children | e032e9e6d09e |
comparison
equal
deleted
inserted
replaced
6748:aee8cb5c801a | 6752:f275aae00c55 |
---|---|
197 } | 197 } |
198 } | 198 } |
199 } | 199 } |
200 | 200 |
201 | 201 |
202 /** Handle one line of data, add one value for all columns. */ | 202 /** Handle one line of data, add one value for all columns. |
203 * @param line the line to parse | |
204 */ | |
203 private void handleDataLine(String line) { | 205 private void handleDataLine(String line) { |
204 String[] cols = line.split(SEPERATOR_CHAR); | 206 String[] cols = line.split(SEPERATOR_CHAR); |
205 | 207 |
206 if (cols == null || cols.length < 2) { | 208 if (cols == null || cols.length < 2) { |
207 log.warn("skip invalid waterlevel-diff line: '" + line + "'"); | 209 log.warn("skip invalid waterlevel-diff line: '" + line + "'"); |
208 return; | 210 return; |
209 } | 211 } |
210 | 212 |
211 try { | 213 try { |
214 // The first value in a line like 12,9;4,3;4,5 is the station, later | |
215 // real values. | |
212 Double station = nf.parse(cols[0]).doubleValue(); | 216 Double station = nf.parse(cols[0]).doubleValue(); |
213 | 217 |
214 for (int i = 0; i < columns.length; i++) { | 218 for (int i = 0; i < columns.length; i++) { |
215 int idx = i+1; | 219 int idx = i+1; |
216 | 220 |
219 continue; | 223 continue; |
220 } | 224 } |
221 | 225 |
222 String value = cols[idx]; | 226 String value = cols[idx]; |
223 | 227 |
224 try { | 228 if (value != null && !value.equals("")) { |
225 columns[i].addColumnValue( | 229 try { |
226 new BigDecimal(station), | 230 columns[i].addColumnValue( |
227 new BigDecimal(nf.parse(value).doubleValue())); | 231 new BigDecimal(station), |
228 } | 232 new BigDecimal(nf.parse(value).doubleValue())); |
229 catch (ParseException pe) { | 233 } |
230 log.warn("Could not parse value: '" + value + "'"); | 234 catch (ParseException pe) { |
235 log.warn("Could not parse value: '" + value + "'"); | |
236 } | |
231 } | 237 } |
232 } | 238 } |
233 } | 239 } |
234 catch (ParseException pe) { | 240 catch (ParseException pe) { |
235 log.warn("Could not parse station: '" + line + "'"); | 241 log.warn("Could not parse station: '" + line + "'"); |