KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.io.OutputStream JavaDoc;
63 import java.io.PrintWriter JavaDoc;
64 import java.io.IOException JavaDoc;
65 import java.util.Enumeration JavaDoc;
66
67 /**
68     This class creates an &lt;hr&gt; tag.
69
70     @version $Id: hr.java,v 1.2 2003/04/27 09:39:01 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 hr extends SinglePartElement implements Printable, MouseEvents, KeyEvents
76 {
77     /**
78             Private initialization routine.
79     */

80     {
81         setElementType("hr");
82         setCase(LOWERCASE);
83         setAttributeQuote(true);
84         setBeginEndModifier('/');
85     }
86
87     /**
88         Basic constructor. Use the set* methods to set the attibutes.
89     */

90     public hr()
91     {
92     }
93
94     /**
95      * Basic constructor
96      *
97      * @param width sets the width="" attribute
98      */

99     public hr(String JavaDoc width)
100     {
101         setWidth(width);
102     }
103
104     /**
105      * Basic constructor
106      *
107      * @param width sets the width="" attribute
108      */

109     public hr(int width)
110     {
111         setWidth(width);
112     }
113
114     /**
115      * Basic constructor
116      *
117      * @param width sets the width="" attribute
118      * @param align sets the align="" attribute
119      */

120     public hr(String JavaDoc width, String JavaDoc align)
121     {
122         setWidth(width);
123         setAlign(align);
124     }
125
126     /**
127      * Basic constructor
128      *
129      * @param width sets the width="" attribute
130      * @param align sets the align="" attribute
131      */

132     public hr(int width, String JavaDoc align)
133     {
134         setWidth(width);
135         setAlign(align);
136     }
137
138     /**
139      * Basic constructor
140      *
141      * @param width sets the width="" attribute
142      * @param align sets the align="" attribute
143      * @param size sets the size="" attribute
144      */

145     public hr(String JavaDoc width, String JavaDoc align, String JavaDoc size)
146     {
147         setWidth(width);
148         setAlign(align);
149         setSize(size);
150     }
151
152     /**
153      * Basic constructor
154      *
155      * @param width sets the width="" attribute
156      * @param align sets the align="" attribute
157      * @param size sets the size="" attribute
158      */

159     public hr(String JavaDoc width, String JavaDoc align, int size)
160     {
161         setWidth(width);
162         setAlign(align);
163         setSize(size);
164     }
165
166     /**
167      * Basic constructor
168      *
169      * @param width sets the width="" attribute
170      * @param align sets the align="" attribute
171      * @param size sets the size="" attribute
172      */

173     public hr(int width, String JavaDoc align, int size)
174     {
175         setWidth(width);
176         setAlign(align);
177         setSize(size);
178     }
179
180     /**
181         Sets the width="" attribute
182         @param width the width="" attribute
183     */

184     public hr setWidth(String JavaDoc width)
185     {
186         addAttribute("width",width);
187         return this;
188     }
189
190     /**
191         Sets the width="" attribute
192         @param width the width="" attribute
193     */

194     public hr setWidth(int width)
195     {
196         addAttribute("width",Integer.toString(width));
197         return this;
198     }
199
200     /**
201         Sets the align="" attribute
202         @param align the align="" attribute
203     */

204     public hr setAlign(String JavaDoc align)
205     {
206         addAttribute("align",align);
207         return this;
208     }
209
210     /**
211         Sets the size="" attribute
212         @param hspace the size="" attribute
213     */

214     public hr setSize(String JavaDoc size)
215     {
216         addAttribute("size",size);
217         return this;
218     }
219
220     /**
221         Sets the size="" attribute
222         @param hspace the size="" attribute
223     */

224     public hr setSize(int size)
225     {
226         addAttribute("size",Integer.toString(size));
227         return this;
228     }
229
230     /**
231         Sets the noshade
232         @param shade true or false
233     */

234     public hr setNoShade(boolean shade)
235     {
236         if ( shade == true )
237             addAttribute("noshade", "noshade");
238         else
239             removeAttribute("noshade");
240             
241         return(this);
242     }
243
244     /**
245         Sets the lang="" and xml:lang="" attributes
246         @param lang the lang="" and xml:lang="" attributes
247     */

248     public Element setLang(String JavaDoc lang)
249     {
250         addAttribute("lang",lang);
251         addAttribute("xml:lang",lang);
252         return this;
253     }
254
255     /**
256         Adds an Element to the element.
257         @param hashcode name of element for hash table
258         @param element Adds an Element to the element.
259      */

260     public hr addElement(String JavaDoc hashcode,Element element)
261     {
262         addElementToRegistry(hashcode,element);
263         return(this);
264     }
265
266     /**
267         Adds an Element to the element.
268         @param hashcode name of element for hash table
269         @param element Adds an Element to the element.
270      */

271     public hr addElement(String JavaDoc hashcode,String JavaDoc element)
272     {
273         addElementToRegistry(hashcode,element);
274         return(this);
275     }
276
277     /**
278         Adds an Element to the element.
279         @param element Adds an Element to the element.
280      */

281     public hr addElement(Element element)
282     {
283         addElementToRegistry(element);
284         return(this);
285     }
286     /**
287         Adds an Element to the element.
288         @param element Adds an Element to the element.
289      */

290     public hr addElement(String JavaDoc element)
291     {
292         addElementToRegistry(element);
293         return(this);
294     }
295     /**
296         Removes an Element from the element.
297         @param hashcode the name of the element to be removed.
298     */

299     public hr removeElement(String JavaDoc hashcode)
300     {
301         removeElementFromRegistry(hashcode);
302         return(this);
303     }
304
305     /**
306         The onclick event occurs when the pointing device button is clicked
307         over an element. This attribute may be used with most elements.
308         
309         @param The script
310     */

311     public void setOnClick(String JavaDoc script)
312     {
313         addAttribute ( "onclick", script );
314     }
315     /**
316         The ondblclick event occurs when the pointing device button is double
317         clicked over an element. This attribute may be used with most elements.
318
319         @param The script
320     */

321     public void setOnDblClick(String JavaDoc script)
322     {
323         addAttribute ( "ondblclick", script );
324     }
325     /**
326         The onmousedown event occurs when the pointing device button is pressed
327         over an element. This attribute may be used with most elements.
328
329         @param The script
330     */

331     public void setOnMouseDown(String JavaDoc script)
332     {
333         addAttribute ( "onmousedown", script );
334     }
335     /**
336         The onmouseup event occurs when the pointing device button is released
337         over an element. This attribute may be used with most elements.
338
339         @param The script
340     */

341     public void setOnMouseUp(String JavaDoc script)
342     {
343         addAttribute ( "onmouseup", script );
344     }
345     /**
346         The onmouseover event occurs when the pointing device is moved onto an
347         element. This attribute may be used with most elements.
348
349         @param The script
350     */

351     public void setOnMouseOver(String JavaDoc script)
352     {
353         addAttribute ( "onmouseover", script );
354     }
355     /**
356         The onmousemove event occurs when the pointing device is moved while it
357         is over an element. This attribute may be used with most elements.
358
359         @param The script
360     */

361     public void setOnMouseMove(String JavaDoc script)
362     {
363         addAttribute ( "onmousemove", script );
364     }
365     /**
366         The onmouseout event occurs when the pointing device is moved away from
367         an element. This attribute may be used with most elements.
368
369         @param The script
370     */

371     public void setOnMouseOut(String JavaDoc script)
372     {
373         addAttribute ( "onmouseout", script );
374     }
375
376     /**
377         The onkeypress event occurs when a key is pressed and released over an
378         element. This attribute may be used with most elements.
379         
380         @param The script
381     */

382     public void setOnKeyPress(String JavaDoc script)
383     {
384         addAttribute ( "onkeypress", script );
385     }
386
387     /**
388         The onkeydown event occurs when a key is pressed down over an element.
389         This attribute may be used with most elements.
390         
391         @param The script
392     */

393     public void setOnKeyDown(String JavaDoc script)
394     {
395         addAttribute ( "onkeydown", script );
396     }
397
398     /**
399         The onkeyup event occurs when a key is released over an element. This
400         attribute may be used with most elements.
401         
402         @param The script
403     */

404     public void setOnKeyUp(String JavaDoc script)
405     {
406         addAttribute ( "onkeyup", script );
407     }
408 }
409
Popular Tags