1 23 24 38 package org.dbforms.servlets.reports; 39 40 import java.util.Iterator ; 41 import java.util.Map ; 42 43 import net.sf.jasperreports.engine.JRException; 44 45 import org.apache.commons.beanutils.PropertyUtils; 46 import org.apache.commons.logging.Log; 47 import org.apache.commons.logging.LogFactory; 48 49 50 51 public final class JRDataSourceIter extends JRDataSourceAbstract { 52 private static Log logCat = LogFactory.getLog(JRDataSourceIter.class 53 .getName()); 54 Object current = null; 55 private Iterator iter; 56 private int rownum = 0; 57 58 64 public JRDataSourceIter(Map attributes, Iterator iter) { 65 super(attributes); 66 this.iter = iter; 67 rownum = 0; 68 } 69 70 73 public boolean next() throws JRException { 74 if (!iter.hasNext()) { 75 return false; 76 } 77 current = iter.next(); 78 rownum++; 79 return true; 80 } 81 82 89 public final Object getFieldValue(String search) { 90 Object obj = null; 91 try { 92 if (current != null) { 93 logCat.debug("calling PropertyUtils.getProperty " + current + " " 95 + search); 96 obj = PropertyUtils.getProperty(current, search); 97 } 98 } catch (Exception e) { 99 logCat.error("getCurrentValue: " + e); 100 } 101 102 return obj; 103 } 104 } 105 | Popular Tags |