1 package com.thaiopensource.xml.sax; 2 3 import org.xml.sax.ContentHandler ; 4 import org.xml.sax.Locator ; 5 import org.xml.sax.SAXException ; 6 import org.xml.sax.Attributes ; 7 8 public class DelegatingContentHandler implements ContentHandler { 9 private ContentHandler delegate; 10 11 public DelegatingContentHandler() { 12 } 13 14 public DelegatingContentHandler(ContentHandler delegate) { 15 this.delegate = delegate; 16 } 17 18 public ContentHandler getDelegate() { 19 return delegate; 20 } 21 22 public void setDelegate(ContentHandler delegate) { 23 this.delegate = delegate; 24 } 25 26 public void setDocumentLocator (Locator locator) { 27 if (delegate != null) 28 delegate.setDocumentLocator(locator); 29 } 30 31 public void startDocument () 32 throws SAXException { 33 if (delegate != null) 34 delegate.startDocument(); 35 } 36 37 public void endDocument() 38 throws SAXException { 39 if (delegate != null) 40 delegate.endDocument(); 41 } 42 43 public void startPrefixMapping (String prefix, String uri) 44 throws SAXException { 45 if (delegate != null) 46 delegate.startPrefixMapping(prefix, uri); 47 } 48 49 public void endPrefixMapping (String prefix) 50 throws SAXException { 51 if (delegate != null) 52 delegate.endPrefixMapping(prefix); 53 } 54 55 public void startElement (String namespaceURI, String localName, 56 String qName, Attributes atts) 57 throws SAXException { 58 if (delegate != null) 59 delegate.startElement(namespaceURI, localName, qName, atts); 60 } 61 62 public void endElement (String namespaceURI, String localName, 63 String qName) 64 throws SAXException { 65 if (delegate != null) 66 delegate.endElement(namespaceURI, localName, qName); 67 } 68 69 public void characters (char ch[], int start, int length) 70 throws SAXException { 71 if (delegate != null) 72 delegate.characters(ch, start, length); 73 } 74 75 public void ignorableWhitespace (char ch[], int start, int length) 76 throws SAXException { 77 if (delegate != null) 78 delegate.ignorableWhitespace(ch, start, length); 79 } 80 81 public void processingInstruction (String target, String data) 82 throws SAXException { 83 if (delegate != null) 84 delegate.processingInstruction(target, data); 85 } 86 87 public void skippedEntity (String name) 88 throws SAXException { 89 if (delegate != null) 90 delegate.skippedEntity(name); 91 } 92 } 93 | Popular Tags |