1 19 20 21 package org.netbeans.modules.j2ee.persistence.unit; 22 23 import java.awt.Image ; 24 import java.beans.PropertyChangeListener ; 25 import java.io.IOException ; 26 import java.util.ArrayList ; 27 import java.util.Iterator ; 28 import java.util.List ; 29 import org.netbeans.modules.xml.catalog.spi.CatalogDescriptor; 30 import org.netbeans.modules.xml.catalog.spi.CatalogListener; 31 import org.netbeans.modules.xml.catalog.spi.CatalogReader; 32 import org.xml.sax.InputSource ; 33 import org.xml.sax.SAXException ; 34 import org.openide.util.NbBundle; 35 import org.openide.util.Utilities; 36 37 42 public class PersistenceCatalog implements CatalogReader, CatalogDescriptor, org.xml.sax.EntityResolver { 43 44 private static final String PERSISTENCE_1_0_XSD = "persistence_1_0.xsd"; private static final String PERSISTENCE_1_0_URL = "nbres:org/netbeans/modules/j2ee/persistence/dd/resources/persistence_1_0.dtd"; private static final String PERSISTENCE_1_0 = "http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"; private static final String PERSISTENCE_1_0_ID = "SCHEMA:" + PERSISTENCE_1_0; 49 public PersistenceCatalog() { 50 } 51 52 public InputSource resolveEntity(String publicId, String systemId) throws SAXException , IOException { 53 if (PERSISTENCE_1_0.equals(systemId)){ 54 return new org.xml.sax.InputSource (PERSISTENCE_1_0_URL); 55 } 56 if (systemId != null && systemId.endsWith(PERSISTENCE_1_0_XSD)){ 57 return new org.xml.sax.InputSource (PERSISTENCE_1_0_URL); 58 } 59 return null; 60 } 61 62 public Iterator getPublicIDs() { 63 List <String > list = new ArrayList <String >(); 64 list.add(PERSISTENCE_1_0_ID); 65 return list.iterator(); 66 } 67 68 public void refresh() { 69 } 70 71 public String getSystemID(String publicId) { 72 if (PERSISTENCE_1_0_ID.equals(publicId)){ 73 return PERSISTENCE_1_0_URL; 74 } 75 return null; 76 } 77 78 public String resolveURI(String name) { 79 return null; 80 } 81 82 public String resolvePublic(String publicId) { 83 return null; 84 } 85 86 public void addCatalogListener(CatalogListener l) { 87 } 88 89 public void removeCatalogListener(CatalogListener l) { 90 } 91 92 public Image getIcon(int type) { 93 return Utilities.loadImage("org/netbeans/modules/j2ee/persistence/dd/resources/persistenceCatalog.gif"); } 95 96 public String getDisplayName() { 97 return NbBundle.getMessage(PersistenceCatalog.class, "LBL_PersistenceCatalog"); 98 } 99 100 public String getShortDescription() { 101 return NbBundle.getMessage(PersistenceCatalog.class, "DESC_PersistenceCatalog"); 102 } 103 104 public void addPropertyChangeListener(PropertyChangeListener l) { 105 } 106 107 public void removePropertyChangeListener(PropertyChangeListener l) { 108 } 109 110 } 111 | Popular Tags |