1 package org.mr.core.util.xml.sax; 2 3 import org.xml.sax.*; 4 import org.xml.sax.ext.DeclHandler ; 5 import org.xml.sax.ext.LexicalHandler ; 6 7 import java.io.IOException ; 8 import java.io.Serializable ; 9 import java.util.ArrayList ; 10 import java.util.Iterator ; 11 12 57 58 65 public class MultiplexerContentHandler implements EntityResolver, ContentHandler, DTDHandler, ErrorHandler, LexicalHandler , DeclHandler , Serializable { 66 private ArrayList m_handlers = new ArrayList (); 67 68 public MultiplexerContentHandler add(ContentHandler i_handler) { 69 m_handlers.add(org.mr.core.util.xml.sax.FilterContentHandler.ensureFullHandler(i_handler)); 70 return this; 71 } 72 73 public void setDocumentLocator(Locator i_locator) { 74 Iterator iter = m_handlers.iterator(); 75 while (iter.hasNext()) { 76 ((ContentHandler) iter.next()).setDocumentLocator(i_locator); 77 } 78 } 79 80 public void startDocument() throws SAXException { 81 Iterator iter = m_handlers.iterator(); 82 while (iter.hasNext()) { 83 ((ContentHandler) iter.next()).startDocument(); 84 } 85 } 86 87 public void endDocument() throws SAXException { 88 Iterator iter = m_handlers.iterator(); 89 while (iter.hasNext()) { 90 ((ContentHandler) iter.next()).endDocument(); 91 } 92 } 93 94 public void startPrefixMapping(String s, String s1) throws SAXException { 95 Iterator iter = m_handlers.iterator(); 96 while (iter.hasNext()) { 97 ((ContentHandler) iter.next()).startPrefixMapping(s, s1); 98 } 99 } 100 101 public void endPrefixMapping(String s) throws SAXException { 102 Iterator iter = m_handlers.iterator(); 103 while (iter.hasNext()) { 104 ((ContentHandler) iter.next()).endPrefixMapping(s); 105 } 106 } 107 108 public void startElement(String s, String s1, String s2, Attributes i_attributes) throws SAXException { 109 Iterator iter = m_handlers.iterator(); 110 while (iter.hasNext()) { 111 ((ContentHandler) iter.next()).startElement(s, s1, s2, i_attributes); 112 } 113 } 114 115 public void endElement(String s, String s1, String s2) throws SAXException { 116 Iterator iter = m_handlers.iterator(); 117 while (iter.hasNext()) { 118 ((ContentHandler) iter.next()).endElement(s, s1, s2); 119 } 120 } 121 122 public void characters(char[] i_chars, int i, int i1) throws SAXException { 123 Iterator iter = m_handlers.iterator(); 124 while (iter.hasNext()) { 125 ((ContentHandler) iter.next()).characters(i_chars, i, i1); 126 } 127 } 128 129 public void ignorableWhitespace(char[] i_chars, int i, int i1) throws SAXException { 130 Iterator iter = m_handlers.iterator(); 131 while (iter.hasNext()) { 132 ((ContentHandler) iter.next()).ignorableWhitespace(i_chars, i, i1); 133 } 134 } 135 136 public void processingInstruction(String s, String s1) throws SAXException { 137 Iterator iter = m_handlers.iterator(); 138 while (iter.hasNext()) { 139 ((ContentHandler) iter.next()).processingInstruction(s, s1); 140 } 141 } 142 143 public void skippedEntity(String s) throws SAXException { 144 Iterator iter = m_handlers.iterator(); 145 while (iter.hasNext()) { 146 ((ContentHandler) iter.next()).skippedEntity(s); 147 } 148 } 149 150 public InputSource resolveEntity(String s, String s1) throws SAXException, IOException { 151 Iterator iter = m_handlers.iterator(); 152 InputSource source = null; 153 while (iter.hasNext() && source == null) { 154 source = ((EntityResolver) iter.next()).resolveEntity(s, s1); 155 } 156 return source; 157 } 158 159 public void notationDecl(String s, String s1, String s2) throws SAXException { 160 Iterator iter = m_handlers.iterator(); 161 while (iter.hasNext()) { 162 ((DTDHandler) iter.next()).notationDecl(s, s1, s2); 163 } 164 } 165 166 public void unparsedEntityDecl(String s, String s1, String s2, String s3) throws SAXException { 167 Iterator iter = m_handlers.iterator(); 168 while (iter.hasNext()) { 169 ((DTDHandler) iter.next()).unparsedEntityDecl(s, s1, s2, s3); 170 } 171 } 172 173 public void error(SAXParseException e) throws SAXException { 174 Iterator iter = m_handlers.iterator(); 175 while (iter.hasNext()) { 176 ((ErrorHandler) iter.next()).error(e); 177 } 178 } 179 180 public void fatalError(SAXParseException e) throws SAXException { 181 Iterator iter = m_handlers.iterator(); 182 while (iter.hasNext()) { 183 ((ErrorHandler) iter.next()).fatalError(e); 184 } 185 } 186 187 public void warning(SAXParseException e) throws SAXException { 188 Iterator iter = m_handlers.iterator(); 189 while (iter.hasNext()) { 190 ((ErrorHandler) iter.next()).warning(e); 191 } 192 } 193 194 public void startDTD(String s, String s1, String s2) throws SAXException { 195 Iterator iter = m_handlers.iterator(); 196 while (iter.hasNext()) { 197 ((LexicalHandler ) iter.next()).startDTD(s, s1, s2); 198 } 199 } 200 201 public void endDTD() throws SAXException { 202 Iterator iter = m_handlers.iterator(); 203 while (iter.hasNext()) { 204 ((LexicalHandler ) iter.next()).endDTD(); 205 } 206 } 207 208 public void startEntity(String s) throws SAXException { 209 Iterator iter = m_handlers.iterator(); 210 while (iter.hasNext()) { 211 ((LexicalHandler ) iter.next()).startEntity(s); 212 } 213 } 214 215 public void endEntity(String s) throws SAXException { 216 Iterator iter = m_handlers.iterator(); 217 while (iter.hasNext()) { 218 ((LexicalHandler ) iter.next()).endEntity(s); 219 } 220 } 221 222 public void startCDATA() throws SAXException { 223 Iterator iter = m_handlers.iterator(); 224 while (iter.hasNext()) { 225 ((LexicalHandler ) iter.next()).startCDATA(); 226 } 227 } 228 229 public void endCDATA() throws SAXException { 230 Iterator iter = m_handlers.iterator(); 231 while (iter.hasNext()) { 232 ((LexicalHandler ) iter.next()).endCDATA(); 233 } 234 } 235 236 public void comment(char[] i_chars, int i, int i1) throws SAXException { 237 Iterator iter = m_handlers.iterator(); 238 while (iter.hasNext()) { 239 ((LexicalHandler ) iter.next()).comment(i_chars, i, i1); 240 } 241 } 242 243 public void elementDecl(String s, String s1) throws SAXException { 244 Iterator iter = m_handlers.iterator(); 245 while (iter.hasNext()) { 246 ((DeclHandler ) iter.next()).elementDecl(s, s1); 247 } 248 } 249 250 public void attributeDecl(String s, String s1, String s2, String s3, String s4) throws SAXException { 251 Iterator iter = m_handlers.iterator(); 252 while (iter.hasNext()) { 253 ((DeclHandler ) iter.next()).attributeDecl(s, s1, s2, s3, s4); 254 } 255 } 256 257 public void internalEntityDecl(String s, String s1) throws SAXException { 258 Iterator iter = m_handlers.iterator(); 259 while (iter.hasNext()) { 260 ((DeclHandler ) iter.next()).internalEntityDecl(s, s1); 261 } 262 } 263 264 public void externalEntityDecl(String s, String s1, String s2) throws SAXException { 265 Iterator iter = m_handlers.iterator(); 266 while (iter.hasNext()) { 267 ((DeclHandler ) iter.next()).externalEntityDecl(s, s1, s2); 268 } 269 } 270 } 271 | Popular Tags |