comparison flys-backend/src/main/java/de/intevation/flys/importer/WstParser.java @ 495:a92da0b3e8e7

Importer: make column names in WST files unique by appending (1), (2) and so on in case of collision flys-backend/trunk@1849 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 08 May 2011 11:07:22 +0000
parents 13af9318a4a2
children 677a6fceea6e
comparison
equal deleted inserted replaced
494:88d5b02ff0c1 495:a92da0b3e8e7
206 } 206 }
207 207
208 if (firstAbfluesse != null) { 208 if (firstAbfluesse != null) {
209 if (!columnHeaderChecked) { 209 if (!columnHeaderChecked) {
210 int unknownCount = 0; 210 int unknownCount = 0;
211 HashSet<String> uniqueColumnNames =
212 new HashSet<String>();
211 for (int i = 0; i < lsBezeichner.length; ++i) { 213 for (int i = 0; i < lsBezeichner.length; ++i) {
212 if (lsBezeichner[i] == null 214 if (lsBezeichner[i] == null
213 || lsBezeichner[i].length() == 0) { 215 || lsBezeichner[i].length() == 0) {
214 double q = firstAbfluesse[i].doubleValue(); 216 double q = firstAbfluesse[i].doubleValue();
215 if (q < 0.001) { 217 if (q < 0.001) {
219 } 221 }
220 else { 222 else {
221 lsBezeichner[i] = "Q="+format(q); 223 lsBezeichner[i] = "Q="+format(q);
222 } 224 }
223 } 225 }
224 wst.getColumn(i).setName(lsBezeichner[i]); 226 String candidate = lsBezeichner[i];
227 int collision = 1;
228 while (!uniqueColumnNames.add(candidate)) {
229 candidate = lsBezeichner[i] +
230 " (" + collision + ")";
231 ++collision;
232 }
233 wst.getColumn(i).setName(candidate);
225 } 234 }
226 columnHeaderChecked = true; 235 columnHeaderChecked = true;
227 } 236 }
228 237
229 BigDecimal [] data = 238 BigDecimal [] data =

http://dive4elements.wald.intevation.org