Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/parsers/BedHeightParser.java @ 6285:f55a99fe5ce3
Whitespace correction and cminor ruft code removal.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Wed, 12 Jun 2013 10:43:30 +0200 |
parents | 52d4175cb331 |
children | 1173e9f47b52 |
comparison
equal
deleted
inserted
replaced
6284:f50d8cee3b64 | 6285:f55a99fe5ce3 |
---|---|
113 public void parse(File file) throws IOException { | 113 public void parse(File file) throws IOException { |
114 log.info("Parsing bed height single file '" + file + "'"); | 114 log.info("Parsing bed height single file '" + file + "'"); |
115 | 115 |
116 ImportBedHeight obj = newImportBedHeight(file.getName().replaceAll("\\.csv", "")); | 116 ImportBedHeight obj = newImportBedHeight(file.getName().replaceAll("\\.csv", "")); |
117 | 117 |
118 LineNumberReader in = null; | 118 LineNumberReader in = |
119 new LineNumberReader( | |
120 new InputStreamReader( | |
121 new FileInputStream(file), ENCODING)); | |
122 | |
119 try { | 123 try { |
120 in = | |
121 new LineNumberReader( | |
122 new InputStreamReader( | |
123 new FileInputStream(file), ENCODING)); | |
124 | |
125 String line = null; | 124 String line = null; |
126 while ((line = in.readLine()) != null) { | 125 while ((line = in.readLine()) != null) { |
127 if ((line = line.trim()).length() == 0) { | 126 if ((line = line.trim()).length() == 0) { |
128 continue; | 127 continue; |
129 } | 128 } |
138 | 137 |
139 log.info("File contained " + obj.getValueCount() + " values."); | 138 log.info("File contained " + obj.getValueCount() + " values."); |
140 bedHeights.add(obj); | 139 bedHeights.add(obj); |
141 } | 140 } |
142 finally { | 141 finally { |
143 if (in != null) { | 142 in.close(); |
144 in.close(); | |
145 } | |
146 } | 143 } |
147 } | 144 } |
148 | 145 |
149 | 146 |
150 protected static String stripMetaLine(String line) { | 147 protected static String stripMetaLine(String line) { |
159 } | 156 } |
160 | 157 |
161 | 158 |
162 public static Date getStartDateFromYear(int year) { | 159 public static Date getStartDateFromYear(int year) { |
163 Calendar cal = Calendar.getInstance(); | 160 Calendar cal = Calendar.getInstance(); |
164 cal.clear(); | 161 cal.clear(); |
165 cal.set(year, 0, 1, 0, 0, 0); | 162 cal.set(year, 0, 1, 0, 0, 0); |
166 | 163 |
167 return cal.getTime(); | 164 return cal.getTime(); |
168 } | 165 } |
169 | 166 |
347 | 344 |
348 if (m.matches()) { | 345 if (m.matches()) { |
349 String tmp = m.group(1).replace(";", "").trim(); | 346 String tmp = m.group(1).replace(";", "").trim(); |
350 | 347 |
351 BedHeightType bht = BedHeightType.fetchBedHeightTypeForType( | 348 BedHeightType bht = BedHeightType.fetchBedHeightTypeForType( |
352 tmp, ImporterSession.getInstance().getDatabaseSession()); | 349 tmp, ImporterSession.getInstance().getDatabaseSession()); |
353 | 350 |
354 if (bht != null) { | 351 if (bht != null) { |
355 obj.setType(new ImportBedHeightType(bht)); | 352 obj.setType(new ImportBedHeightType(bht)); |
356 return true; | 353 return true; |
357 } | 354 } |