KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > tools > tld > JspTaglibSubTask


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * $Header:$
17  */

18 package org.apache.beehive.netui.tools.tld;
19
20 import xdoclet.XDocletException;
21 import xdoclet.XDocletMessages;
22
23 import xdoclet.XmlSubTask;
24 import xdoclet.util.Translator;
25
26 /**
27  * Generates taglib.tld deployment descriptor for JSP taglibs.
28  *
29  * @author Ara Abrahamian (ara_e@email.com)
30  * @created July 12, 2001
31  * @ant.element display-name="JSP Taglib" name="netuitldgen" parent="xdoclet.modules.web.WebDocletTask"
32  * @version $Revision: 1.12 $
33  */

34 public class JspTaglibSubTask extends XmlSubTask
35 {
36     private static String JavaDoc DEFAULT_TEMPLATE_FILE = "xdoclet/tld.xdt";
37
38     private static String JavaDoc TLD_PUBLICID_1_2 = "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN";
39
40     private static String JavaDoc TLD_PUBLICID_1_1 = "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN";
41
42     private static String JavaDoc TLD_SYSTEMID_1_2 = "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd";
43
44     private static String JavaDoc TLD_SYSTEMID_1_1 = "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd";
45
46     private static String JavaDoc TLD_DTD_FILE_NAME_1_2 = "xdoclet/modules/web/resources/web-jsptaglibrary_1_2.dtd";
47
48     private static String JavaDoc TLD_DTD_FILE_NAME_1_1 = "xdoclet/modules/web/resources/web-jsptaglibrary_1_1.dtd";
49
50     protected String JavaDoc taglibversion = "1.0";
51
52     protected String JavaDoc jspversion = JspVersionTypes.VERSION_1_2;
53
54     protected String JavaDoc shortname = "";
55
56     protected String JavaDoc uri = "";
57
58     protected String JavaDoc displayname = "";
59
60     protected String JavaDoc smallicon = "";
61
62     protected String JavaDoc largeicon = "";
63
64     protected String JavaDoc description = "";
65
66     protected String JavaDoc filename = "taglib.tld";
67
68     private String JavaDoc _packageName = null;
69
70     private String JavaDoc _functionPackage = null;
71
72     /**
73      * Describe what the JspTaglibSubTask constructor does
74      */

75     public JspTaglibSubTask()
76     {
77         setTemplateURL(getClass().getResource(DEFAULT_TEMPLATE_FILE));
78         setDestinationFile(filename);
79
80         setPublicId(TLD_PUBLICID_1_2);
81         setSystemId(TLD_SYSTEMID_1_2);
82         setDtdURL(getClass().getResource(TLD_DTD_FILE_NAME_1_2));
83     }
84
85     public void setPackageName(String JavaDoc packageName)
86     {
87         this._packageName = packageName;
88     }
89
90     public String JavaDoc getPackageName()
91     {
92         return _packageName;
93     }
94
95     public void setFunctionPackage(String JavaDoc functionPackage) {
96         _functionPackage = functionPackage;
97     }
98
99     public String JavaDoc getFunctionPackage() {
100         return _functionPackage;
101     }
102
103     /**
104      * Gets the Jspversion attribute of the JspTaglibSubTask object
105      *
106      * @return The Jspversion value
107      */

108     public String JavaDoc getJspversion()
109     {
110         return jspversion;
111     }
112
113     /**
114      * Gets the Taglibversion attribute of the JspTaglibSubTask object
115      *
116      * @return The Taglibversion value
117      */

118     public String JavaDoc getTaglibversion()
119     {
120         return taglibversion;
121     }
122
123     /**
124      * Gets the Shortname attribute of the JspTaglibSubTask object
125      *
126      * @return The Shortname value
127      */

128     public String JavaDoc getShortname()
129     {
130         return shortname;
131     }
132
133     /**
134      * Gets the Uri attribute of the JspTaglibSubTask object
135      *
136      * @return The Uri value
137      */

138     public String JavaDoc getUri()
139     {
140         return uri;
141     }
142
143     /**
144      * Gets the Displayname attribute of the JspTaglibSubTask object
145      *
146      * @return The Displayname value
147      */

148     public String JavaDoc getDisplayname()
149     {
150         return displayname;
151     }
152
153     /**
154      * Gets the Smallicon attribute of the JspTaglibSubTask object
155      *
156      * @return The Smallicon value
157      */

158     public String JavaDoc getSmallicon()
159     {
160         return smallicon;
161     }
162
163     /**
164      * Gets the Largeicon attribute of the JspTaglibSubTask object
165      *
166      * @return The Largeicon value
167      */

168     public String JavaDoc getLargeicon()
169     {
170         return largeicon;
171     }
172
173     /**
174      * Gets the Description attribute of the JspTaglibSubTask object
175      *
176      * @return The Description value
177      */

178     public String JavaDoc getDescription()
179     {
180         return description;
181     }
182
183     /**
184      * Gets the Filename attribute of the JspTaglibSubTask object
185      *
186      * @return The Filename value
187      */

188     public String JavaDoc getFilename()
189     {
190         return filename;
191     }
192
193     /**
194      * Sets the Jspversion attribute of the JspTaglibSubTask object
195      *
196      * @param jspversion The new Jspversion value
197      */

198     public void setJspversion(JspVersionTypes jspversion)
199     {
200         this.jspversion = jspversion.getValue();
201     }
202
203     /**
204      * Sets the Taglibversion attribute of the JspTaglibSubTask object
205      *
206      * @param taglibversion The new Taglibversion value
207      */

208     public void setTaglibversion(String JavaDoc taglibversion)
209     {
210         this.taglibversion = taglibversion;
211     }
212
213     /**
214      * Sets the Shortname attribute of the JspTaglibSubTask object
215      *
216      * @param shortname The new Shortname value
217      */

218     public void setShortname(String JavaDoc shortname)
219     {
220         this.shortname = shortname;
221     }
222
223     /**
224      * Sets the Uri attribute of the JspTaglibSubTask object
225      *
226      * @param uri The new Uri value
227      */

228     public void setUri(String JavaDoc uri)
229     {
230         this.uri = uri;
231     }
232
233     /**
234      * Sets the Displayname attribute of the JspTaglibSubTask object
235      *
236      * @param new_display_name The new Displayname value
237      */

238     public void setDisplayname(String JavaDoc new_display_name)
239     {
240         displayname = new_display_name;
241     }
242
243     /**
244      * Sets the Smallicon attribute of the JspTaglibSubTask object
245      *
246      * @param new_icon The new Smallicon value
247      */

248     public void setSmallicon(String JavaDoc new_icon)
249     {
250         smallicon = new_icon;
251     }
252
253     /**
254      * Sets the Largeicon attribute of the JspTaglibSubTask object
255      *
256      * @param new_icon The new Largeicon value
257      */

258     public void setLargeicon(String JavaDoc new_icon)
259     {
260         largeicon = new_icon;
261     }
262
263     /**
264      * Sets the Description attribute of the JspTaglibSubTask object
265      *
266      * @param new_description The new Description value
267      */

268     public void setDescription(String JavaDoc new_description)
269     {
270         description = new_description;
271     }
272
273     /**
274      * Sets the Filename attribute of the JspTaglibSubTask object
275      *
276      * @param new_filename The new Filename value
277      */

278     public void setFilename(String JavaDoc new_filename)
279     {
280         filename = new_filename;
281         setDestinationFile(filename);
282     }
283
284     /**
285      * Called to validate configuration parameters.
286      *
287      * @exception XDocletException
288      */

289     public void validateOptions() throws XDocletException
290     {
291         super.validateOptions();
292
293         if (getShortname() == null || getShortname().trim().equals("")) {
294             throw new XDocletException(Translator.getString(XDocletMessages.class, XDocletMessages.PARAMETER_MISSING_OR_EMPTY, new String JavaDoc[]{"shortName"}));
295         }
296     }
297
298     /**
299      * Describe what the method does
300      *
301      * @exception XDocletException
302      */

303     public void execute() throws XDocletException
304     {
305         if (getJspversion().equals(JspVersionTypes.VERSION_1_1)) {
306             setPublicId(TLD_PUBLICID_1_1);
307             setSystemId(TLD_SYSTEMID_1_1);
308             setDtdURL(getClass().getResource(TLD_DTD_FILE_NAME_1_1));
309         }
310         else {
311             setPublicId(TLD_PUBLICID_1_2);
312             setSystemId(TLD_SYSTEMID_1_2);
313             setDtdURL(getClass().getResource(TLD_DTD_FILE_NAME_1_2));
314         }
315
316         startProcess();
317     }
318
319     /**
320      * Describe what the method does
321      *
322      * @exception XDocletException
323      */

324     protected void engineStarted() throws XDocletException
325     {
326         System.out.println(Translator.getString(XDocletMessages.class, XDocletMessages.GENERATING_SOMETHING, new String JavaDoc[]{getDestinationFile().toString()}));
327     }
328
329     /**
330      * @author Aslak Hellesoy
331      * @created July 28, 2001
332      */

333     public static class ContextParam implements java.io.Serializable JavaDoc
334     {
335         private String JavaDoc paramName = null;
336         private String JavaDoc paramValue = null;
337         private String JavaDoc description = "";
338
339         /**
340          * Gets the Name attribute of the ContextParam object
341          *
342          * @return The Name value
343          */

344         public String JavaDoc getName()
345         {
346             return paramName;
347         }
348
349         /**
350          * Gets the Value attribute of the ContextParam object
351          *
352          * @return The Value value
353          */

354         public String JavaDoc getValue()
355         {
356             return paramValue;
357         }
358
359         /**
360          * Gets the Description attribute of the ContextParam object
361          *
362          * @return The Description value
363          */

364         public String JavaDoc getDescription()
365         {
366             return description;
367         }
368
369         /**
370          * Sets the Name attribute of the ContextParam object
371          *
372          * @param name The new Name value
373          */

374         public void setName(String JavaDoc name)
375         {
376             paramName = name;
377         }
378
379         /**
380          * Sets the Value attribute of the ContextParam object
381          *
382          * @param value The new Value value
383          */

384         public void setValue(String JavaDoc value)
385         {
386             paramValue = value;
387         }
388
389         /**
390          * Sets the Description attribute of the ContextParam object
391          *
392          * @param desc The new Description value
393          */

394         public void setDescription(String JavaDoc desc)
395         {
396             description = desc;
397         }
398     }
399
400     /**
401      * @author Aslak Hellesoy
402      * @created July 28, 2001
403      */

404     public static class TagLib implements java.io.Serializable JavaDoc
405     {
406         private String JavaDoc taglibURI = null;
407         private String JavaDoc taglibLocation = null;
408
409         /**
410          * Gets the URI attribute of the TagLib object
411          *
412          * @return The URI value
413          */

414         public String JavaDoc getURI()
415         {
416             return taglibURI;
417         }
418
419         /**
420          * Gets the Location attribute of the TagLib object
421          *
422          * @return The Location value
423          */

424         public String JavaDoc getLocation()
425         {
426             return taglibLocation;
427         }
428
429         /**
430          * Sets the URI attribute of the TagLib object
431          *
432          * @param uri The new URI value
433          */

434         public void setURI(String JavaDoc uri)
435         {
436             taglibURI = uri;
437         }
438
439         /**
440          * Sets the Location attribute of the TagLib object
441          *
442          * @param location The new Location value
443          */

444         public void setLocation(String JavaDoc location)
445         {
446             taglibLocation = location;
447         }
448     }
449
450     /**
451      * @author Ara Abrahamian (ara_e@email.com)
452      * @created July 19, 2001
453      */

454     public static class JspVersionTypes extends org.apache.tools.ant.types.EnumeratedAttribute
455     {
456         public final static String JavaDoc VERSION_1_1 = "1.1";
457         public final static String JavaDoc VERSION_1_2 = "1.2";
458         public final static String JavaDoc VERSION_2_0 = "2.0";
459
460         // We're getting there!
461

462         /**
463          * Gets the Values attribute of the JspVersionTypes object
464          *
465          * @return The Values value
466          */

467         public String JavaDoc[] getValues()
468         {
469             return (new String JavaDoc[]{VERSION_1_1, VERSION_1_2, VERSION_2_0});
470         }
471     }
472
473 }
474
Popular Tags