Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/parsers/WstParser.java @ 7883:fc8d5b5f2c99
Removed trailing whitespace.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 16 May 2014 17:10:10 +0200 |
parents | 1890bd524d27 |
children | 3bb1c62ad732 |
comparison
equal
deleted
inserted
replaced
7882:4534659e200e | 7883:fc8d5b5f2c99 |
---|---|
150 BigDecimal kmHist1 = null; | 150 BigDecimal kmHist1 = null; |
151 BigDecimal kmHist2 = null; | 151 BigDecimal kmHist2 = null; |
152 | 152 |
153 boolean columnHeaderChecked = false; | 153 boolean columnHeaderChecked = false; |
154 | 154 |
155 /* Default string for altitude reference | 155 /* Default string for altitude reference |
156 * if none is found in WST-file. | 156 * if none is found in WST-file. |
157 * Use in case no unit comment is found in file */ | 157 * Use in case no unit comment is found in file */ |
158 String einheit = "m ü. unbekannte Referenz"; | 158 String einheit = "m ü. unbekannte Referenz"; |
159 boolean unitFound = false; | 159 boolean unitFound = false; |
160 | 160 |
341 ") found more than once. -> ignored"); | 341 ") found more than once. -> ignored"); |
342 continue; | 342 continue; |
343 } | 343 } |
344 | 344 |
345 // check consistence of station ordering in file | 345 // check consistence of station ordering in file |
346 if (kmHist2 != null && | 346 if (kmHist2 != null && |
347 kmHist2.compareTo(kmHist1) != kmHist1.compareTo(kaem)) { | 347 kmHist2.compareTo(kmHist1) != kmHist1.compareTo(kaem)) { |
348 throw new ParseException("WST: Stations in " + file + | 348 throw new ParseException("WST: Stations in " + file + |
349 " near line " + in.getLineNumber() + | 349 " near line " + in.getLineNumber() + |
350 " not ordered. File rejected."); | 350 " not ordered. File rejected."); |
351 } | 351 } |
352 | 352 |
353 // remember stations in two previous lines | 353 // remember stations in two previous lines |
354 kmHist2 = kmHist1; | 354 kmHist2 = kmHist1; |
379 ) { | 379 ) { |
380 lsBezeichner[j] = input.substring( | 380 lsBezeichner[j] = input.substring( |
381 i, i+colNaWidths[j]).trim(); | 381 i, i+colNaWidths[j]).trim(); |
382 } | 382 } |
383 } | 383 } |
384 else { // fetch column names from non-comment header line | 384 else { // fetch column names from non-comment header line |
385 // (above first Qs) | 385 // (above first Qs) |
386 // first column begins at position 8 in line | 386 // first column begins at position 8 in line |
387 for (int i = 8, col = 0; i < input.length(); i += 9) { | 387 for (int i = 8, col = 0; i < input.length(); i += 9) { |
388 // one column header is 9 chars wide | 388 // one column header is 9 chars wide |
389 // but the last one may be shorter | 389 // but the last one may be shorter |
390 if (col < lsBezeichner.length) { | 390 if (col < lsBezeichner.length) { |
391 lsBezeichner[col++] = | 391 lsBezeichner[col++] = |
392 input.substring(i, | 392 input.substring(i, |
393 Math.min(i + 9, input.length())).trim(); | 393 Math.min(i + 9, input.length())).trim(); |
394 } | 394 } |
395 if (col == lsBezeichner.length) { | 395 if (col == lsBezeichner.length) { |
396 break; | 396 break; |
397 } | 397 } |
404 if (!unitFound) { | 404 if (!unitFound) { |
405 log.warn("no unit and height reference found. Using default."); | 405 log.warn("no unit and height reference found. Using default."); |
406 } | 406 } |
407 wst.setUnit(new ImportUnit(einheit)); | 407 wst.setUnit(new ImportUnit(einheit)); |
408 | 408 |
409 // add Q-ranges obtained from previous lines | 409 // add Q-ranges obtained from previous lines |
410 // in case there was no further Q-line | 410 // in case there was no further Q-line |
411 // but only if there were values following the last Q-line | 411 // but only if there were values following the last Q-line |
412 if (minKm != MAX_RANGE && maxKm != MIN_RANGE) { | 412 if (minKm != MAX_RANGE && maxKm != MIN_RANGE) { |
413 if (kmHist1 != null && kmHist2 != null | 413 if (kmHist1 != null && kmHist2 != null |
414 && kmHist1.compareTo(kmHist2) < 0) { // stations descending in file | 414 && kmHist1.compareTo(kmHist2) < 0) { // stations descending in file |
533 for (int i = 0; i < tokenCount; ++i) { | 533 for (int i = 0; i < tokenCount; ++i) { |
534 pos += 9; | 534 pos += 9; |
535 if (pos >= line.length()) { | 535 if (pos >= line.length()) { |
536 break; | 536 break; |
537 } | 537 } |
538 strings.add(line.substring(pos, | 538 strings.add(line.substring(pos, |
539 Math.min(pos + 8, line.length()))); | 539 Math.min(pos + 8, line.length()))); |
540 } | 540 } |
541 | 541 |
542 return strings.toArray(new String[strings.size()]); | 542 return strings.toArray(new String[strings.size()]); |
543 } | 543 } |