001    package com.thaiopensource.xml.sax;
002    
003    import org.xml.sax.Locator;
004    import org.xml.sax.SAXException;
005    import org.xml.sax.Attributes;
006    import org.xml.sax.ContentHandler;
007    
008    public class ForkContentHandler implements ContentHandler {
009      private final ContentHandler ch1;
010      private final ContentHandler ch2;
011    
012      public ForkContentHandler(ContentHandler ch1, ContentHandler ch2) {
013        this.ch1 = ch1;
014        this.ch2 = ch2;
015      }
016    
017      public void setDocumentLocator(Locator locator) {
018         ch1.setDocumentLocator(locator);
019         ch2.setDocumentLocator(locator);
020       }
021    
022       public void startDocument() throws SAXException {
023         ch1.startDocument();
024         ch2.startDocument();
025       }
026    
027       public void endDocument() throws SAXException {
028         ch1.endDocument();
029         ch2.endDocument();
030       }
031    
032       public void startPrefixMapping(String s, String s1) throws SAXException {
033         ch1.startPrefixMapping(s, s1);
034         ch2.startPrefixMapping(s, s1);
035       }
036    
037       public void endPrefixMapping(String s) throws SAXException {
038         ch1.endPrefixMapping(s);
039         ch2.endPrefixMapping(s);
040       }
041    
042       public void startElement(String s, String s1, String s2, Attributes attributes) throws SAXException {
043         ch1.startElement(s, s1, s2, attributes);
044         ch2.startElement(s, s1, s2, attributes);
045       }
046    
047       public void endElement(String s, String s1, String s2) throws SAXException {
048         ch1.endElement(s, s1, s2);
049         ch2.endElement(s, s1, s2);
050       }
051    
052       public void characters(char[] chars, int i, int i1) throws SAXException {
053         ch1.characters(chars, i, i1);
054         ch2.characters(chars, i, i1);
055       }
056    
057       public void ignorableWhitespace(char[] chars, int i, int i1) throws SAXException {
058         ch1.ignorableWhitespace(chars, i, i1);
059         ch2.ignorableWhitespace(chars, i, i1);
060       }
061    
062       public void processingInstruction(String s, String s1) throws SAXException {
063         ch1.processingInstruction(s, s1);
064         ch2.processingInstruction(s, s1);
065       }
066    
067       public void skippedEntity(String s) throws SAXException {
068         ch1.skippedEntity(s);
069         ch2.skippedEntity(s);
070       }
071    }