comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WKmsJRDataSource.java @ 3318:dbe2f85bf160

merged flys-artifacts/2.8
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:35 +0200
parents 3e5f45a9e052
children
comparison
equal deleted inserted replaced
2987:98c7a46ec5ae 3318:dbe2f85bf160
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 }
76 else if ("date".equals(fieldName)) {
77 value = metaData.get("date");
78 }
79 else if ("range".equals(fieldName)) {
80 value = metaData.get("range");
81 }
82 else if ("gauge".equals(fieldName)) {
83 value = metaData.get("gauge");
84 }
85 else if ("calculation".equals(fieldName)) {
86 value = metaData.get("calculation");
87 }
88 else if ("differences".equals(fieldName)) {
89 value = metaData.get("differences");
90 }
91 else if ("km".equals(fieldName)) {
92 value = data.get(index)[0];
93 }
94 else if ("W".equals(fieldName)) {
95 value = data.get(index)[1];
96 }
97 else if ("Q".equals(fieldName)) {
98 value = data.get(index)[2];
99 }
100 else if ("description".equals(fieldName)) {
101 value = data.get(index)[3];
102 }
103 else if ("location".equals(fieldName)) {
104 value = data.get(index)[4];
105 }
106 else if ("gaugename".equals(fieldName)) {
107 value = data.get(index)[5];
108 }
109 else if ("day".equals(fieldName)) {
110 value = data.get(index)[6];
111 }
112 return value;
113 }
114 }
115 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org