KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > struts > StrutsCatalog


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 /*
21  * StrutsCatalog.java
22  *
23  * Created on April 24, 2002, 10:38 PM
24  */

25
26 package org.netbeans.modules.web.struts;
27
28 import org.netbeans.modules.xml.catalog.spi.*;
29 import org.openide.util.NbBundle;
30 import org.openide.util.Utilities;
31 /**
32  *
33  * @author Petr Pisl
34  */

35 public class StrutsCatalog implements CatalogReader, CatalogDescriptor, org.xml.sax.EntityResolver JavaDoc {
36
37     private static final String JavaDoc STRUTS_ID_1_0 = "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"; // NOI18N
38
private static final String JavaDoc STRUTS_ID_1_1 = "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"; // NOI18N
39
private static final String JavaDoc STRUTS_ID_1_2 = "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"; // NOI18N
40
private static final String JavaDoc TILES_ID_1_1 = "-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"; // NOI18N
41
private static final String JavaDoc VALIDATOR_ID_1_1_3 = "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"; // NOI18N
42

43     private static final String JavaDoc URL_STRUTS_1_0 ="nbres:/org/netbeans/modules/web/struts/resources/struts-config_1_0.dtd"; // NOI18N
44
private static final String JavaDoc URL_STRUTS_1_1 ="nbres:/org/netbeans/modules/web/struts/resources/struts-config_1_1.dtd"; // NOI18N
45
private static final String JavaDoc URL_STRUTS_1_2 ="nbres:/org/netbeans/modules/web/struts/resources/struts-config_1_2.dtd"; // NOI18N
46
private static final String JavaDoc URL_TILES_1_1 = "nbres:/org/netbeans/modules/web/struts/resources/tiles-config_1_1.dtd"; // NOI18N
47
private static final String JavaDoc URL_VALIDATOR_1_1_3 = "nbres:/org/netbeans/modules/web/struts/resources/validator_1_1_3.dtd"; // NOI18N
48

49     /** Creates a new instance of StrutsCatalog */
50     public StrutsCatalog() {
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(STRUTS_ID_1_0);
60         list.add(STRUTS_ID_1_1);
61         list.add(STRUTS_ID_1_2);
62         list.add(TILES_ID_1_1);
63         list.add(VALIDATOR_ID_1_1_3);
64         return list.listIterator();
65     }
66     
67     /**
68      * Get registered systemid for given public Id or null if not registered.
69      * @return null if not registered
70      */

71     public String JavaDoc getSystemID(String JavaDoc publicId) {
72         if (STRUTS_ID_1_0.equals(publicId))
73             return URL_STRUTS_1_0;
74         else if (STRUTS_ID_1_1.equals(publicId))
75             return URL_STRUTS_1_1;
76         else if (STRUTS_ID_1_2.equals(publicId))
77             return URL_STRUTS_1_2;
78         else if (TILES_ID_1_1.equals(publicId))
79             return URL_TILES_1_1;
80         else if (VALIDATOR_ID_1_1_3.equals(publicId))
81             return URL_VALIDATOR_1_1_3;
82         else return null;
83     }
84     
85     /**
86      * Refresh content according to content of mounted catalog.
87      */

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

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

102     public void removeCatalogListener(CatalogListener l) {
103     }
104     
105     /** Registers new listener. */
106     public void addPropertyChangeListener(java.beans.PropertyChangeListener JavaDoc l) {
107     }
108     
109      /** Unregister the listener. */
110     public void removePropertyChangeListener(java.beans.PropertyChangeListener JavaDoc l) {
111     }
112     
113     /**
114      * @return I18N display name
115      */

116     public String JavaDoc getDisplayName() {
117         return NbBundle.getMessage (StrutsCatalog.class, "LBL_StrutsCatalog"); //NOI18N
118
}
119     
120     /**
121      * Return visuaized state of given catalog.
122      * @param type of icon defined by JavaBeans specs
123      * @return icon representing current state or null
124      */

125     public java.awt.Image JavaDoc getIcon(int type) {
126         return Utilities.loadImage("org/netbeans/modules/web/struts/resources/StrutsCatalog.png"); // NOI18N
127
}
128     
129     /**
130      * @return I18N short description
131      */

132     public String JavaDoc getShortDescription() {
133         return NbBundle.getMessage (StrutsCatalog.class, "DESC_StrutsCatalog"); //NOI18N
134
}
135     
136    /**
137      * Resolves schema definition file for taglib descriptor (spec.1_1, 1_2, 2_0)
138      * @param publicId publicId for resolved entity (null in our case)
139      * @param systemId systemId for resolved entity
140      * @return InputSource for publisId,
141      */

142     public org.xml.sax.InputSource JavaDoc resolveEntity(String JavaDoc publicId, String JavaDoc systemId) throws org.xml.sax.SAXException JavaDoc, java.io.IOException JavaDoc {
143        if (STRUTS_ID_1_0.equals(publicId)) {
144             return new org.xml.sax.InputSource JavaDoc(URL_STRUTS_1_0);
145         } else if (STRUTS_ID_1_1.equals(publicId)) {
146             return new org.xml.sax.InputSource JavaDoc(URL_STRUTS_1_1);
147         } else if (STRUTS_ID_1_2.equals(publicId)) {
148             return new org.xml.sax.InputSource JavaDoc(URL_STRUTS_1_2);
149         } else if (TILES_ID_1_1.equals(publicId)) {
150             return new org.xml.sax.InputSource JavaDoc(URL_TILES_1_1);
151         } else if (VALIDATOR_ID_1_1_3.equals(publicId)) {
152             return new org.xml.sax.InputSource JavaDoc(URL_VALIDATOR_1_1_3);
153         } else {
154             return null;
155         }
156     }
157     
158     /**
159      * Get registered URI for the given name or null if not registered.
160      * @return null if not registered
161      */

162     public String JavaDoc resolveURI(String JavaDoc name) {
163         return null;
164     }
165     /**
166      * Get registered URI for the given publicId or null if not registered.
167      * @return null if not registered
168      */

169     public String JavaDoc resolvePublic(String JavaDoc publicId) {
170         return null;
171     }
172 }
173
Popular Tags