1 16 package org.apache.cocoon.xml; 17 18 import org.xml.sax.Attributes ; 19 import org.xml.sax.ContentHandler ; 20 import org.xml.sax.Locator ; 21 import org.xml.sax.SAXException ; 22 import org.xml.sax.ext.LexicalHandler ; 23 24 28 29 public final class XMLMulticaster implements XMLConsumer { 30 31 35 private ContentHandler [] contentHandlerList; 36 private LexicalHandler [] lexicalHandlerList; 37 38 41 public XMLMulticaster(XMLConsumer firstConsumer, XMLConsumer secondConsumer) { 42 this.contentHandlerList = new ContentHandler [] {firstConsumer, secondConsumer}; 43 this.lexicalHandlerList = new LexicalHandler [] {firstConsumer, secondConsumer}; 44 } 45 46 49 public XMLMulticaster(ContentHandler firstContentHandler, 50 LexicalHandler firstLexicalHandler, 51 ContentHandler secondContentHandler, 52 LexicalHandler secondLexicalHandler) { 53 this.contentHandlerList = new ContentHandler [] {firstContentHandler, secondContentHandler}; 54 this.lexicalHandlerList = new LexicalHandler [] {firstLexicalHandler, secondLexicalHandler}; 55 } 56 57 public XMLMulticaster(ContentHandler [] chList, 58 LexicalHandler [] lhList) { 59 this.contentHandlerList = chList; 60 this.lexicalHandlerList = lhList; 61 } 62 63 public void startDocument() throws SAXException { 64 for(int i=0; i<this.contentHandlerList.length; i++) { 65 this.contentHandlerList[i].startDocument(); 66 } 67 } 68 69 public void endDocument() throws SAXException { 70 for(int i=0; i<this.contentHandlerList.length; i++) { 71 this.contentHandlerList[i].endDocument(); 72 } 73 } 74 75 public void startPrefixMapping(java.lang.String prefix, java.lang.String uri) throws SAXException { 76 for(int i=0; i<this.contentHandlerList.length; i++) 77 this.contentHandlerList[i].startPrefixMapping(prefix, uri); 78 } 79 80 public void endPrefixMapping(java.lang.String prefix) throws SAXException { 81 for(int i=0; i<this.contentHandlerList.length; i++) 82 this.contentHandlerList[i].endPrefixMapping(prefix); 83 } 84 85 public void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, Attributes atts) throws SAXException { 86 for(int i=0; i<this.contentHandlerList.length; i++) 87 this.contentHandlerList[i].startElement(namespaceURI, localName, qName, atts); 88 } 89 90 public void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName) throws SAXException { 91 for(int i=0; i<this.contentHandlerList.length; i++) 92 this.contentHandlerList[i].endElement(namespaceURI, localName, qName); 93 } 94 95 public void characters(char[] ch, int start, int length) throws SAXException { 96 for(int i=0; i<this.contentHandlerList.length; i++) 97 this.contentHandlerList[i].characters(ch, start, length); 98 } 99 100 public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { 101 for(int i=0; i<this.contentHandlerList.length; i++) 102 this.contentHandlerList[i].ignorableWhitespace(ch, start, length); 103 } 104 105 public void processingInstruction(java.lang.String target, java.lang.String data) throws SAXException { 106 for(int i=0; i<this.contentHandlerList.length; i++) 107 this.contentHandlerList[i].processingInstruction(target, data); 108 } 109 110 public void setDocumentLocator(Locator locator) { 111 for(int i=0; i<this.contentHandlerList.length; i++) 112 this.contentHandlerList[i].setDocumentLocator(locator); 113 } 114 115 public void skippedEntity(java.lang.String name) throws SAXException { 116 for(int i=0; i<this.contentHandlerList.length; i++) 117 this.contentHandlerList[i].skippedEntity(name); 118 } 119 120 public void startDTD(String name, String public_id, String system_id) 121 throws SAXException { 122 for(int i=0; i<this.lexicalHandlerList.length; i++) 123 if (this.lexicalHandlerList[i] != null) 124 this.lexicalHandlerList[i].startDTD(name, public_id, system_id); 125 } 126 127 public void endDTD() throws SAXException { 128 for(int i=0; i<this.lexicalHandlerList.length; i++) 129 if (this.lexicalHandlerList[i] != null) 130 this.lexicalHandlerList[i].endDTD(); 131 } 132 133 public void startEntity(String name) throws SAXException { 134 for(int i=0; i<this.lexicalHandlerList.length; i++) 135 if (this.lexicalHandlerList[i] != null) 136 this.lexicalHandlerList[i].startEntity(name); 137 } 138 139 public void endEntity(String name) throws SAXException { 140 for(int i=0; i<this.lexicalHandlerList.length; i++) 141 if (this.lexicalHandlerList[i] != null) 142 this.lexicalHandlerList[i].endEntity(name); 143 } 144 145 public void startCDATA() throws SAXException { 146 for(int i=0; i<this.lexicalHandlerList.length; i++) 147 if (this.lexicalHandlerList[i] != null) 148 this.lexicalHandlerList[i].startCDATA(); 149 } 150 151 public void endCDATA() throws SAXException { 152 for(int i=0; i<this.lexicalHandlerList.length; i++) 153 if (this.lexicalHandlerList[i] != null) 154 this.lexicalHandlerList[i].endCDATA(); 155 } 156 157 public void comment(char ary[], int start, int length) 158 throws SAXException { 159 for(int i=0; i<this.lexicalHandlerList.length; i++) 160 if (this.lexicalHandlerList[i] != null) 161 this.lexicalHandlerList[i].comment(ary, start, length); 162 } 163 } 164 | Popular Tags |