1 28 package net.sf.jasperreports.engine.base; 29 30 import java.io.Serializable ; 31 32 import net.sf.jasperreports.engine.JRConstants; 33 import net.sf.jasperreports.engine.JRExpression; 34 import net.sf.jasperreports.engine.JRGroup; 35 import net.sf.jasperreports.engine.JRRuntimeException; 36 import net.sf.jasperreports.engine.JRVariable; 37 import net.sf.jasperreports.engine.util.JRClassLoader; 38 39 40 44 public class JRBaseVariable implements JRVariable, Serializable 45 { 46 47 48 51 private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID; 52 53 56 protected String name = null; 57 protected String valueClassName = java.lang.String .class.getName(); 58 protected String incrementerFactoryClassName = null; 59 protected byte resetType = RESET_TYPE_REPORT; 60 protected byte incrementType = RESET_TYPE_NONE; 61 protected byte calculation = CALCULATION_NOTHING; 62 protected boolean isSystemDefined = false; 63 64 protected transient Class valueClass = null; 65 protected transient Class incrementerFactoryClass = null; 66 67 70 protected JRExpression expression = null; 71 protected JRExpression initialValueExpression = null; 72 protected JRGroup resetGroup = null; 73 protected JRGroup incrementGroup = null; 74 75 76 79 protected JRBaseVariable() 80 { 81 } 82 83 84 87 protected JRBaseVariable(JRVariable variable, JRBaseObjectFactory factory) 88 { 89 factory.put(variable, this); 90 91 name = variable.getName(); 92 valueClassName = variable.getValueClassName(); 93 incrementerFactoryClassName = variable.getIncrementerFactoryClassName(); 94 resetType = variable.getResetType(); 95 incrementType = variable.getIncrementType(); 96 calculation = variable.getCalculation(); 97 isSystemDefined = variable.isSystemDefined(); 98 99 expression = factory.getExpression(variable.getExpression()); 100 initialValueExpression = factory.getExpression(variable.getInitialValueExpression()); 101 102 resetGroup = factory.getGroup(variable.getResetGroup()); 103 incrementGroup = factory.getGroup(variable.getIncrementGroup()); 104 } 105 106 107 110 public String getName() 111 { 112 return this.name; 113 } 114 115 118 public Class getValueClass() 119 { 120 if (valueClass == null) 121 { 122 if (valueClassName != null) 123 { 124 try 125 { 126 valueClass = JRClassLoader.loadClassForName(valueClassName); 127 } 128 catch(ClassNotFoundException e) 129 { 130 throw new JRRuntimeException(e); 131 } 132 } 133 } 134 135 return valueClass; 136 } 137 138 141 public String getValueClassName() 142 { 143 return valueClassName; 144 } 145 146 149 public Class getIncrementerFactoryClass() 150 { 151 if (incrementerFactoryClass == null) 152 { 153 if (incrementerFactoryClassName != null) 154 { 155 try 156 { 157 incrementerFactoryClass = JRClassLoader.loadClassForName(incrementerFactoryClassName); 158 } 159 catch(ClassNotFoundException e) 160 { 161 throw new JRRuntimeException(e); 162 } 163 } 164 } 165 166 return incrementerFactoryClass; 167 } 168 169 172 public String getIncrementerFactoryClassName() 173 { 174 return incrementerFactoryClassName; 175 } 176 177 180 public byte getResetType() 181 { 182 return this.resetType; 183 } 184 185 188 public byte getIncrementType() 189 { 190 return this.incrementType; 191 } 192 193 196 public byte getCalculation() 197 { 198 return this.calculation; 199 } 200 201 204 public boolean isSystemDefined() 205 { 206 return this.isSystemDefined; 207 } 208 209 212 public JRExpression getExpression() 213 { 214 return this.expression; 215 } 216 217 220 public JRExpression getInitialValueExpression() 221 { 222 return this.initialValueExpression; 223 } 224 225 228 public JRGroup getResetGroup() 229 { 230 return this.resetGroup; 231 } 232 233 236 public JRGroup getIncrementGroup() 237 { 238 return this.incrementGroup; 239 } 240 241 242 } 243 | Popular Tags |