1 28 package net.sf.jasperreports.engine.xml; 29 30 import java.util.Set; 31 32 import net.sf.jasperreports.engine.JRVariable; 33 import net.sf.jasperreports.engine.design.JRDesignChartDataset; 34 import net.sf.jasperreports.engine.design.JRDesignGroup; 35 36 import org.xml.sax.Attributes; 37 38 39 43 public class JRChartDatasetFactory extends JRBaseFactory 44 { 45 46 private static final String ATTRIBUTE_resetType = "resetType"; 47 private static final String ATTRIBUTE_resetGroup = "resetGroup"; 48 private static final String ATTRIBUTE_incrementType = "incrementType"; 49 private static final String ATTRIBUTE_incrementGroup = "incrementGroup"; 50 51 52 55 public Object createObject(Attributes atts) 56 { 57 JRXmlLoader xmlLoader = (JRXmlLoader)digester.peek(digester.getCount() - 1); 58 Set groupBoundDatasets = xmlLoader.getGroupBoundDatasets(); 59 60 JRDesignChartDataset dataset = (JRDesignChartDataset) digester.peek(); 61 62 Byte resetType = (Byte)JRXmlConstants.getResetTypeMap().get(atts.getValue(ATTRIBUTE_resetType)); 63 if (resetType != null) 64 { 65 dataset.setResetType(resetType.byteValue()); 66 } 67 if (dataset.getResetType() == JRVariable.RESET_TYPE_GROUP) 68 { 69 groupBoundDatasets.add(dataset); 70 71 String groupName = atts.getValue(ATTRIBUTE_resetGroup); 72 if (groupName != null) 73 { 74 JRDesignGroup group = new JRDesignGroup(); 75 group.setName(groupName); 76 dataset.setResetGroup(group); 77 } 78 } 79 80 Byte incrementType = (Byte)JRXmlConstants.getResetTypeMap().get(atts.getValue(ATTRIBUTE_incrementType)); 81 if (incrementType != null) 82 { 83 dataset.setIncrementType(incrementType.byteValue()); 84 } 85 if (dataset.getIncrementType() == JRVariable.RESET_TYPE_GROUP) 86 { 87 groupBoundDatasets.add(dataset); 88 89 String groupName = atts.getValue(ATTRIBUTE_incrementGroup); 90 if (groupName != null) 91 { 92 JRDesignGroup group = new JRDesignGroup(); 93 group.setName(groupName); 94 dataset.setIncrementGroup(group); 95 } 96 } 97 98 return dataset; 99 } 100 101 } 102 | Popular Tags |