comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQTJRDataSource.java @ 3468:f37e7e8907cb

merged flys-artifacts/2.8.1
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:39 +0200
parents 3e5f45a9e052
children
comparison
equal deleted inserted replaced
3387:5ffad8bde8ad 3468:f37e7e8907cb
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 WQTJRDataSource implements JRDataSource
17 {
18 /** The logger used in this exporter.*/
19 private static Logger logger = Logger.getLogger(WQTJRDataSource.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 WQTJRDataSource()
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 ("calculation".equals(fieldName)) {
80 value = metaData.get("calculation");
81 }
82 else if ("range".equals(fieldName)) {
83 value = data.get(index)[0];
84 }
85 else if ("W".equals(fieldName)) {
86 value = data.get(index)[1];
87 }
88 else if ("Q".equals(fieldName)) {
89 value = data.get(index)[2];
90 }
91 else if ("delta".equals(fieldName)) {
92 value = data.get(index)[3];
93 }
94 else if ("gaugename".equals(fieldName)) {
95 value = data.get(index)[4];
96 }
97 return value;
98 }
99 }
100 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org