1 41 42 package org.jfree.data.xml; 43 44 import org.jfree.data.category.CategoryDataset; 45 import org.jfree.data.category.DefaultCategoryDataset; 46 import org.xml.sax.Attributes ; 47 import org.xml.sax.SAXException ; 48 import org.xml.sax.helpers.DefaultHandler ; 49 50 53 public class CategoryDatasetHandler extends RootHandler implements DatasetTags { 54 55 56 private DefaultCategoryDataset dataset; 57 58 61 public CategoryDatasetHandler() { 62 this.dataset = null; 63 } 64 65 70 public CategoryDataset getDataset() { 71 return this.dataset; 72 } 73 74 81 public void addItem(Comparable rowKey, Comparable columnKey, Number value) { 82 this.dataset.addValue(value, rowKey, columnKey); 83 } 84 85 95 public void startElement(String namespaceURI, 96 String localName, 97 String qName, 98 Attributes atts) throws SAXException { 99 100 DefaultHandler current = getCurrentHandler(); 101 if (current != this) { 102 current.startElement(namespaceURI, localName, qName, atts); 103 } 104 else if (qName.equals(CATEGORYDATASET_TAG)) { 105 this.dataset = new DefaultCategoryDataset(); 106 } 107 else if (qName.equals(SERIES_TAG)) { 108 CategorySeriesHandler subhandler = new CategorySeriesHandler(this); 109 getSubHandlers().push(subhandler); 110 subhandler.startElement(namespaceURI, localName, qName, atts); 111 } 112 else { 113 throw new SAXException ("Element not recognised: " + qName); 114 } 115 116 } 117 118 127 public void endElement(String namespaceURI, 128 String localName, 129 String qName) throws SAXException { 130 131 DefaultHandler current = getCurrentHandler(); 132 if (current != this) { 133 current.endElement(namespaceURI, localName, qName); 134 } 135 136 } 137 138 } 139 | Popular Tags |