Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WKmsJRDataSource.java @ 4369:8ddab49ff297
Added i18n string for sediment load output tab title.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Fri, 02 Nov 2012 14:44:11 +0100 |
parents | 3e5f45a9e052 |
children |
rev | line source |
---|---|
2176 | 1 package de.intevation.flys.artifacts.model; |
2 | |
3 import java.util.ArrayList; | |
4 import java.util.HashMap; | |
5 | |
6 import org.apache.log4j.Logger; | |
7 | |
8 import net.sf.jasperreports.engine.JRDataSource; | |
9 import net.sf.jasperreports.engine.JRException; | |
10 import net.sf.jasperreports.engine.JRField; | |
11 | |
12 | |
13 /** | |
14 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> | |
15 */ | |
16 public class WKmsJRDataSource implements JRDataSource | |
17 { | |
18 /** The logger used in this exporter.*/ | |
19 private static Logger logger = Logger.getLogger(WKmsJRDataSource.class); | |
20 | |
21 /** | |
22 * | |
23 */ | |
24 private ArrayList<String[]> data; | |
25 private HashMap<String, String> metaData; | |
26 | |
27 private int index = -1; | |
28 | |
29 /** | |
30 * | |
31 */ | |
32 public WKmsJRDataSource() | |
33 { | |
34 data = new ArrayList<String[]>(); | |
35 metaData = new HashMap<String, String>(); | |
36 } | |
37 | |
38 | |
39 /** | |
40 * | |
41 */ | |
42 public void addData(String[] data) { | |
43 this.data.add(data); | |
44 } | |
45 | |
46 | |
47 /** | |
48 * | |
49 */ | |
50 public void addMetaData(String key, String value) { | |
51 this.metaData.put(key, value); | |
52 } | |
53 | |
54 | |
55 /** | |
56 * | |
57 */ | |
58 public boolean next() throws JRException | |
59 { | |
60 index++; | |
61 | |
62 return (index < data.size()); | |
63 } | |
64 | |
65 | |
66 /** | |
67 * | |
68 */ | |
69 public Object getFieldValue(JRField field) throws JRException | |
70 { | |
71 Object value = ""; | |
72 String fieldName = field.getName(); | |
73 if ("river".equals(fieldName)) { | |
74 value = metaData.get("river"); | |
75 } | |
3085
3e5f45a9e052
Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
76 else if ("date".equals(fieldName)) { |
2176 | 77 value = metaData.get("date"); |
78 } | |
3085
3e5f45a9e052
Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
79 else if ("range".equals(fieldName)) { |
2176 | 80 value = metaData.get("range"); |
81 } | |
3085
3e5f45a9e052
Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
82 else if ("gauge".equals(fieldName)) { |
2176 | 83 value = metaData.get("gauge"); |
84 } | |
3085
3e5f45a9e052
Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
85 else if ("calculation".equals(fieldName)) { |
2176 | 86 value = metaData.get("calculation"); |
87 } | |
3085
3e5f45a9e052
Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
88 else if ("differences".equals(fieldName)) { |
2180
65b32220f197
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2178
diff
changeset
|
89 value = metaData.get("differences"); |
65b32220f197
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2178
diff
changeset
|
90 } |
3085
3e5f45a9e052
Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
91 else if ("km".equals(fieldName)) { |
2176 | 92 value = data.get(index)[0]; |
93 } | |
3085
3e5f45a9e052
Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
94 else if ("W".equals(fieldName)) { |
2176 | 95 value = data.get(index)[1]; |
96 } | |
3085
3e5f45a9e052
Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
97 else if ("Q".equals(fieldName)) { |
2176 | 98 value = data.get(index)[2]; |
99 } | |
3085
3e5f45a9e052
Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
100 else if ("description".equals(fieldName)) { |
2176 | 101 value = data.get(index)[3]; |
102 } | |
3085
3e5f45a9e052
Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
103 else if ("location".equals(fieldName)) { |
2176 | 104 value = data.get(index)[4]; |
105 } | |
3085
3e5f45a9e052
Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
106 else if ("gaugename".equals(fieldName)) { |
2176 | 107 value = data.get(index)[5]; |
108 } | |
3085
3e5f45a9e052
Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
109 else if ("day".equals(fieldName)) { |
2178
1d7fb2cabfc7
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
110 value = data.get(index)[6]; |
1d7fb2cabfc7
Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2176
diff
changeset
|
111 } |
2176 | 112 return value; |
113 } | |
114 } | |
3083
4bd3d8bbb60c
Added missing vim lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2180
diff
changeset
|
115 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |