1 3 19 20 package com.sun.org.apache.xml.internal.resolver.readers; 21 22 import java.io.IOException ; 23 24 import org.xml.sax.*; 25 import org.xml.sax.helpers.*; 26 27 38 public class SAXParserHandler extends DefaultHandler { 39 private EntityResolver er = null; 40 private ContentHandler ch = null; 41 42 public SAXParserHandler() { 43 super(); 44 } 45 46 public void setEntityResolver(EntityResolver er) { 47 this.er = er; 48 } 49 50 public void setContentHandler(ContentHandler ch) { 51 this.ch = ch; 52 } 53 54 public InputSource resolveEntity(String publicId, String systemId) 56 throws SAXException { 57 58 if (er != null) { 59 try { 60 return er.resolveEntity(publicId, systemId); 61 } catch (IOException e) { 62 System.out.println("resolveEntity threw IOException!"); 63 return null; 64 } 65 } else { 66 return null; 67 } 68 } 69 70 public void characters(char[] ch, int start, int length) 72 throws SAXException { 73 if (this.ch != null) { 74 this.ch.characters(ch, start, length); 75 } 76 } 77 78 public void endDocument() 79 throws SAXException { 80 if (ch != null) { 81 ch.endDocument(); 82 } 83 } 84 85 public void endElement(String namespaceURI, String localName, String qName) 86 throws SAXException { 87 if (ch != null) { 88 ch.endElement(namespaceURI, localName, qName); 89 } 90 } 91 92 public void endPrefixMapping(String prefix) 93 throws SAXException { 94 if (ch != null) { 95 ch.endPrefixMapping(prefix); 96 } 97 } 98 99 public void ignorableWhitespace(char[] ch, int start, int length) 100 throws SAXException { 101 if (this.ch != null) { 102 this.ch.ignorableWhitespace(ch, start, length); 103 } 104 } 105 106 public void processingInstruction(String target, String data) 107 throws SAXException { 108 if (ch != null) { 109 ch.processingInstruction(target, data); 110 } 111 } 112 113 public void setDocumentLocator(Locator locator) { 114 if (ch != null) { 115 ch.setDocumentLocator(locator); 116 } 117 } 118 119 public void skippedEntity(String name) 120 throws SAXException { 121 if (ch != null) { 122 ch.skippedEntity(name); 123 } 124 } 125 126 public void startDocument() 127 throws SAXException { 128 if (ch != null) { 129 ch.startDocument(); 130 } 131 } 132 133 public void startElement(String namespaceURI, String localName, 134 String qName, Attributes atts) 135 throws SAXException { 136 if (ch != null) { 137 ch.startElement(namespaceURI, localName, qName, atts); 138 } 139 } 140 141 public void startPrefixMapping(String prefix, String uri) 142 throws SAXException { 143 if (ch != null) { 144 ch.startPrefixMapping(prefix, uri); 145 } 146 } 147 } 148 | Popular Tags |