1 28 package net.sf.jasperreports.crosstabs.base; 29 30 import java.io.Serializable ; 31 32 import net.sf.jasperreports.crosstabs.JRCrosstabMeasure; 33 import net.sf.jasperreports.engine.JRConstants; 34 import net.sf.jasperreports.engine.JRExpression; 35 import net.sf.jasperreports.engine.JRRuntimeException; 36 import net.sf.jasperreports.engine.JRVariable; 37 import net.sf.jasperreports.engine.base.JRBaseObjectFactory; 38 import net.sf.jasperreports.engine.util.JRClassLoader; 39 40 46 public class JRBaseCrosstabMeasure implements JRCrosstabMeasure, Serializable 47 { 48 private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID; 49 50 protected String name; 51 protected String valueClassName; 52 protected Class valueClass; 53 protected JRExpression expression; 54 protected byte calculation = JRVariable.CALCULATION_COUNT; 55 protected String incrementerFactoryClassName; 56 protected Class incrementerFactoryClass; 57 protected byte percentageOfType = JRCrosstabMeasure.PERCENTAGE_TYPE_NONE; 58 protected String percentageCalculatorClassName; 59 protected Class percentageCalculatorClass; 60 protected JRVariable variable; 61 62 protected JRBaseCrosstabMeasure() 63 { 64 } 65 66 public JRBaseCrosstabMeasure(JRCrosstabMeasure measure, JRBaseObjectFactory factory) 67 { 68 factory.put(measure, this); 69 70 this.name = measure.getName(); 71 this.valueClassName = measure.getValueClassName(); 72 this.expression = factory.getExpression(measure.getValueExpression()); 73 this.calculation = measure.getCalculation(); 74 this.incrementerFactoryClassName = measure.getIncrementerFactoryClassName(); 75 this.percentageOfType = measure.getPercentageOfType(); 76 this.percentageCalculatorClassName = measure.getPercentageCalculatorClassName(); 77 this.variable = factory.getVariable(measure.getVariable()); 78 } 79 80 public String getName() 81 { 82 return name; 83 } 84 85 public String getValueClassName() 86 { 87 return valueClassName; 88 } 89 90 public JRExpression getValueExpression() 91 { 92 return expression; 93 } 94 95 public byte getCalculation() 96 { 97 return calculation; 98 } 99 100 public String getIncrementerFactoryClassName() 101 { 102 return incrementerFactoryClassName; 103 } 104 105 public byte getPercentageOfType() 106 { 107 return percentageOfType; 108 } 109 110 public Class getIncrementerFactoryClass() 111 { 112 if (incrementerFactoryClass == null && incrementerFactoryClassName != null) 113 { 114 try 115 { 116 incrementerFactoryClass = JRClassLoader.loadClassForName(incrementerFactoryClassName); 117 } 118 catch (ClassNotFoundException e) 119 { 120 throw new JRRuntimeException("Could not load measure incrementer class", e); 121 } 122 } 123 124 return incrementerFactoryClass; 125 } 126 127 public Class getValueClass() 128 { 129 if (valueClass == null && valueClassName != null) 130 { 131 try 132 { 133 valueClass = JRClassLoader.loadClassForName(valueClassName); 134 } 135 catch (ClassNotFoundException e) 136 { 137 throw new JRRuntimeException("Could not load bucket value class", e); 138 } 139 } 140 141 return valueClass; 142 } 143 144 public JRVariable getVariable() 145 { 146 return variable; 147 } 148 149 public String getPercentageCalculatorClassName() 150 { 151 return percentageCalculatorClassName; 152 } 153 154 public Class getPercentageCalculatorClass() 155 { 156 if (percentageCalculatorClass == null && percentageCalculatorClassName != null) 157 { 158 try 159 { 160 percentageCalculatorClass = JRClassLoader.loadClassForName(percentageCalculatorClassName); 161 } 162 catch (ClassNotFoundException e) 163 { 164 throw new JRRuntimeException("Could not load measure percentage calculator class", e); 165 } 166 } 167 168 return percentageCalculatorClass; 169 } 170 } 171 | Popular Tags |