001 package com.thaiopensource.xml.sax; 002 003 import org.xml.sax.ContentHandler; 004 import org.xml.sax.Locator; 005 import org.xml.sax.SAXException; 006 import org.xml.sax.Attributes; 007 008 public class DelegatingContentHandler implements ContentHandler { 009 private ContentHandler delegate; 010 011 public DelegatingContentHandler() { 012 } 013 014 public DelegatingContentHandler(ContentHandler delegate) { 015 this.delegate = delegate; 016 } 017 018 public ContentHandler getDelegate() { 019 return delegate; 020 } 021 022 public void setDelegate(ContentHandler delegate) { 023 this.delegate = delegate; 024 } 025 026 public void setDocumentLocator (Locator locator) { 027 if (delegate != null) 028 delegate.setDocumentLocator(locator); 029 } 030 031 public void startDocument () 032 throws SAXException { 033 if (delegate != null) 034 delegate.startDocument(); 035 } 036 037 public void endDocument() 038 throws SAXException { 039 if (delegate != null) 040 delegate.endDocument(); 041 } 042 043 public void startPrefixMapping (String prefix, String uri) 044 throws SAXException { 045 if (delegate != null) 046 delegate.startPrefixMapping(prefix, uri); 047 } 048 049 public void endPrefixMapping (String prefix) 050 throws SAXException { 051 if (delegate != null) 052 delegate.endPrefixMapping(prefix); 053 } 054 055 public void startElement (String namespaceURI, String localName, 056 String qName, Attributes atts) 057 throws SAXException { 058 if (delegate != null) 059 delegate.startElement(namespaceURI, localName, qName, atts); 060 } 061 062 public void endElement (String namespaceURI, String localName, 063 String qName) 064 throws SAXException { 065 if (delegate != null) 066 delegate.endElement(namespaceURI, localName, qName); 067 } 068 069 public void characters (char ch[], int start, int length) 070 throws SAXException { 071 if (delegate != null) 072 delegate.characters(ch, start, length); 073 } 074 075 public void ignorableWhitespace (char ch[], int start, int length) 076 throws SAXException { 077 if (delegate != null) 078 delegate.ignorableWhitespace(ch, start, length); 079 } 080 081 public void processingInstruction (String target, String data) 082 throws SAXException { 083 if (delegate != null) 084 delegate.processingInstruction(target, data); 085 } 086 087 public void skippedEntity (String name) 088 throws SAXException { 089 if (delegate != null) 090 delegate.skippedEntity(name); 091 } 092 }