1 17 package org.eclipse.emf.ecore.xmi.impl; 18 19 20 import org.xml.sax.Attributes ; 21 import org.xml.sax.InputSource ; 22 import org.xml.sax.Locator ; 23 import org.xml.sax.SAXException ; 24 import org.xml.sax.SAXParseException ; 25 import org.xml.sax.ext.LexicalHandler ; 26 import org.xml.sax.helpers.DefaultHandler ; 27 28 import org.eclipse.emf.ecore.xmi.XMIException; 29 30 31 34 public class SAXWrapper extends DefaultHandler implements LexicalHandler 35 { 36 protected XMLHandler handler; 37 38 41 public SAXWrapper(XMLHandler handler) 42 { 43 super(); 44 this.handler = handler; 45 } 46 47 public void setDocumentLocator(Locator locator) 48 { 49 handler.setLocator(locator); 50 } 51 52 public void startDocument() throws SAXException 53 { 54 handler.startDocument(); 55 } 56 57 public void endDocument() throws SAXException 58 { 59 handler.endDocument(); 60 } 61 62 public void startPrefixMapping(String prefix, String uri) throws SAXException 63 { 64 } 65 66 public void endPrefixMapping(String prefix) throws SAXException 67 { 68 } 69 70 public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException 71 { 72 handler.setAttributes(attributes); 73 handler.startElement(uri, localName, qName); 74 } 75 76 public void endElement (String uri, String localName, String qName) throws SAXException 77 { 78 handler.endElement(uri, localName, qName); 79 } 80 81 public void warning (SAXParseException e) throws SAXException 82 { 83 XMIException xmi = new XMIException(e.getException() == null ? e : e.getException(), e.getSystemId(), e.getLineNumber(), e.getColumnNumber()); 84 handler.warning(xmi); 85 } 86 87 public void error (SAXParseException e) throws SAXException 88 { 89 XMIException xmi = new XMIException(e.getException() == null ? e : e.getException(), e.getSystemId(), e.getLineNumber(), e.getColumnNumber()); 90 handler.error(xmi); 91 } 92 93 public void fatalError (SAXParseException e) throws SAXException 94 { 95 XMIException xmi = new XMIException(e.getException() == null ? e : e.getException(), e.getSystemId(), e.getLineNumber(), e.getColumnNumber()); 96 handler.fatalError(xmi); 97 throw e; 98 } 99 100 public void characters (char ch[], int start, int length) throws SAXException 101 { 102 handler.characters(ch, start, length); 103 } 104 105 public void ignorableWhitespace (char ch[], int start, int length) throws SAXException 106 { 107 } 109 110 public void processingInstruction (String target, String data) throws SAXException 111 { 112 handler.processingInstruction(target, data); 113 } 114 115 public void skippedEntity (String name) throws SAXException 116 { 117 } 119 120 public InputSource resolveEntity(String publicId, String systemId) throws SAXException 121 { 122 return null; 124 } 125 126 public void notationDecl(String name, String publicId, String systemId) throws SAXException 127 { 128 } 130 131 public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName) throws SAXException 132 { 133 } 135 136 public void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId) 137 { 138 handler.startDTD(name, publicId, systemId); 139 } 140 141 public void endDTD() 142 { 143 } 144 145 public void startEntity(java.lang.String name) 146 { 147 } 148 149 public void endEntity(java.lang.String name) 150 { 151 } 152 153 public void startCDATA() 154 { 155 handler.startCDATA(); 156 } 157 158 public void endCDATA() 159 { 160 handler.endCDATA(); 161 } 162 163 public void comment(char [] characters, int start, int length) throws SAXException 164 { 165 handler.comment(characters, start, length); 166 } 167 } 168 | Popular Tags |