1 19 20 28 29 package org.netbeans.modules.xml.schema.completion; 30 31 import java.io.IOException ; 32 import java.io.InputStream ; 33 import java.net.MalformedURLException ; 34 import java.net.URI ; 35 import java.net.URL ; 36 import javax.swing.text.BadLocationException ; 37 import javax.swing.text.Document ; 38 import org.netbeans.api.xml.services.UserCatalog; 39 import org.netbeans.modules.xml.xam.ModelSource; 40 import org.netbeans.modules.xml.xam.dom.AbstractDocumentModel; 41 import org.netbeans.modules.xml.xam.locator.CatalogModel; 42 import org.netbeans.modules.xml.xam.locator.CatalogModelException; 43 import org.openide.util.lookup.Lookups; 44 import org.w3c.dom.ls.LSInput ; 45 import org.xml.sax.InputSource ; 46 import org.xml.sax.SAXException ; 47 48 52 public class RuntimeCatalogModel implements CatalogModel{ 53 54 55 public RuntimeCatalogModel() { 56 } 57 58 public ModelSource getModelSource(URI locationURI) throws CatalogModelException { 59 throw new RuntimeException ("Method not implemented"); } 61 62 public ModelSource getModelSource(URI locationURI, 63 ModelSource modelSourceOfSourceDocument) throws CatalogModelException { 64 InputSource isrc; 65 try { 66 isrc = UserCatalog.getDefault().getEntityResolver(). 67 resolveEntity(null, locationURI.toString()); 68 InputStream is = new URL (isrc.getSystemId()).openStream(); 69 if(is != null) 70 return createModelSource(is); 71 } catch (Exception ex) { 72 throw new CatalogModelException(ex); 73 } 74 75 return null; 76 } 77 78 private ModelSource createModelSource(InputStream is) throws CatalogModelException{ 79 try { 80 Document d = AbstractDocumentModel.getAccessProvider().loadSwingDocument(is); 81 if(d != null) 82 return new ModelSource(Lookups.fixed(new Object []{this,d}), false); 83 } catch (Exception ex) { 84 throw new CatalogModelException(ex); 85 } 86 87 return null; 88 } 89 90 public InputSource resolveEntity(String publicId, 91 String systemId) throws SAXException , IOException { 92 throw new RuntimeException ("Method not implemented"); } 94 95 public LSInput resolveResource(String type, String namespaceURI, 96 String publicId, String systemId, String baseURI) { 97 throw new RuntimeException ("Method not implemented"); } 99 100 } 101 | Popular Tags |