Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/importer/parsers/LineParser.java @ 4721:b0b1008c07e9
LineParser: Make file name available to subclasses.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 27 Dec 2012 13:19:34 +0100 |
parents | 23392c25fc11 |
children | 53fcc0d5a03e |
comparison
equal
deleted
inserted
replaced
4720:9f7cd65daac2 | 4721:b0b1008c07e9 |
---|---|
40 | 40 |
41 protected abstract void reset(); | 41 protected abstract void reset(); |
42 | 42 |
43 protected abstract void finish(); | 43 protected abstract void finish(); |
44 | 44 |
45 /** Name of file parsed. */ | |
46 protected String fileName; | |
47 | |
45 | 48 |
46 /** | 49 /** |
47 * This method reads each line of <i>file</i>. At the beginning, | 50 * This method reads each line of <i>file</i>. At the beginning, |
48 * <i>reset()</i> is called; afterwards for each line <i>handleLine()</i> is | 51 * <i>reset()</i> is called; afterwards for each line <i>handleLine()</i> is |
49 * called; at the end <i>finish</i> is called. | 52 * called; at the end <i>finish</i> is called. |
50 * | 53 * |
51 * @param file The file which should be parsed. | 54 * @param file The file which should be parsed. |
52 */ | 55 */ |
53 public void parse(File file) throws IOException { | 56 public void parse(File file) throws IOException { |
54 log.info("Parsing file '" + file + "'"); | 57 log.info("Parsing file '" + file + "'"); |
58 | |
59 fileName = file.getName(); | |
55 | 60 |
56 reset(); | 61 reset(); |
57 | 62 |
58 LineNumberReader in = null; | 63 LineNumberReader in = null; |
59 try { | 64 try { |
78 in.close(); | 83 in.close(); |
79 } | 84 } |
80 } | 85 } |
81 | 86 |
82 finish(); | 87 finish(); |
88 } | |
89 | |
90 | |
91 /** Returns the name of the file parsed. */ | |
92 protected String getFileName() { | |
93 return fileName; | |
83 } | 94 } |
84 | 95 |
85 | 96 |
86 protected static String stripMetaLine(String line) { | 97 protected static String stripMetaLine(String line) { |
87 String tmp = line.substring(1, line.length()); | 98 String tmp = line.substring(1, line.length()); |