Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/parsers/LineParser.java @ 8042:9342d7fe0ee7
Introduce LineParserException for CSV file parsing.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Wed, 16 Jul 2014 18:33:28 +0200 |
parents | fd3a24336e6a |
children | 9d2e69f971f5 |
comparison
equal
deleted
inserted
replaced
8041:01ad09af0975 | 8042:9342d7fe0ee7 |
---|---|
40 public static final Locale DEFAULT_LOCALE = Locale.GERMAN; | 40 public static final Locale DEFAULT_LOCALE = Locale.GERMAN; |
41 | 41 |
42 public static final String START_META_CHAR = "#"; | 42 public static final String START_META_CHAR = "#"; |
43 public static final String SEPERATOR_CHAR = ";"; | 43 public static final String SEPERATOR_CHAR = ";"; |
44 | 44 |
45 public static class LineParserException extends Exception { | |
46 public LineParserException() { | |
47 } | |
45 | 48 |
46 protected abstract void handleLine(int lineNum, String line); | 49 public LineParserException(String msg) { |
50 super(msg); | |
51 } | |
52 } // class LineParserException | |
53 | |
54 | |
55 protected abstract void handleLine(int lineNum, String line) throws LineParserException; | |
47 | 56 |
48 protected abstract void reset(); | 57 protected abstract void reset(); |
49 | 58 |
50 protected abstract void finish(); | 59 protected abstract void finish(); |
51 | 60 |
86 continue; | 95 continue; |
87 } | 96 } |
88 | 97 |
89 handleLine(lineNum++, line); | 98 handleLine(lineNum++, line); |
90 } | 99 } |
91 } | 100 } catch (LineParserException lpe) { |
92 finally { | 101 log.error("Error while parsing file '" + file + "'", lpe); |
102 } finally { | |
93 if (in != null) { | 103 if (in != null) { |
94 in.close(); | 104 in.close(); |
95 } | 105 } |
96 } | 106 } |
97 | 107 |