Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/exports/WDifferencesExporter.java @ 1769:bbe12d77710d
Prepare rendering of added other (static) WKms and Differences in LongitudinalSection Diagrams.
flys-artifacts/trunk@3090 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 26 Oct 2011 12:54:22 +0000 |
parents | 2c643a643026 |
children | 65dac9cf6ff5 |
rev | line source |
---|---|
1161
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.exports; |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
2 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
3 import java.io.IOException; |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
4 import java.io.OutputStream; |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
5 import java.text.NumberFormat; |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
6 import java.util.ArrayList; |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
7 import java.util.List; |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
8 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
9 import org.w3c.dom.Document; |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
10 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
11 import org.apache.log4j.Logger; |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
12 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
13 import au.com.bytecode.opencsv.CSVWriter; |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
14 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.artifacts.CallContext; |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
16 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
17 import de.intevation.flys.artifacts.model.CalculationResult; |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
18 import de.intevation.flys.artifacts.model.WKms; |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
19 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
20 import de.intevation.flys.utils.Formatter; |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
21 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
22 /** |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
23 * (CSV)Exporter for WDifferences. |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
24 */ |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
25 public class WDifferencesExporter extends AbstractExporter { |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
26 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
27 /** The logger used in this exporter. */ |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
28 private static Logger logger = Logger.getLogger(WDifferencesExporter.class); |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
29 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
30 |
1705
2c643a643026
Addressed 'wrong label' issue of wdiff csv-export.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1161
diff
changeset
|
31 public static final String WDIFF_CSV_KM_HEADER = |
1161
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
32 "export.w_differences.csv.header.km"; |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
33 |
1705
2c643a643026
Addressed 'wrong label' issue of wdiff csv-export.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1161
diff
changeset
|
34 public static final String WDIFF_CSV_W_HEADER = |
1161
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
35 "export.w_differences.csv.header.w"; |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
36 |
1705
2c643a643026
Addressed 'wrong label' issue of wdiff csv-export.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1161
diff
changeset
|
37 public static final String WDIFF_DEFAULT_CSV_KM_HEADER = "Fluss-Km"; |
2c643a643026
Addressed 'wrong label' issue of wdiff csv-export.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1161
diff
changeset
|
38 public static final String WDIFF_DEFAULT_CSV_W_HEADER = "m"; |
1161
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
39 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
40 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
41 /** The storage that contains all WKms objects for the different facets. */ |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
42 protected List<WKms[]> data; |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
43 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
44 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
45 public void init(Document request, OutputStream out, CallContext context) { |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
46 logger.debug("WDifferencesExporter.init"); |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
47 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
48 super.init(request, out, context); |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
49 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
50 this.data = new ArrayList<WKms[]>(); |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
51 } |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
52 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
53 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
54 /** |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
55 * Genereate data in csv format. |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
56 */ |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
57 @Override |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
58 public void generate() |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
59 throws IOException |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
60 { |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
61 logger.debug("WDifferencesExporter.generate"); |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
62 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
63 if (facet == null) { |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
64 throw new IOException("invalid (null) facet for exporter"); |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
65 } |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
66 else if (facet.equals(AbstractExporter.FACET_CSV)) { |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
67 generateCSV(); |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
68 } |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
69 else { |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
70 throw new IOException("invalid facet (" + facet + ") for exporter"); |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
71 } |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
72 } |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
73 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
74 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
75 /** |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
76 * Adds given data. |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
77 * @param d either a WKms or a CalculationResult to add to data. |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
78 */ |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
79 @Override |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
80 protected void addData(Object d) { |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
81 if (d instanceof CalculationResult) { |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
82 d = ((CalculationResult)d).getData(); |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
83 if (d instanceof WKms []) { |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
84 data.add((WKms [])d); |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
85 } |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
86 } |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
87 else if (d instanceof WKms) { |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
88 data.add(new WKms[] { (WKms) d }); |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
89 } |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
90 } |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
91 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
92 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
93 /** |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
94 * Lets writer write all data (including header). |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
95 * @param writer Writer to write data with. |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
96 */ |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
97 @Override |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
98 protected void writeCSVData(CSVWriter writer) { |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
99 logger.info("WDifferencesExporter.writeData"); |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
100 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
101 writeCSVHeader(writer); |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
102 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
103 for (WKms[] tmp: data) { |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
104 for (WKms wkms: tmp) { |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
105 wKms2CSV(writer, wkms); |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
106 } |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
107 } |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
108 } |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
109 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
110 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
111 /** |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
112 * Lets csvwriter write the header (first line in file). |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
113 * @param write Writer to write header with. |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
114 */ |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
115 protected void writeCSVHeader(CSVWriter writer) { |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
116 logger.info("WDifferencesExporter.writeCSVHeader"); |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
117 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
118 writer.writeNext(new String[] { |
1705
2c643a643026
Addressed 'wrong label' issue of wdiff csv-export.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1161
diff
changeset
|
119 msg(WDIFF_CSV_KM_HEADER, WDIFF_DEFAULT_CSV_KM_HEADER), |
2c643a643026
Addressed 'wrong label' issue of wdiff csv-export.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1161
diff
changeset
|
120 msg(WDIFF_CSV_W_HEADER, WDIFF_DEFAULT_CSV_W_HEADER) |
1161
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
121 }); |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
122 } |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
123 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
124 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
125 protected void wKms2CSV(CSVWriter writer, WKms wkms) { |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
126 logger.debug("WDifferencesExporter.wQKms2CSV"); |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
127 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
128 NumberFormat kmf = getKmFormatter(); |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
129 NumberFormat wf = getWFormatter(); |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
130 int size = wkms.size(); |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
131 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
132 for (int i = 0; i < size; i ++) { |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
133 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
134 writer.writeNext(new String[] { |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
135 kmf.format(wkms.getKm(i)), |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
136 wf.format(wkms.getW(i)) |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
137 }); |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
138 } |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
139 } |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
140 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
141 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
142 /** |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
143 * Returns the number formatter for kilometer values. |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
144 * |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
145 * @return the number formatter for kilometer values. |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
146 */ |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
147 protected NumberFormat getKmFormatter() { |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
148 return Formatter.getWaterlevelKM(context); |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
149 } |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
150 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
151 |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
152 /** |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
153 * Returns the number formatter for W values. |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
154 * |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
155 * @return the number formatter for W values. |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
156 */ |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
157 protected NumberFormat getWFormatter() { |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
158 return Formatter.getWaterlevelW(context); |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
159 } |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
160 } |
9bdf738abbad
Added CSV Exporter for WDifferences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
161 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |