1 19 20 21 package org.netbeans.modules.web.jsf; 22 23 24 import org.netbeans.modules.web.jsf.api.facesmodel.JSFVersion; 25 import org.netbeans.modules.xml.catalog.spi.*; 26 import org.openide.util.NbBundle; 27 import org.openide.util.Utilities; 28 import org.w3c.dom.Document ; 29 import org.w3c.dom.DocumentType ; 30 31 35 public class JSFCatalog implements CatalogReader, CatalogDescriptor, org.xml.sax.EntityResolver { 36 37 private static final String JSF_ID_1_0 = "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"; private static final String JSF_ID_1_1 = "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"; 40 private static final String URL_JSF_1_0 ="nbres:/org/netbeans/modules/web/jsf/resources/web-facesconfig_1_0.dtd"; private static final String URL_JSF_1_1 ="nbres:/org/netbeans/modules/web/jsf/resources/web-facesconfig_1_1.dtd"; 43 public static final String JAVAEE_NS = "http://java.sun.com/xml/ns/javaee"; private static final String JSF_1_2_XSD="web-facesconfig_1_2.xsd"; private static final String JSF_1_2=JAVAEE_NS+"/"+JSF_1_2_XSD; public static final String JSF_ID_1_2="SCHEMA:"+JSF_1_2; private static final String URL_JSF_1_2="nbres:/org/netbeans/modules/web/jsf/resources/web-facesconfig_1_2.xsd"; private static final String URL_JSF_1_2_DTD="nbres:/org/netbeans/modules/web/jsf/resources/web-facesconfig_1_2.dtd"; 50 51 public JSFCatalog() { 52 } 53 54 58 public java.util.Iterator getPublicIDs() { 59 java.util.List list = new java.util.ArrayList (); 60 list.add(JSF_ID_1_0); 61 list.add(JSF_ID_1_1); 62 list.add(JSF_ID_1_2); 63 return list.listIterator(); 64 } 65 66 70 public String getSystemID(String publicId) { 71 if (JSF_ID_1_0.equals(publicId)) 72 return URL_JSF_1_0; 73 else if (JSF_ID_1_1.equals(publicId)) 74 return URL_JSF_1_1; 75 else if (JSF_ID_1_2.equals(publicId)) 76 return URL_JSF_1_2_DTD; 77 else return null; 78 } 79 80 83 public void refresh() { 84 } 85 86 90 public void addCatalogListener(CatalogListener l) { 91 } 92 93 97 public void removeCatalogListener(CatalogListener l) { 98 } 99 100 101 public void addPropertyChangeListener(java.beans.PropertyChangeListener l) { 102 } 103 104 105 public void removePropertyChangeListener(java.beans.PropertyChangeListener l) { 106 } 107 108 111 public String getDisplayName() { 112 return NbBundle.getMessage (JSFCatalog.class, "LBL_JSFCatalog"); 113 } 114 115 120 public java.awt.Image getIcon(int type) { 121 return Utilities.loadImage("org/netbeans/modules/web/jsf/resources/JSFCatalog.png"); } 123 124 127 public String getShortDescription() { 128 return NbBundle.getMessage (JSFCatalog.class, "DESC_JSFCatalog"); 129 } 130 131 137 public org.xml.sax.InputSource resolveEntity(String publicId, String systemId) throws org.xml.sax.SAXException , java.io.IOException { 138 if (JSF_ID_1_0.equals(publicId)) { 139 return new org.xml.sax.InputSource (URL_JSF_1_0); 140 } else if (JSF_ID_1_1.equals(publicId)) { 141 return new org.xml.sax.InputSource (URL_JSF_1_1); 142 } else if (JSF_1_2.equals(systemId)) { 143 return new org.xml.sax.InputSource (URL_JSF_1_2); 144 } else if (systemId!=null && systemId.endsWith(JSF_1_2_XSD)) { 145 return new org.xml.sax.InputSource (URL_JSF_1_2); 146 } else { 147 return null; 148 } 149 } 150 151 155 public String resolveURI(String name) { 156 return null; 157 } 158 162 public String resolvePublic(String publicId) { 163 return null; 164 } 165 166 public static JSFVersion extractVersion(Document document) { 167 DocumentType dt = document.getDoctype(); 169 JSFVersion value = JSFVersion.JSF_1_0; 170 if (dt != null) { 172 if (JSF_ID_1_0.equals(dt.getPublicId())) { 173 value = JSFVersion.JSF_1_0; 174 } 175 if (JSF_ID_1_1.equals(dt.getPublicId())) { 176 value = JSFVersion.JSF_1_1; 177 } 178 if (JSF_ID_1_2.equals(dt.getPublicId())) { 179 value = JSFVersion.JSF_1_2; 180 } 181 } 182 return value; 183 184 } 185 186 } 187 | Popular Tags |