KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > taglib > TaglibCatalog


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.web.taglib;
21
22 import org.netbeans.modules.xml.catalog.spi.*;
23 import org.openide.util.NbBundle;
24 import org.openide.util.Utilities;
25
26 /** Catalog for taglib DTDs and schemas that enables code completion and XML validation in editor.
27  *
28  * @author Milan Kuchtiak
29  */

30 public class TaglibCatalog implements CatalogReader, CatalogDescriptor, org.xml.sax.EntityResolver JavaDoc {
31     private static final String JavaDoc TAGLIB_1_1="-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"; // NOI18N
32
private static final String JavaDoc TAGLIB_1_2="-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"; // NOI18N
33

34     public static final String JavaDoc J2EE_NS = "http://java.sun.com/xml/ns/j2ee"; // NOI18N
35
private static final String JavaDoc TAGLIB_2_0_XSD="web-jsptaglibrary_2_0.xsd"; // NOI18N
36
private static final String JavaDoc TAGLIB_2_0=J2EE_NS+"/"+TAGLIB_2_0_XSD; // NOI18N
37
public static final String JavaDoc TAGLIB_2_0_ID="SCHEMA:"+TAGLIB_2_0; // NOI18N
38
private static final String JavaDoc WEB_SERVICES_CLIENT_XSD = "http://www.ibm.com/webservices/xsd/j2ee_web_services_client_1_1.xsd"; // NOI18N
39

40     private static final String JavaDoc URL_TAGLIB_1_1="nbres:/org/netbeans/modules/web/taglib/resources/web-jsptaglibrary_1_1.dtd"; // NOI18N
41
private static final String JavaDoc URL_TAGLIB_1_2="nbres:/org/netbeans/modules/web/taglib/resources/web-jsptaglibrary_1_2.dtd"; // NOI18N
42
private static final String JavaDoc URL_TAGLIB_2_0="nbres:/org/netbeans/modules/web/taglib/resources/web-jsptaglibrary_2_0.xsd"; // NOI18N
43
private static final String JavaDoc URL_WEB_SERVICES_CLIENT = "nbres:/org/netbeans/modules/web/taglib/resources/j2ee_web_services_client_1_1.xsd"; // NOI18N
44
private static final String JavaDoc URL_TAGLIB_2_0_DTD="nbres:/org/netbeans/modules/web/taglib/resources/web-jsptaglibrary_2_0.dtd"; // NOI18N
45

46     private static final String JavaDoc XML_XSD="http://www.w3.org/2001/xml.xsd"; // NOI18N
47
private static final String JavaDoc XML_XSD_DEF="<?xml version='1.0'?><xs:schema targetNamespace=\"http://www.w3.org/XML/1998/namespace\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xml:lang=\"en\"><xs:attribute name=\"lang\" type=\"xs:language\"><xs:annotation><xs:documentation>In due course, we should install the relevant ISO 2- and 3-letter codes as the enumerated possible values . . .</xs:documentation></xs:annotation></xs:attribute></xs:schema>"; // NOI18N
48

49     /** Creates a new instance of TaglibCatalog */
50     public TaglibCatalog() {
51     }
52     
53     /**
54      * Get String iterator representing all public IDs registered in catalog.
55      * @return null if cannot proceed, try later.
56      */

57     public java.util.Iterator JavaDoc getPublicIDs() {
58         java.util.List JavaDoc list = new java.util.ArrayList JavaDoc();
59         list.add(TAGLIB_1_1);
60         list.add(TAGLIB_1_2);
61         list.add(TAGLIB_2_0_ID);
62         return list.listIterator();
63     }
64     
65     /**
66      * Get registered systemid for given public Id or null if not registered.
67      * @return null if not registered
68      */

69     public String JavaDoc getSystemID(String JavaDoc publicId) {
70         if (TAGLIB_1_2.equals(publicId))
71             return URL_TAGLIB_1_2;
72         else if (TAGLIB_1_1.equals(publicId))
73             return URL_TAGLIB_1_1;
74         else if (TAGLIB_2_0_ID.equals(publicId))
75             return URL_TAGLIB_2_0_DTD;
76         else return null;
77     }
78     
79     /**
80      * Refresh content according to content of mounted catalog.
81      */

82     public void refresh() {
83     }
84     
85     /**
86      * Optional operation allowing to listen at catalog for changes.
87      * @throws UnsupportedOpertaionException if not supported by the implementation.
88      */

89     public void addCatalogListener(CatalogListener l) {
90     }
91     
92     /**
93      * Optional operation couled with addCatalogListener.
94      * @throws UnsupportedOpertaionException if not supported by the implementation.
95      */

96     public void removeCatalogListener(CatalogListener l) {
97     }
98     
99     /** Registers new listener. */
100     public void addPropertyChangeListener(java.beans.PropertyChangeListener JavaDoc l) {
101     }
102     
103     /**
104      * @return I18N display name
105      */

106     public String JavaDoc getDisplayName() {
107         return NbBundle.getMessage (TaglibCatalog.class, "LBL_TaglibCatalog");
108     }
109     
110     /**
111      * Return visuaized state of given catalog.
112      * @param type of icon defined by JavaBeans specs
113      * @return icon representing current state or null
114      */

115     public java.awt.Image JavaDoc getIcon(int type) {
116         return Utilities.loadImage("org/netbeans/modules/web/taglib/resources/TaglibCatalog.gif"); // NOI18N
117
}
118     
119     /**
120      * @return I18N short description
121      */

122     public String JavaDoc getShortDescription() {
123         return NbBundle.getMessage (TaglibCatalog.class, "DESC_TaglibCatalog");
124     }
125     
126     /** Unregister the listener. */
127     public void removePropertyChangeListener(java.beans.PropertyChangeListener JavaDoc l) {
128     }
129     
130     /**
131      * Resolves schema definition file for taglib descriptor (spec.1_1, 1_2, 2_0)
132      * @param publicId publicId for resolved entity (null in our case)
133      * @param systemId systemId for resolved entity
134      * @return InputSource for publisId,
135      */

136     public org.xml.sax.InputSource JavaDoc resolveEntity(String JavaDoc publicId, String JavaDoc systemId) throws org.xml.sax.SAXException JavaDoc, java.io.IOException JavaDoc {
137         if (TAGLIB_2_0.equals(systemId)) {
138             return new org.xml.sax.InputSource JavaDoc(URL_TAGLIB_2_0);
139         } else if (systemId!=null && systemId.endsWith(TAGLIB_2_0_XSD)) {
140             return new org.xml.sax.InputSource JavaDoc(URL_TAGLIB_2_0);
141         } else if (WEB_SERVICES_CLIENT_XSD.equals(systemId)) {
142             return new org.xml.sax.InputSource JavaDoc(URL_WEB_SERVICES_CLIENT);
143         } else if (XML_XSD.equals(systemId)) {
144             return new org.xml.sax.InputSource JavaDoc(new java.io.StringReader JavaDoc(XML_XSD_DEF));
145         } else {
146             return null;
147         }
148     }
149     
150     /**
151      * Get registered URI for the given name or null if not registered.
152      * @return null if not registered
153      */

154     public String JavaDoc resolveURI(String JavaDoc name) {
155         return null;
156     }
157     /**
158      * Get registered URI for the given publicId or null if not registered.
159      * @return null if not registered
160      */

161     public String JavaDoc resolvePublic(String JavaDoc publicId) {
162         return null;
163     }
164     
165 }
166
Popular Tags