1 28 package net.sf.jasperreports.engine.xml; 29 30 import net.sf.jasperreports.engine.design.JRDesignGroup; 31 import net.sf.jasperreports.engine.design.JRDesignVariable; 32 33 import org.xml.sax.Attributes ; 34 35 36 40 public class JRVariableFactory extends JRBaseFactory 41 { 42 43 44 47 private static final String ATTRIBUTE_name = "name"; 48 private static final String ATTRIBUTE_class = "class"; 49 private static final String ATTRIBUTE_resetType = "resetType"; 50 private static final String ATTRIBUTE_resetGroup = "resetGroup"; 51 private static final String ATTRIBUTE_incrementType = "incrementType"; 52 private static final String ATTRIBUTE_incrementGroup = "incrementGroup"; 53 private static final String ATTRIBUTE_calculation = "calculation"; 54 private static final String ATTRIBUTE_incrementerFactoryClass = "incrementerFactoryClass"; 55 56 57 60 public Object createObject(Attributes atts) 61 { 62 JRDesignVariable variable = new JRDesignVariable(); 63 64 variable.setName(atts.getValue(ATTRIBUTE_name)); 65 66 if (atts.getValue(ATTRIBUTE_class) != null) 67 { 68 variable.setValueClassName(atts.getValue(ATTRIBUTE_class)); 69 } 70 71 Byte resetType = (Byte )JRXmlConstants.getResetTypeMap().get(atts.getValue(ATTRIBUTE_resetType)); 72 if (resetType != null) 73 { 74 variable.setResetType(resetType.byteValue()); 75 } 76 77 String groupName = atts.getValue(ATTRIBUTE_resetGroup); 78 if (groupName != null) 79 { 80 JRDesignGroup group = new JRDesignGroup(); 81 group.setName(groupName); 82 variable.setResetGroup(group); 83 } 84 85 Byte incrementType = (Byte )JRXmlConstants.getResetTypeMap().get(atts.getValue(ATTRIBUTE_incrementType)); 86 if (incrementType != null) 87 { 88 variable.setIncrementType(incrementType.byteValue()); 89 } 90 91 groupName = atts.getValue(ATTRIBUTE_incrementGroup); 92 if (groupName != null) 93 { 94 JRDesignGroup group = new JRDesignGroup(); 95 group.setName(groupName); 96 variable.setIncrementGroup(group); 97 } 98 99 Byte calculation = (Byte )JRXmlConstants.getCalculationMap().get(atts.getValue(ATTRIBUTE_calculation)); 100 if (calculation != null) 101 { 102 variable.setCalculation(calculation.byteValue()); 103 } 104 105 if (atts.getValue(ATTRIBUTE_incrementerFactoryClass) != null) 106 { 107 variable.setIncrementerFactoryClassName(atts.getValue(ATTRIBUTE_incrementerFactoryClass)); 108 } 109 110 return variable; 111 } 112 113 114 } 115 | Popular Tags |