1 41 42 package org.jfree.data.xml; 43 44 import org.jfree.data.general.DefaultPieDataset; 45 import org.jfree.data.general.PieDataset; 46 import org.xml.sax.Attributes ; 47 import org.xml.sax.SAXException ; 48 import org.xml.sax.helpers.DefaultHandler ; 49 50 53 public class PieDatasetHandler extends RootHandler implements DatasetTags { 54 55 56 private DefaultPieDataset dataset; 57 58 61 public PieDatasetHandler() { 62 this.dataset = null; 63 } 64 65 70 public PieDataset getDataset() { 71 return this.dataset; 72 } 73 74 80 public void addItem(Comparable key, Number value) { 81 this.dataset.setValue(key, value); 82 } 83 84 94 public void startElement(String namespaceURI, 95 String localName, 96 String qName, 97 Attributes atts) throws SAXException { 98 99 DefaultHandler current = getCurrentHandler(); 100 if (current != this) { 101 current.startElement(namespaceURI, localName, qName, atts); 102 } 103 else if (qName.equals(PIEDATASET_TAG)) { 104 this.dataset = new DefaultPieDataset(); 105 } 106 else if (qName.equals(ITEM_TAG)) { 107 ItemHandler subhandler = new ItemHandler(this, this); 108 getSubHandlers().push(subhandler); 109 subhandler.startElement(namespaceURI, localName, qName, atts); 110 } 111 112 } 113 114 123 public void endElement(String namespaceURI, 124 String localName, 125 String qName) throws SAXException { 126 127 DefaultHandler current = getCurrentHandler(); 128 if (current != this) { 129 current.endElement(namespaceURI, localName, qName); 130 } 131 132 } 133 134 } 135 | Popular Tags |