KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ecs > html > 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.html;
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.5 2003/04/27 09:04:02 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 */

74 public class HR extends SinglePartElement implements Printable, MouseEvents, KeyEvents
75 {
76     /**
77             Private initialization routine.
78     */

79     {
80         setElementType("hr");
81     }
82
83     /**
84         Basic constructor. Use the set* methods to set the attibutes.
85     */

86     public HR()
87     {
88     }
89
90     /**
91      * Basic constructor
92      *
93      * @param width sets the WIDTH="" attribute
94      */

95     public HR(String JavaDoc width)
96     {
97         setWidth(width);
98     }
99
100     /**
101      * Basic constructor
102      *
103      * @param width sets the WIDTH="" attribute
104      */

105     public HR(int width)
106     {
107         setWidth(width);
108     }
109
110     /**
111      * Basic constructor
112      *
113      * @param width sets the WIDTH="" attribute
114      * @param align sets the ALIGN="" attribute
115      */

116     public HR(String JavaDoc width, String JavaDoc align)
117     {
118         setWidth(width);
119         setAlign(align);
120     }
121
122     /**
123      * Basic constructor
124      *
125      * @param width sets the WIDTH="" attribute
126      * @param align sets the ALIGN="" attribute
127      */

128     public HR(int width, String JavaDoc align)
129     {
130         setWidth(width);
131         setAlign(align);
132     }
133
134     /**
135      * Basic constructor
136      *
137      * @param width sets the WIDTH="" attribute
138      * @param align sets the ALIGN="" attribute
139      * @param size sets the SIZE="" attribute
140      */

141     public HR(String JavaDoc width, String JavaDoc align, String JavaDoc size)
142     {
143         setWidth(width);
144         setAlign(align);
145         setSize(size);
146     }
147
148     /**
149      * Basic constructor
150      *
151      * @param width sets the WIDTH="" attribute
152      * @param align sets the ALIGN="" attribute
153      * @param size sets the SIZE="" attribute
154      */

155     public HR(String JavaDoc width, String JavaDoc align, int size)
156     {
157         setWidth(width);
158         setAlign(align);
159         setSize(size);
160     }
161
162     /**
163      * Basic constructor
164      *
165      * @param width sets the WIDTH="" attribute
166      * @param align sets the ALIGN="" attribute
167      * @param size sets the SIZE="" attribute
168      */

169     public HR(int width, String JavaDoc align, int size)
170     {
171         setWidth(width);
172         setAlign(align);
173         setSize(size);
174     }
175
176     /**
177         Sets the WIDTH="" attribute
178         @param width the WIDTH="" attribute
179     */

180     public HR setWidth(String JavaDoc width)
181     {
182         addAttribute("width",width);
183         return this;
184     }
185
186     /**
187         Sets the WIDTH="" attribute
188         @param width the WIDTH="" attribute
189     */

190     public HR setWidth(int width)
191     {
192         addAttribute("width",Integer.toString(width));
193         return this;
194     }
195
196     /**
197         Sets the ALIGN="" attribute
198         @param align the ALIGN="" attribute
199     */

200     public HR setAlign(String JavaDoc align)
201     {
202         addAttribute("align",align);
203         return this;
204     }
205
206     /**
207         Sets the SIZE="" attribute
208         @param hspace the SIZE="" attribute
209     */

210     public HR setSize(String JavaDoc size)
211     {
212         addAttribute("size",size);
213         return this;
214     }
215
216     /**
217         Sets the SIZE="" attribute
218         @param hspace the SIZE="" attribute
219     */

220     public HR setSize(int size)
221     {
222         addAttribute("size",Integer.toString(size));
223         return this;
224     }
225
226     /**
227         Sets the noshade
228         @param shade true or false
229     */

230     public HR setNoShade(boolean shade)
231     {
232         if ( shade == true )
233             addAttribute("noshade", NO_ATTRIBUTE_VALUE);
234         else
235             removeAttribute("noshade");
236             
237         return(this);
238     }
239
240     /**
241         Adds an Element to the element.
242         @param hashcode name of element for hash table
243         @param element Adds an Element to the element.
244      */

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

256     public HR addElement(String JavaDoc hashcode,String JavaDoc element)
257     {
258         addElementToRegistry(hashcode,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 HR addElement(Element element)
267     {
268         addElementToRegistry(element);
269         return(this);
270     }
271     /**
272         Adds an Element to the element.
273         @param element Adds an Element to the element.
274      */

275     public HR addElement(String JavaDoc element)
276     {
277         addElementToRegistry(element);
278         return(this);
279     }
280     /**
281         Removes an Element from the element.
282         @param hashcode the name of the element to be removed.
283     */

284     public HR removeElement(String JavaDoc hashcode)
285     {
286         removeElementFromRegistry(hashcode);
287         return(this);
288     }
289
290     /**
291         The onclick event occurs when the pointing device button is clicked
292         over an element. This attribute may be used with most elements.
293         
294         @param The script
295     */

296     public void setOnClick(String JavaDoc script)
297     {
298         addAttribute ( "onClick", script );
299     }
300     /**
301         The ondblclick event occurs when the pointing device button is double
302         clicked over an element. This attribute may be used with most elements.
303
304         @param The script
305     */

306     public void setOnDblClick(String JavaDoc script)
307     {
308         addAttribute ( "onDblClick", script );
309     }
310     /**
311         The onmousedown event occurs when the pointing device button is pressed
312         over an element. This attribute may be used with most elements.
313
314         @param The script
315     */

316     public void setOnMouseDown(String JavaDoc script)
317     {
318         addAttribute ( "onMouseDown", script );
319     }
320     /**
321         The onmouseup event occurs when the pointing device button is released
322         over an element. This attribute may be used with most elements.
323
324         @param The script
325     */

326     public void setOnMouseUp(String JavaDoc script)
327     {
328         addAttribute ( "onMouseUp", script );
329     }
330     /**
331         The onmouseover event occurs when the pointing device is moved onto an
332         element. This attribute may be used with most elements.
333
334         @param The script
335     */

336     public void setOnMouseOver(String JavaDoc script)
337     {
338         addAttribute ( "onMouseOver", script );
339     }
340     /**
341         The onmousemove event occurs when the pointing device is moved while it
342         is over an element. This attribute may be used with most elements.
343
344         @param The script
345     */

346     public void setOnMouseMove(String JavaDoc script)
347     {
348         addAttribute ( "onMouseMove", script );
349     }
350     /**
351         The onmouseout event occurs when the pointing device is moved away from
352         an element. This attribute may be used with most elements.
353
354         @param The script
355     */

356     public void setOnMouseOut(String JavaDoc script)
357     {
358         addAttribute ( "onMouseOut", script );
359     }
360
361     /**
362         The onkeypress event occurs when a key is pressed and released over an
363         element. This attribute may be used with most elements.
364         
365         @param The script
366     */

367     public void setOnKeyPress(String JavaDoc script)
368     {
369         addAttribute ( "onKeyPress", script );
370     }
371
372     /**
373         The onkeydown event occurs when a key is pressed down over an element.
374         This attribute may be used with most elements.
375         
376         @param The script
377     */

378     public void setOnKeyDown(String JavaDoc script)
379     {
380         addAttribute ( "onKeyDown", script );
381     }
382
383     /**
384         The onkeyup event occurs when a key is released over an element. This
385         attribute may be used with most elements.
386         
387         @param The script
388     */

389     public void setOnKeyUp(String JavaDoc script)
390     {
391         addAttribute ( "onKeyUp", script );
392     }
393 }
394
Popular Tags