1 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 JRDataSourceAbstract implements JRDataSource { 37 private static Log logCat = LogFactory.getLog(JRDataSourceAbstract.class 38 .getName()); 39 private Map attributes; 40 41 JRDataSourceAbstract(Map attributes) { 42 this.attributes = attributes; 43 } 44 47 public abstract boolean next() throws JRException; 48 49 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 82 return o; 83 } 84 85 public abstract Object getFieldValue(String fieldName); 86 87 90 public Map getAttributes() { 91 return attributes; 92 } 93 } 94 | Popular Tags |