1 43 44 package org.jfree.xml.parser.coretypes; 45 46 import java.awt.RenderingHints ; 47 import java.util.ArrayList ; 48 49 import org.jfree.xml.parser.AbstractXmlReadHandler; 50 import org.jfree.xml.parser.XmlReadHandler; 51 import org.jfree.xml.parser.XmlReaderException; 52 import org.xml.sax.Attributes ; 53 import org.xml.sax.SAXException ; 54 55 58 public class RenderingHintsReadHandler extends AbstractXmlReadHandler { 59 60 61 private ArrayList handlers; 62 63 64 private RenderingHints renderingHints; 65 66 69 public RenderingHintsReadHandler() { 70 super(); 71 } 72 73 80 protected void startParsing(final Attributes attrs) throws SAXException { 81 this.handlers = new ArrayList (); 82 } 83 84 95 protected XmlReadHandler getHandlerForChild(final String tagName, final Attributes atts) 96 throws XmlReaderException, SAXException { 97 98 if (!tagName.equals("entry")) { 99 throw new SAXException ("Expected 'entry' tag."); 100 } 101 102 final XmlReadHandler handler = new RenderingHintValueReadHandler(); 103 this.handlers.add(handler); 104 return handler; 105 } 106 107 113 protected void doneParsing() throws SAXException , XmlReaderException { 114 this.renderingHints = new RenderingHints (null); 115 116 for (int i = 0; i < this.handlers.size(); i++) { 117 final RenderingHintValueReadHandler rh = 118 (RenderingHintValueReadHandler) this.handlers.get(i); 119 this.renderingHints.put(rh.getKey(), rh.getValue()); 120 } 121 } 122 123 130 public Object getObject() throws XmlReaderException { 131 return this.renderingHints; 132 } 133 } 134 | Popular Tags |