Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/parsers/OfficialLinesConfigParser.java @ 6335:b2a470c148a7
Backend: First steps to integrate parsing of official config files.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 14 Jun 2013 13:01:26 +0200 |
parents | |
children | b966c67a476d |
comparison
equal
deleted
inserted
replaced
6334:9231940bd192 | 6335:b2a470c148a7 |
---|---|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU AGPL (>=v3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
6 * documentation coming with Dive4Elements River for details. | |
7 */ | |
8 | |
9 package org.dive4elements.river.importer.parsers; | |
10 | |
11 import java.io.File; | |
12 import java.io.FileInputStream; | |
13 import java.io.IOException; | |
14 import java.io.InputStreamReader; | |
15 import java.io.LineNumberReader; | |
16 import java.util.ArrayList; | |
17 import java.util.List; | |
18 | |
19 import org.apache.log4j.Logger; | |
20 | |
21 public class OfficialLinesConfigParser { | |
22 | |
23 private static Logger log = Logger.getLogger(OfficialLinesConfigParser.class); | |
24 | |
25 public static final String ENCODING = "ISO-8859-1"; | |
26 | |
27 private List<String> mainValueNames; | |
28 | |
29 public OfficialLinesConfigParser() { | |
30 mainValueNames = new ArrayList<String>(); | |
31 } | |
32 | |
33 public void reset() { | |
34 mainValueNames.clear(); | |
35 } | |
36 | |
37 public void parse(File file) throws IOException { | |
38 | |
39 log.info("Parsing offical lines config file: " + file); | |
40 | |
41 LineNumberReader reader = | |
42 new LineNumberReader( | |
43 new InputStreamReader( | |
44 new FileInputStream(file), ENCODING)); | |
45 | |
46 try { | |
47 String line; | |
48 while ((line = reader.readLine()) != null) { | |
49 if ((line = line.trim()).length() == 0 || line.charAt(0) == '*') { | |
50 continue; | |
51 } | |
52 mainValueNames.add(line); | |
53 } | |
54 } | |
55 finally { | |
56 reader.close(); | |
57 } | |
58 } | |
59 | |
60 public List<String> getMainValueNames() { | |
61 return mainValueNames; | |
62 } | |
63 } | |
64 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |