1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package org.dbforms.servlets.reports;
26
27 import net.sf.jasperreports.engine.JRException;
28 import net.sf.jasperreports.engine.JRField;
29 import net.sf.jasperreports.engine.JRDataSource;
30
31 import org.apache.commons.logging.Log;
32 import org.apache.commons.logging.LogFactory;
33
34 import java.util.Map;
35
36 public abstract class AbstractJRDataSource implements JRDataSource {
37 private static Log logCat = LogFactory.getLog(AbstractJRDataSource.class
38 .getName());
39 private Map attributes;
40
41 AbstractJRDataSource(Map attributes) {
42 this.attributes = attributes;
43 }
44 /***
45 * @see net.sf.jasperreports.engine.JRDataSource#next()
46 */
47 public abstract boolean next() throws JRException;
48
49 /***
50 * @see net.sf.jasperreports.engine.JRDataSource#getFieldValue(net.sf.jasperreports.engine.JRField)
51 * Philip Grunikiewicz 2004-01-13 Because I had fields defined
52 * (dbforms-config.xml) in mix case (ie: creditLimit) and in my XML
53 * file, my field was in uppercase (ie: CREDITLIMIT), my field could
54 * not be found. Added some logging to help out debugging this type of
55 * problem.
56 */
57 public Object getFieldValue(JRField field) throws JRException {
58 String search = field.getName();
59 logCat.debug("Trying to find data for field named: " + search);
60 Object o = getFieldValue(field.getName());
61 if (o == null) {
62 logCat
63 .debug("Field not found in dbforms-config, trying field renamed to uppercase: "
64 + search.toUpperCase());
65 o = getFieldValue(search.toUpperCase());
66 }
67 if (o == null) {
68 logCat
69 .debug("Field not found in dbforms-config, trying field renamed to lowercase: "
70 + search.toLowerCase());
71 o = getFieldValue(field.getName().toLowerCase());
72 }
73
74
75
76
77
78
79
80
81
82 return o;
83 }
84
85 public abstract Object getFieldValue(String fieldName);
86
87 /***
88 * @return Returns the attributes.
89 */
90 public Map getAttributes() {
91 return attributes;
92 }
93 }