1 16 package org.apache.cocoon.xml; 17 18 import org.apache.avalon.excalibur.pool.Recyclable; 19 import org.xml.sax.Attributes ; 20 import org.xml.sax.ContentHandler ; 21 import org.xml.sax.Locator ; 22 import org.xml.sax.SAXException ; 23 import org.xml.sax.ext.LexicalHandler ; 24 25 35 public class ContentHandlerWrapper extends AbstractXMLConsumer implements Recyclable { 36 37 38 protected ContentHandler contentHandler; 39 40 41 protected LexicalHandler lexicalHandler; 42 43 46 public ContentHandlerWrapper() { 47 super(); 48 } 49 50 53 public ContentHandlerWrapper(ContentHandler contentHandler) { 54 this(); 55 this.setContentHandler(contentHandler); 56 } 57 58 61 public ContentHandlerWrapper(ContentHandler contentHandler, 62 LexicalHandler lexicalHandler) { 63 this(); 64 this.setContentHandler(contentHandler); 65 this.setLexicalHandler(lexicalHandler); 66 } 67 68 74 public void setContentHandler(ContentHandler contentHandler) 75 throws IllegalStateException { 76 if (this.contentHandler!=null) throw new IllegalStateException (); 77 this.contentHandler=contentHandler; 78 } 79 80 86 public void setLexicalHandler(LexicalHandler lexicalHandler) 87 throws IllegalStateException { 88 if (this.lexicalHandler!=null) throw new IllegalStateException (); 89 this.lexicalHandler=lexicalHandler; 90 } 91 92 public void recycle () { 93 this.contentHandler = null; 94 this.lexicalHandler = null; 95 } 96 97 100 public void setDocumentLocator (Locator locator) { 101 if (this.contentHandler==null) return; 102 else this.contentHandler.setDocumentLocator(locator); 103 } 104 105 108 public void startDocument () 109 throws SAXException { 110 if (this.contentHandler==null) 111 throw new SAXException ("ContentHandler not set"); 112 this.contentHandler.startDocument(); 113 } 114 115 118 public void endDocument () 119 throws SAXException { 120 this.contentHandler.endDocument(); 121 } 122 123 126 public void startPrefixMapping(String prefix, String uri) 127 throws SAXException { 128 if (this.contentHandler==null) 129 throw new SAXException ("ContentHandler not set"); 130 this.contentHandler.startPrefixMapping(prefix, uri); 131 } 132 133 136 public void endPrefixMapping(String prefix) 137 throws SAXException { 138 this.contentHandler.endPrefixMapping(prefix); 139 } 140 141 144 public void startElement(String uri, String loc, String raw, Attributes a) 145 throws SAXException { 146 this.contentHandler.startElement(uri, loc, raw, a); 147 } 148 149 150 153 public void endElement(String uri, String loc, String raw) 154 throws SAXException { 155 this.contentHandler.endElement(uri, loc, raw); 156 } 157 158 161 public void characters(char ch[], int start, int len) 162 throws SAXException { 163 this.contentHandler.characters(ch,start,len); 164 } 165 166 169 public void ignorableWhitespace(char ch[], int start, int len) 170 throws SAXException { 171 this.contentHandler.ignorableWhitespace(ch,start,len); 172 } 173 174 177 public void processingInstruction(String target, String data) 178 throws SAXException { 179 this.contentHandler.processingInstruction(target,data); 180 } 181 182 188 public void skippedEntity(String name) 189 throws SAXException { 190 this.contentHandler.skippedEntity(name); 191 } 192 193 202 public void startDTD(String name, String publicId, String systemId) 203 throws SAXException { 204 if (this.lexicalHandler != null) 205 this.lexicalHandler.startDTD(name, publicId, systemId); 206 } 207 208 211 public void endDTD() 212 throws SAXException { 213 if (this.lexicalHandler != null) 214 this.lexicalHandler.endDTD(); 215 } 216 217 223 public void startEntity(String name) 224 throws SAXException { 225 if (this.lexicalHandler != null) 226 this.lexicalHandler.startEntity(name); 227 } 228 229 234 public void endEntity(String name) 235 throws SAXException { 236 if (this.lexicalHandler != null) 237 this.lexicalHandler.endEntity(name); 238 } 239 240 243 public void startCDATA() 244 throws SAXException { 245 if (this.lexicalHandler != null) 246 this.lexicalHandler.startCDATA(); 247 } 248 249 252 public void endCDATA() 253 throws SAXException { 254 if (this.lexicalHandler != null) 255 this.lexicalHandler.endCDATA(); 256 } 257 258 259 266 public void comment(char ch[], int start, int len) 267 throws SAXException { 268 if (this.lexicalHandler != null) 269 this.lexicalHandler.comment(ch, start, len); 270 } 271 272 } 273 | Popular Tags |