1 3 56 57 package org.jboss.util.xml.catalog.readers; 58 59 import java.io.IOException ; 60 61 import org.xml.sax.*; 62 import org.xml.sax.helpers.*; 63 64 75 public class SAXParserHandler extends DefaultHandler { 76 private EntityResolver er = null; 77 private ContentHandler ch = null; 78 79 public SAXParserHandler() { 80 super(); 81 } 82 83 public void setEntityResolver(EntityResolver er) { 84 this.er = er; 85 } 86 87 public void setContentHandler(ContentHandler ch) { 88 this.ch = ch; 89 } 90 91 public InputSource resolveEntity(String publicId, String systemId) 93 throws SAXException { 94 95 if (er != null) { 96 try { 97 return er.resolveEntity(publicId, systemId); 98 } catch (IOException e) { 99 System.out.println("resolveEntity threw IOException!"); 100 return null; 101 } 102 } else { 103 return null; 104 } 105 } 106 107 public void characters(char[] ch, int start, int length) 109 throws SAXException { 110 if (this.ch != null) { 111 this.ch.characters(ch, start, length); 112 } 113 } 114 115 public void endDocument() 116 throws SAXException { 117 if (ch != null) { 118 ch.endDocument(); 119 } 120 } 121 122 public void endElement(String namespaceURI, String localName, String qName) 123 throws SAXException { 124 if (ch != null) { 125 ch.endElement(namespaceURI, localName, qName); 126 } 127 } 128 129 public void endPrefixMapping(String prefix) 130 throws SAXException { 131 if (ch != null) { 132 ch.endPrefixMapping(prefix); 133 } 134 } 135 136 public void ignorableWhitespace(char[] ch, int start, int length) 137 throws SAXException { 138 if (this.ch != null) { 139 this.ch.ignorableWhitespace(ch, start, length); 140 } 141 } 142 143 public void processingInstruction(String target, String data) 144 throws SAXException { 145 if (ch != null) { 146 ch.processingInstruction(target, data); 147 } 148 } 149 150 public void setDocumentLocator(Locator locator) { 151 if (ch != null) { 152 ch.setDocumentLocator(locator); 153 } 154 } 155 156 public void skippedEntity(String name) 157 throws SAXException { 158 if (ch != null) { 159 ch.skippedEntity(name); 160 } 161 } 162 163 public void startDocument() 164 throws SAXException { 165 if (ch != null) { 166 ch.startDocument(); 167 } 168 } 169 170 public void startElement(String namespaceURI, String localName, 171 String qName, Attributes atts) 172 throws SAXException { 173 if (ch != null) { 174 ch.startElement(namespaceURI, localName, qName, atts); 175 } 176 } 177 178 public void startPrefixMapping(String prefix, String uri) 179 throws SAXException { 180 if (ch != null) { 181 ch.startPrefixMapping(prefix, uri); 182 } 183 } 184 } 185 | Popular Tags |