1 17 18 19 20 package embedding.tools; 21 22 import org.xml.sax.ContentHandler ; 24 import org.xml.sax.Locator ; 25 import org.xml.sax.Attributes ; 26 import org.xml.sax.SAXException ; 27 import org.xml.sax.helpers.AttributesImpl ; 28 29 36 37 public class EasyGenerationContentHandlerProxy implements ContentHandler { 38 39 40 public static final Attributes EMPTY_ATTS = new AttributesImpl (); 41 42 private ContentHandler target; 43 44 45 49 public EasyGenerationContentHandlerProxy(ContentHandler forwardTo) { 50 this.target = forwardTo; 51 } 52 53 54 59 public void startElement(String name) throws SAXException { 60 startElement(name, EMPTY_ATTS); 61 } 62 63 64 71 public void startElement(String name, Attributes atts) throws SAXException { 72 startElement(null, name, name, atts); 73 } 74 75 76 81 public void characters(String s) throws SAXException { 82 target.characters(s.toCharArray(), 0, s.length()); 83 } 84 85 86 91 public void endElement(String name) throws SAXException { 92 endElement(null, name, name); 93 } 94 95 96 102 public void element(String name, String value) throws SAXException { 103 element(name, value, EMPTY_ATTS); 104 } 105 106 107 115 public void element(String name, String value, Attributes atts) throws SAXException { 116 startElement(name, atts); 117 if (value != null) { 118 characters(value.toCharArray(), 0, value.length()); 119 } 120 endElement(name); 121 } 122 123 124 125 128 public void setDocumentLocator(Locator locator) { 129 target.setDocumentLocator(locator); 130 } 131 132 133 136 public void startDocument() throws SAXException { 137 target.startDocument(); 138 } 139 140 141 144 public void endDocument() throws SAXException { 145 target.endDocument(); 146 } 147 148 149 152 public void startPrefixMapping(String prefix, String uri) throws SAXException { 153 target.startPrefixMapping(prefix, uri); 154 } 155 156 157 160 public void endPrefixMapping(String prefix) throws SAXException { 161 target.endPrefixMapping(prefix); 162 } 163 164 165 168 public void startElement(String namespaceURI, String localName, 169 String qName, Attributes atts) throws SAXException { 170 target.startElement(namespaceURI, localName, qName, atts); 171 } 172 173 174 177 public void endElement(String namespaceURI, String localName, String qName) 178 throws SAXException { 179 target.endElement(namespaceURI, localName, qName); 180 } 181 182 183 186 public void characters(char[] ch, int start, int length) throws SAXException { 187 target.characters(ch, start, length); 188 } 189 190 191 194 public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { 195 target.ignorableWhitespace(ch, start, length); 196 } 197 198 199 202 public void processingInstruction(String target, String data) throws SAXException { 203 this.target.processingInstruction(target, data); 204 } 205 206 207 210 public void skippedEntity(String name) throws SAXException { 211 target.skippedEntity(name); 212 } 213 214 } | Popular Tags |