Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WWQQJRDataSource.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 WWQQJRDataSource implements JRDataSource | |
17 { | |
18 /** The logger used in this exporter.*/ | |
19 private static Logger logger = Logger.getLogger(WWQQJRDataSource.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 WWQQJRDataSource() | |
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 ("reference".equals(fieldName)) { | |
83 value = metaData.get("reference"); | |
84 } | |
85 else if ("location".equals(fieldName)) { | |
86 value = metaData.get("location"); | |
87 } | |
88 else if ("km1".equals(fieldName)) { | |
89 value = data.get(index)[0]; | |
90 } | |
91 else if ("location1".equals(fieldName)) { | |
92 value = data.get(index)[1]; | |
93 } | |
94 else if ("W1".equals(fieldName)) { | |
95 value = data.get(index)[2]; | |
96 } | |
97 else if ("Q1".equals(fieldName)) { | |
98 value = data.get(index)[3]; | |
99 } | |
100 else if ("km2".equals(fieldName)) { | |
101 value = data.get(index)[4]; | |
102 } | |
103 else if ("location2".equals(fieldName)) { | |
104 value = data.get(index)[5]; | |
105 } | |
106 else if ("W2".equals(fieldName)) { | |
107 value = data.get(index)[6]; | |
108 } | |
109 else if ("Q2".equals(fieldName)) { | |
110 value = data.get(index)[7]; | |
111 } | |
112 else if ("Wcm1".equals(fieldName)) { | |
113 value = data.get(index)[8]; | |
114 } | |
115 else if ("Wcm2".equals(fieldName)) { | |
116 value = data.get(index)[9]; | |
117 } | |
118 return value; | |
119 } | |
120 } | |
121 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |