1 19 package org.netbeans.lib.jmi.xmi; 20 21 import java.io.IOException ; 22 import java.io.InputStream ; 23 import java.net.MalformedURLException ; 24 import java.net.URL ; 25 import java.util.Collection ; 26 import javax.jmi.reflect.RefPackage; 27 import javax.jmi.xmi.MalformedXMIException; 28 import javax.jmi.xmi.XmiReader; 29 import javax.xml.parsers.ParserConfigurationException ; 30 import org.netbeans.lib.jmi.util.Logger; 31 import org.xml.sax.SAXException ; 32 33 public class XMISaxReaderImpl implements XmiReader { 34 35 36 public XMISaxReaderImpl () { 37 } 38 39 public Collection read (InputStream stream, String uri, RefPackage extent) throws IOException , MalformedXMIException { 40 try { 42 return new XmiSAXReader ().read (stream, uri, new RefPackage[] {extent}, null); 44 } catch (ParserConfigurationException e) { 45 MalformedXMIException ne = new MalformedXMIException(e.getMessage()); 46 Logger.getDefault().annotate(ne, e); 47 throw ne; 48 } catch (SAXException e) { 49 MalformedXMIException ne = new MalformedXMIException(e.getMessage()); 50 Logger.getDefault().annotate(ne, e); 51 throw ne; 52 } 53 } 54 55 public Collection read (String uri, RefPackage extent) 56 throws IOException , MalformedXMIException { 57 return read (new URL (uri), new RefPackage[] {extent}, null); 58 } 59 60 private Collection read (URL url, RefPackage[] extents, String encoding) 61 throws IOException , MalformedXMIException { 62 try { 64 return new XmiSAXReader ().read (url, extents, encoding); 65 } catch (ParserConfigurationException e) { 66 MalformedXMIException ne = new MalformedXMIException(e.toString()); 67 Logger.getDefault().annotate(ne, e); 68 throw ne; 69 } catch (SAXException e) { 70 MalformedXMIException ne = new MalformedXMIException(e.toString()); 71 Logger.getDefault().annotate(ne, e); 72 throw ne; 73 } 74 } 75 76 } 77 | Popular Tags |