1 28 package net.sf.jasperreports.engine.fill; 29 30 import java.sql.Connection ; 31 import java.util.Map ; 32 33 import net.sf.jasperreports.engine.JRDataSource; 34 import net.sf.jasperreports.engine.JRException; 35 import net.sf.jasperreports.engine.JRReport; 36 import net.sf.jasperreports.engine.JasperPrint; 37 import net.sf.jasperreports.engine.JasperReport; 38 39 40 44 public abstract class JRFiller 45 { 46 47 48 51 public static JasperPrint fillReport( 52 JasperReport jasperReport, 53 Map parameters, 54 Connection conn 55 ) throws JRException 56 { 57 JRBaseFiller filler = createFiller(jasperReport); 58 59 JasperPrint jasperPrint = null; 60 61 try 62 { 63 jasperPrint = filler.fill(parameters, conn); 64 } 65 catch(JRFillInterruptedException e) 66 { 67 throw new JRException("The report filling thread was interrupted."); 68 } 69 70 return jasperPrint; 71 } 72 73 74 77 public static JasperPrint fillReport( 78 JasperReport jasperReport, 79 Map parameters, 80 JRDataSource dataSource 81 ) throws JRException 82 { 83 JRBaseFiller filler = createFiller(jasperReport); 84 85 JasperPrint jasperPrint = null; 86 87 try 88 { 89 jasperPrint = filler.fill(parameters, dataSource); 90 } 91 catch(JRFillInterruptedException e) 92 { 93 throw new JRException("The report filling thread was interrupted."); 94 } 95 96 return jasperPrint; 97 } 98 99 100 117 public static JasperPrint fillReport(JasperReport jasperReport, Map parameters) throws JRException 118 { 119 JRBaseFiller filler = createFiller(jasperReport); 120 121 try 122 { 123 JasperPrint jasperPrint = filler.fill(parameters); 124 125 return jasperPrint; 126 } 127 catch (JRFillInterruptedException e) 128 { 129 throw new JRException("The report filling thread was interrupted."); 130 } 131 } 132 133 134 public static JRBaseFiller createFiller(JasperReport jasperReport) throws JRException 135 { 136 JRBaseFiller filler = null; 137 138 switch (jasperReport.getPrintOrder()) 139 { 140 case JRReport.PRINT_ORDER_HORIZONTAL : 141 { 142 filler = new JRHorizontalFiller(jasperReport); 143 break; 144 } 145 case JRReport.PRINT_ORDER_VERTICAL : 146 { 147 filler = new JRVerticalFiller(jasperReport); 148 break; 149 } 150 } 151 return filler; 152 } 153 } 154 | Popular Tags |