KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > wsdl > WSSchemaCatalog


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.websvc.wsdl;
21
22 import java.beans.PropertyChangeListener JavaDoc;
23 import java.io.IOException JavaDoc;
24 import java.util.ArrayList JavaDoc;
25 import java.util.Iterator JavaDoc;
26 import java.util.List JavaDoc;
27
28 import org.xml.sax.EntityResolver JavaDoc;
29 import org.xml.sax.InputSource JavaDoc;
30 import org.xml.sax.SAXException JavaDoc;
31
32 import org.openide.util.NbBundle;
33 import org.openide.util.Utilities;
34
35 import org.netbeans.modules.xml.catalog.spi.CatalogReader;
36 import org.netbeans.modules.xml.catalog.spi.CatalogDescriptor;
37 import org.netbeans.modules.xml.catalog.spi.CatalogListener;
38
39 /** Catalog for webservice related schemas that enables completion support in
40  * editor.
41  *
42  * Original code before webservice modifications taken from DDCatalog.java in web/core
43  *
44  * @author Peter Williams
45  *
46  */

47 public class WSSchemaCatalog implements CatalogReader, CatalogDescriptor, EntityResolver JavaDoc {
48
49     public static final String JavaDoc JAXRPC_CONFIG_1_1 = "http://java.sun.com/xml/ns/jax-rpc/ri/config"; // NOI18N
50
public static final String JavaDoc JAXRPC_CONFIG_1_1_SLASH = "http://java.sun.com/xml/ns/jax-rpc/ri/config/"; // NOI18N
51
private static final String JavaDoc JAXRPC_CONFIG_1_1_XSD = "jax-rpc-ri-config_1_1.xsd"; // NOI18N
52
private static final String JavaDoc URL_JAXRPC_CONFIG_1_1 = "nbres:/org/netbeans/modules/websvc/wsdl/config/resources/jax-rpc-ri-config_1_1.xsd"; // NOI18N
53
private static final String JavaDoc URL_JAXRPC_CONFIG_1_1_DTD = "nbres:/org/netbeans/modules/websvc/wsdl/config/resources/jax-rpc-ri-config_1_1.dtd"; // NOI18N
54

55     public static final String JavaDoc JAXRPC_CONFIG_1_1_ID = "SCHEMA:" + JAXRPC_CONFIG_1_1; // NOI18N
56

57     public WSSchemaCatalog() {
58     }
59
60     /**
61      * Get String iterator representing all public IDs registered in catalog.
62      * @return null if cannot proceed, try later.
63      */

64     public Iterator JavaDoc<String JavaDoc> getPublicIDs() {
65         List JavaDoc<String JavaDoc> list = new ArrayList JavaDoc<String JavaDoc>();
66         list.add(JAXRPC_CONFIG_1_1_ID);
67         return list.listIterator();
68     }
69
70     /**
71      * Get registered systemid for given public Id or null if not registered.
72      * @return null if not registered
73      */

74     public String JavaDoc getSystemID(String JavaDoc publicId) {
75         if(JAXRPC_CONFIG_1_1_ID.equals(publicId)) {
76             return URL_JAXRPC_CONFIG_1_1_DTD;
77         } else {
78             return null;
79         }
80     }
81
82     /**
83      * Refresh content according to content of mounted catalog.
84      */

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

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

99     public void removeCatalogListener(CatalogListener l) {
100     }
101
102     /** Registers new listener. */
103     public void addPropertyChangeListener(PropertyChangeListener JavaDoc l) {
104     }
105
106     /**
107      * @return I18N display name
108      */

109     public String JavaDoc getDisplayName() {
110         return NbBundle.getMessage(WSSchemaCatalog.class, "LBL_WebServiceSchemaCatalog"); // NOI18N
111
}
112
113     /**
114      * Return visualized state of given catalog.
115      * @param type of icon defined by JavaBeans specs
116      * @return icon representing current state or null
117      */

118     public java.awt.Image JavaDoc getIcon(int type) {
119         return Utilities.loadImage("org/netbeans/modules/websvc/wsdl/resources/WebServiceSchemaCatalog.png"); // NOI18N
120
}
121
122     /**
123      * @return I18N short description
124      */

125     public String JavaDoc getShortDescription() {
126         return NbBundle.getMessage (WSSchemaCatalog.class, "DESC_WebServiceSchemaCatalog");
127     }
128
129     /** Unregister the listener.
130      */

131     public void removePropertyChangeListener(PropertyChangeListener JavaDoc l) {
132     }
133
134     /**
135      * Resolves schema definition file for deployment descriptor (spec.2_4)
136      * @param publicId publicId for resolved entity (null in our case)
137      * @param systemId systemId for resolved entity
138      * @return InputSource for
139      */

140     public InputSource JavaDoc resolveEntity(String JavaDoc publicId, String JavaDoc systemId) throws SAXException JavaDoc, IOException JavaDoc {
141         if(JAXRPC_CONFIG_1_1.equals(systemId) || JAXRPC_CONFIG_1_1_SLASH.equals(systemId)) {
142             return new InputSource JavaDoc(URL_JAXRPC_CONFIG_1_1);
143         } else if(systemId != null && systemId.endsWith(JAXRPC_CONFIG_1_1_XSD)) {
144             return new org.xml.sax.InputSource JavaDoc(URL_JAXRPC_CONFIG_1_1);
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         if(JAXRPC_CONFIG_1_1.equals(name) || JAXRPC_CONFIG_1_1_SLASH.equals(name)) {
156             return URL_JAXRPC_CONFIG_1_1;
157         }
158
159         return null;
160     }
161     /**
162      * Get registered URI for the given publicId or null if not registered.
163      * @return null if not registered
164      */

165     public String JavaDoc resolvePublic(String JavaDoc publicId) {
166         return null;
167     }
168 }
169
Popular Tags