KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ecs > xhtml > script


1 /*
2  * ====================================================================
3  *
4  * The Apache Software License, Version 1.1
5  *
6  * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
7  * reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in
18  * the documentation and/or other materials provided with the
19  * distribution.
20  *
21  * 3. The end-user documentation included with the redistribution, if
22  * any, must include the following acknowlegement:
23  * "This product includes software developed by the
24  * Apache Software Foundation (http://www.apache.org/)."
25  * Alternately, this acknowlegement may appear in the software itself,
26  * if and wherever such third-party acknowlegements normally appear.
27  *
28  * 4. The names "The Jakarta Project", "Jakarta Element Construction Set",
29  * "Jakarta ECS" , and "Apache Software Foundation" must not be used
30  * to endorse or promote products derived
31  * from this software without prior written permission. For written
32  * permission, please contact apache@apache.org.
33  *
34  * 5. Products derived from this software may not be called "Apache",
35  * "Jakarta Element Construction Set" nor "Jakarta ECS" nor may "Apache"
36  * appear in their names without prior written permission of the Apache Group.
37  *
38  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
39  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
40  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
42  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
44  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
45  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
46  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
48  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49  * SUCH DAMAGE.
50  * ====================================================================
51  *
52  * This software consists of voluntary contributions made by many
53  * individuals on behalf of the Apache Software Foundation. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  *
57  */

58 package org.apache.ecs.xhtml;
59
60 import org.apache.ecs.*;
61
62 /**
63     This class creates a &lt;script&gt; tag.
64     <P>
65     Note that XHTML script tag doesn't hide the script text withing comments
66     like its HTML counterpart does. This difference is caused by the fact that
67     XHTML is XML and XML parsers can throw the comments out. Use this tag with
68     browsers that support scripting language(s).
69
70     @version $Id: script.java,v 1.2 2003/04/27 09:36:30 rdonkin Exp $
71     @author <a HREF="mailto:snagy@servletapi.com">Stephan Nagy</a>
72     @author <a HREF="mailto:jon@clearink.com">Jon S. Stevens</a>
73     @author <a HREF="mailto:bojan@binarix.com">Bojan Smojver</a>
74 */

75 public class script extends MultiPartElement implements Printable
76 {
77     /**
78         Private initialization routine.
79     */

80     {
81         setElementType("script");
82         setCase(LOWERCASE);
83         setAttributeQuote(true);
84         setLanguage("Javascript");
85     }
86     /**
87         Basic constructor.
88     */

89     public script()
90     {
91     }
92
93     /**
94         Basic constructor.
95         @param element Adds an Element to the element.
96     */

97     public script(Element element)
98     {
99         addElement(element);
100     }
101
102     /**
103         Basic constructor.
104         @param element Adds an Element to the element.
105         @param src sets the SRC="" attribute
106     */

107     public script(Element element, String JavaDoc src)
108     {
109         addElement(element);
110         setSrc(src);
111     }
112
113     /**
114         Basic constructor.
115         @param element Adds an Element to the element.
116         @param src sets the SRC="" attribute
117         @param type sets the type="" attribute
118     */

119     public script(Element element, String JavaDoc src, String JavaDoc type)
120     {
121         addElement(element);
122         setSrc(src);
123         setType(type);
124     }
125
126     /**
127         Basic constructor.
128         @param element Adds an Element to the element.
129         @param src sets the SRC="" attribute
130         @param type sets the type="" attribute
131         @param lang sets the language="" attribute
132     */

133     public script(Element element, String JavaDoc src, String JavaDoc type, String JavaDoc lang)
134     {
135         addElement(element);
136         setSrc(src);
137         setType(type);
138         setLanguage(lang);
139     }
140
141     /**
142         Basic constructor.
143         @param element Adds an Element to the element.
144     */

145     public script(String JavaDoc element)
146     {
147         addElement(element);
148     }
149
150     /**
151         Basic constructor.
152         @param element Adds an Element to the element.
153         @param src sets the SRC="" attribute
154     */

155     public script(String JavaDoc element, String JavaDoc src)
156     {
157         addElement(element);
158         setSrc(src);
159     }
160
161     /**
162         Basic constructor.
163         @param element Adds an Element to the element.
164         @param src sets the SRC="" attribute
165         @param type sets the type="" attribute
166     */

167     public script(String JavaDoc element, String JavaDoc src, String JavaDoc type)
168     {
169         addElement(element);
170         setSrc(src);
171         setType(type);
172     }
173
174     /**
175         Basic constructor.
176         @param element Adds an Element to the element.
177         @param src sets the SRC="" attribute
178         @param type sets the type="" attribute
179         @param lang sets the language="" attribute
180     */

181     public script(String JavaDoc element, String JavaDoc src, String JavaDoc type, String JavaDoc lang)
182     {
183         addElement(element);
184         setSrc(src);
185         setType(type);
186         setLanguage(lang);
187     }
188
189     /**
190         Sets the SRC="" attribute
191         @param src the SRC="" attribute
192     */

193     public script setSrc(String JavaDoc src)
194     {
195         addAttribute("src",src);
196         return this;
197     }
198
199     /**
200         Sets the type="" attribute
201         @param type the type="" attribute
202     */

203     public script setType(String JavaDoc type)
204     {
205         addAttribute("type", type);
206         return this;
207     }
208
209     /**
210         Sets the language="" attribute
211         @param language the language="" attribute
212     */

213     public script setLanguage(String JavaDoc language)
214     {
215         addAttribute("language", language);
216         return this;
217     }
218
219     /**
220         Sets the lang="" and xml:lang="" attributes
221         @param lang the lang="" and xml:lang="" attributes
222     */

223     public Element setLang(String JavaDoc lang)
224     {
225         addAttribute("lang",lang);
226         addAttribute("xml:lang",lang);
227         return this;
228     }
229
230     /**
231         Adds an Element to the element.
232         @param hashcode name of element for hash table
233         @param element Adds an Element to the element.
234      */

235     public script addElement(String JavaDoc hashcode,Element element)
236     {
237         addElementToRegistry(hashcode,element);
238         return(this);
239     }
240
241     /**
242         Adds an Element to the element.
243         @param hashcode name of element for hash table
244         @param element Adds an Element to the element.
245      */

246     public script addElement(String JavaDoc hashcode,String JavaDoc element)
247     {
248         addElementToRegistry(hashcode,element);
249         return(this);
250     }
251
252     /**
253         Adds an Element to the element.
254         @param element Adds an Element to the element.
255      */

256     public script addElement(Element element)
257     {
258         addElementToRegistry(element);
259         return(this);
260     }
261
262     /**
263         Adds an Element to the element.
264         @param element Adds an Element to the element.
265      */

266     public script addElement(String JavaDoc element)
267     {
268         addElementToRegistry(element);
269         return(this);
270     }
271     /**
272         Removes an Element from the element.
273         @param hashcode the name of the element to be removed.
274     */

275     public script removeElement(String JavaDoc hashcode)
276     {
277         removeElementFromRegistry(hashcode);
278         return(this);
279     }
280 }
281
Popular Tags