annotate flys-backend/src/main/java/org/dive4elements/river/importer/parsers/LineParser.java @ 5829:18619c1e7c2a

Repaired internal references.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 11:54:36 +0200
parents dfb26b03b179
children
rev   line source
5829
18619c1e7c2a Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5828
diff changeset
1 package org.dive4elements.river.importer.parsers;
2815
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import java.io.File;
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4
4193
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2815
diff changeset
5 import java.text.DateFormat;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2815
diff changeset
6 import java.text.NumberFormat;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2815
diff changeset
7 import java.text.ParseException;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2815
diff changeset
8 import java.text.SimpleDateFormat;
2815
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import java.util.Calendar;
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import java.util.Date;
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import java.util.Locale;
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import java.io.IOException;
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import java.io.LineNumberReader;
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import java.io.FileInputStream;
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 import java.io.InputStreamReader;
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 import org.apache.log4j.Logger;
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20
4679
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4193
diff changeset
21 /**
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4193
diff changeset
22 * Base-Class for prasers for line-based file formats.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4193
diff changeset
23 * Calls reset(), then read line by line, calling handleLine() for each,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4193
diff changeset
24 * then calls finish().
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4193
diff changeset
25 */
2815
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 public abstract class LineParser {
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27
4679
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4193
diff changeset
28 /** Private logger. */
2815
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 private static final Logger log = Logger.getLogger(LineParser.class);
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 public static final String ENCODING = "ISO-8859-1";
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 public static final Locale DEFAULT_LOCALE = Locale.GERMAN;
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 public static final String START_META_CHAR = "#";
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 public static final String SEPERATOR_CHAR = ";";
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38
4193
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2815
diff changeset
39 protected abstract void handleLine(int lineNum, String line);
2815
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 protected abstract void reset();
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 protected abstract void finish();
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44
4721
b0b1008c07e9 LineParser: Make file name available to subclasses.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4679
diff changeset
45 /** Name of file parsed. */
b0b1008c07e9 LineParser: Make file name available to subclasses.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4679
diff changeset
46 protected String fileName;
b0b1008c07e9 LineParser: Make file name available to subclasses.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4679
diff changeset
47
5809
53fcc0d5a03e LineParser: Store reference to input file.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4721
diff changeset
48 protected File inputFile;
53fcc0d5a03e LineParser: Store reference to input file.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4721
diff changeset
49
2815
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 /**
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 * This method reads each line of <i>file</i>. At the beginning,
4679
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4193
diff changeset
53 * <i>reset()</i> is called; afterwards for each line <i>handleLine()</i> is
2815
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 * called; at the end <i>finish</i> is called.
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 *
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 * @param file The file which should be parsed.
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 */
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 public void parse(File file) throws IOException {
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 log.info("Parsing file '" + file + "'");
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60
5809
53fcc0d5a03e LineParser: Store reference to input file.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4721
diff changeset
61 inputFile = file;
53fcc0d5a03e LineParser: Store reference to input file.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4721
diff changeset
62
4721
b0b1008c07e9 LineParser: Make file name available to subclasses.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4679
diff changeset
63 fileName = file.getName();
b0b1008c07e9 LineParser: Make file name available to subclasses.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4679
diff changeset
64
2815
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 reset();
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 LineNumberReader in = null;
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 try {
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 in =
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 new LineNumberReader(
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 new InputStreamReader(
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 new FileInputStream(file), ENCODING));
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73
4193
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2815
diff changeset
74 String line = null;
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2815
diff changeset
75 int lineNum = 1;
2815
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 while ((line = in.readLine()) != null) {
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 if ((line = line.trim()).length() == 0) {
4193
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2815
diff changeset
78 lineNum++;
2815
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79 continue;
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80 }
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81
4193
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2815
diff changeset
82 handleLine(lineNum++, line);
2815
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83 }
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84 }
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85 finally {
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86 if (in != null) {
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87 in.close();
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88 }
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89 }
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91 finish();
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 }
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94
4721
b0b1008c07e9 LineParser: Make file name available to subclasses.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4679
diff changeset
95 /** Returns the name of the file parsed. */
b0b1008c07e9 LineParser: Make file name available to subclasses.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4679
diff changeset
96 protected String getFileName() {
b0b1008c07e9 LineParser: Make file name available to subclasses.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4679
diff changeset
97 return fileName;
b0b1008c07e9 LineParser: Make file name available to subclasses.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4679
diff changeset
98 }
b0b1008c07e9 LineParser: Make file name available to subclasses.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4679
diff changeset
99
5809
53fcc0d5a03e LineParser: Store reference to input file.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4721
diff changeset
100 /** Returns the file currently parsed. */
53fcc0d5a03e LineParser: Store reference to input file.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4721
diff changeset
101 protected File getInputFile() {
53fcc0d5a03e LineParser: Store reference to input file.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4721
diff changeset
102 return inputFile;
53fcc0d5a03e LineParser: Store reference to input file.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4721
diff changeset
103 }
53fcc0d5a03e LineParser: Store reference to input file.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4721
diff changeset
104
4721
b0b1008c07e9 LineParser: Make file name available to subclasses.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4679
diff changeset
105
2815
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106 protected static String stripMetaLine(String line) {
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107 String tmp = line.substring(1, line.length());
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
109 if (tmp.startsWith(" ")) {
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110 return tmp.substring(1, tmp.length());
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
111 }
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112 else {
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113 return tmp;
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114 }
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
115 }
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
116
4193
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2815
diff changeset
117 public static double getDouble(String doubleString) throws ParseException {
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2815
diff changeset
118 NumberFormat nf = NumberFormat.getInstance(DEFAULT_LOCALE);
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2815
diff changeset
119 Number value = nf.parse(doubleString);
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2815
diff changeset
120
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2815
diff changeset
121 return value.doubleValue();
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2815
diff changeset
122 }
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2815
diff changeset
123
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2815
diff changeset
124 public static Date getDate(String dateString) throws ParseException {
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2815
diff changeset
125 DateFormat df = SimpleDateFormat.getDateInstance(
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2815
diff changeset
126 SimpleDateFormat.MEDIUM, DEFAULT_LOCALE);
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2815
diff changeset
127
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2815
diff changeset
128 return df.parse(dateString);
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2815
diff changeset
129 }
f63b39799d2d Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2815
diff changeset
130
2815
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
131
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
132 public static Date getDateFromYear(int year) {
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
133 Calendar cal = Calendar.getInstance();
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
134 cal.set(year, 0, 1);
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
135
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
136 return cal.getTime();
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
137 }
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
138 }
3febaed762b8 Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
139 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org