1 32 33 package it.businesslogic.ireport; 34 import net.sf.jasperreports.engine.JRException; 35 import net.sf.jasperreports.engine.JRScriptletException; 36 37 import java.util.*; 38 42 public class IReportScriptlet extends net.sf.jasperreports.engine.JRAbstractScriptlet 43 { 44 HashMap series = new java.util.HashMap (); 46 HashMap groupStarted = new java.util.HashMap (); 47 48 51 public void beforeReportInit() throws JRScriptletException 52 { 53 } 54 55 56 59 public void afterReportInit() throws JRScriptletException 60 { 61 62 } 63 64 65 68 public void beforePageInit() throws JRScriptletException 69 { 70 71 } 72 73 74 77 public void afterPageInit() throws JRScriptletException 78 { 79 } 80 81 82 85 public void beforeColumnInit() throws JRScriptletException 86 { 87 } 88 89 90 93 public void afterColumnInit() throws JRScriptletException 94 { 95 } 96 97 98 101 public void beforeGroupInit(String groupName) throws JRScriptletException 102 { 103 104 } 105 106 107 110 public void afterGroupInit(String groupName) throws JRScriptletException 111 { 112 resetSeries(groupName); 113 } 114 115 116 119 public void beforeDetailEval() throws JRScriptletException 120 { 121 } 122 123 124 127 public void afterDetailEval() throws JRScriptletException 128 { 129 processSeries(); 130 } 131 132 protected void processSeries() 133 { 134 Set vars = variablesMap.keySet(); 136 Iterator iter = vars.iterator(); 137 while( iter.hasNext()) 138 { 139 String key = (String )iter.next(); 140 if (key.startsWith("SERIE_")) 141 { 142 Vector serie = (Vector)series.get(key); 143 if (serie == null) 144 { 145 serie = new Vector(); 146 series.put(key,serie); 147 } 148 try { 149 serie.add( getVariableValue(key) ); 150 } catch (Exception ex) {} 151 } 152 } 153 } 154 155 protected void resetSeries(String group) 156 { 157 Set vars = variablesMap.keySet(); 159 Iterator iter = vars.iterator(); 160 while( iter.hasNext()) 161 { 162 String key = (String )iter.next(); 163 if (key.startsWith("SERIE_") && key.indexOf("G_" + group)> 0) 164 { 165 series.remove(key); 166 } 167 } 168 } 169 170 public String getSerieAsString(String name) 171 { 172 Vector v = (Vector)series.get(name); 173 Enumeration enum_v = v.elements(); 174 String tot = ""; 175 while (enum_v.hasMoreElements()) 176 { 177 String s = ""+enum_v.nextElement(); 178 tot += s + "\n"; 179 } 180 181 return tot; 182 } 183 184 public Vector getSerie(String serieName) 185 { 186 187 Vector v = (Vector)series.get(serieName); 188 if (v==null) 189 { 190 v = new Vector(); 191 series.put(serieName, v); 192 193 } 194 195 return v; 196 } 197 198 199 public Boolean addValueToSerie(String serieName, Object value) 200 { 201 Vector v = getSerie(serieName); 202 v.add( value ); 203 return new Boolean (false); 204 } 205 206 public Boolean resetSerie(String serieName) 207 { 208 series.remove(serieName); 209 return new Boolean (false); 210 } 211 } 212 | Popular Tags |