1 28 package net.sf.jasperreports.engine.design; 29 30 import java.io.Serializable ; 31 import java.util.HashMap ; 32 import java.util.Map ; 33 34 import net.sf.jasperreports.crosstabs.JRCrosstab; 35 import net.sf.jasperreports.engine.JRConstants; 36 import net.sf.jasperreports.engine.JRDataset; 37 import net.sf.jasperreports.engine.JRException; 38 39 50 public class JRReportCompileData implements Serializable 51 { 52 private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID; 53 54 57 private Serializable mainDatasetCompileData; 58 59 62 private Map datasetCompileData; 63 64 67 private Map crosstabCompileData; 68 69 70 73 public JRReportCompileData() 74 { 75 datasetCompileData = new HashMap (); 76 crosstabCompileData = new HashMap (); 77 } 78 79 80 85 public void setMainDatasetCompileData(Serializable compileData) 86 { 87 mainDatasetCompileData = compileData; 88 } 89 90 91 97 public void setDatasetCompileData(JRDataset dataset, Serializable compileData) 98 { 99 if (dataset.isMainDataset()) 100 { 101 setMainDatasetCompileData(compileData); 102 } 103 else 104 { 105 datasetCompileData.put(dataset.getName(), compileData); 106 } 107 } 108 109 110 116 public void setCrosstabCompileData(int crosstabId, Serializable compileData) 117 { 118 crosstabCompileData.put(new Integer (crosstabId), compileData); 119 } 120 121 122 127 public Serializable getMainDatasetCompileData() 128 { 129 return mainDatasetCompileData; 130 } 131 132 133 140 public Serializable getDatasetCompileData(JRDataset dataset) throws JRException 141 { 142 Serializable compileData; 143 if (dataset.isMainDataset()) 144 { 145 compileData = getMainDatasetCompileData(); 146 } 147 else 148 { 149 compileData = (Serializable ) datasetCompileData.get(dataset.getName()); 150 if (compileData == null) 151 { 152 throw new JRException("Compile data for dataset " + dataset.getName() + " not found in the report."); 153 } 154 } 155 156 return compileData; 157 } 158 159 160 167 public Serializable getCrosstabCompileData(JRCrosstab crosstab) throws JRException 168 { 169 Serializable compileData = (Serializable ) crosstabCompileData.get(new Integer (crosstab.getId())); 170 if (compileData == null) 171 { 172 throw new JRException("Compile data for crosstab not found in the report."); 173 } 174 175 return compileData; 176 } 177 } 178 | Popular Tags |