KickJava   Java API By Example, From Geeks To Geeks.

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


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;th&gt; object.
64     @version $Id: th.java,v 1.2 2003/04/27 09:36:17 rdonkin Exp $
65     @author <a HREF="mailto:snagy@servletapi.com">Stephan Nagy</a>
66     @author <a HREF="mailto:jon@clearink.com">Jon S. Stevens</a>
67     @author <a HREF="mailto:bojan@binarix.com">Bojan Smojver</a>
68 */

69 public class th extends MultiPartElement implements Printable, MouseEvents, KeyEvents
70 {
71     /**
72         private initializer.
73     */

74     {
75         setElementType("th");
76         setCase(LOWERCASE);
77         setAttributeQuote(true);
78     }
79
80     /**
81         Basic constructor. Use set* methods.
82     */

83     public th()
84     {
85     }
86
87     /**
88         Basic Constructor use set* methods.
89     */

90     public th(Element element)
91     {
92         addElement(element);
93     }
94
95     /**
96         Basic Constructor use set* methods.
97     */

98     public th(String JavaDoc element)
99     {
100         addElement(element);
101     }
102
103     /*
104         Basic Constructor use set* methods.
105         @param close. Print the closing tag or not.
106      *
107     public th(boolean close)
108     {
109         setNeedClosingTag(close);
110     }*/

111
112     /**
113         Sets the abbr="" attribute.
114         @param cdata sets the abbr="" attribute.
115     */

116     public th setAbbr(String JavaDoc cdata)
117     {
118         addAttribute("abbr",cdata);
119         return(this);
120     }
121
122     /**
123         Sets the axis="" attribute
124         @param cdata sets the axis="" attribute
125     */

126     public th setAxis(String JavaDoc cdata)
127     {
128         addAttribute("axis",cdata);
129         return(this);
130     }
131
132     /**
133         Sets the axes="" attribute
134         @param id_refs list of id's for header cells
135     */

136     public th setAxes(String JavaDoc id_refs)
137     {
138         addAttribute("axes",id_refs);
139         return(this);
140     }
141
142     /**
143         Sets the rowspan="" attribute
144         @param span number of rows spaned by cell
145     */

146     public th setRowSpan(int span)
147     {
148         addAttribute("rowspan",Integer.toString(span));
149         return(this);
150     }
151
152     /**
153         Sets the rowspan="" attribute
154         @param span number of rows spaned by cell
155     */

156     public th setRowSpan(String JavaDoc span)
157     {
158         addAttribute("rowspan",span);
159         return(this);
160     }
161
162     /**
163         Sets the colspan="" attribute
164         @param span number of columns spanned by cell
165     */

166     public th setColSpan(int span)
167     {
168         addAttribute("colspan",Integer.toString(span));
169         return(this);
170     }
171
172     /**
173         Sets the colspan="" attribute
174         @param span number of columns spanned by cell
175     */

176     public th setColSpan(String JavaDoc span)
177     {
178         addAttribute("colspan",span);
179         return(this);
180     }
181
182     /**
183         Sets word wrap on or off.
184         @param wrap turn word wrap on or off.
185     */

186     public th setNoWrap(boolean wrap)
187     {
188         if ( wrap == true )
189             addAttribute("nowrap", "nowrap");
190         else
191             removeAttribute("nowrap");
192
193         return(this);
194     }
195
196     /**
197         Supplies user agents with a recommended cell width. (Pixel Values)
198         @param width how many pixels to make cell
199     */

200     public th setWidth(int width)
201     {
202         addAttribute("width",Integer.toString(width));
203         return(this);
204     }
205     
206     /**
207         Supplies user agents with a recommended cell width. (Pixel Values)
208         @param width how many pixels to make cell
209     */

210     public th setWidth(String JavaDoc width)
211     {
212         addAttribute("width",width);
213         return(this);
214     }
215
216     /**
217         Supplies user agents with a recommended cell height. (Pixel Values)
218         @param height how many pixels to make cell
219     */

220     public th setHeight(int height)
221     {
222         addAttribute("height",Integer.toString(height));
223         return(this);
224     }
225
226     /**
227         Supplies user agents with a recommended cell height. (Pixel Values)
228         @param height how many pixels to make cell
229     */

230     public th setHeight(String JavaDoc height)
231     {
232         addAttribute("height",height);
233         return(this);
234     }
235
236     /**
237         Sets the align="" attribute convience variables are provided in the AlignType interface
238         @param align Sets the align="" attribute
239     */

240     public th setAlign(String JavaDoc align)
241     {
242         addAttribute("align",align);
243         return(this);
244     }
245
246     /**
247         Sets the valign="" attribute convience variables are provided in the AlignType interface
248         @param valign Sets the valign="" attribute
249     */

250     public th setVAlign(String JavaDoc valign)
251     {
252         addAttribute("valign",valign);
253         return(this);
254     }
255
256     /**
257         Sets the char="" attribute.
258         @param character the character to use for alignment.
259     */

260     public th setChar(String JavaDoc character)
261     {
262         addAttribute("char",character);
263         return(this);
264     }
265
266     /**
267         Sets the charoff="" attribute.
268         @param char_off When present this attribute specifies the offset
269         of the first occurrence of the alignment character on each line.
270     */

271     public th setCharOff(int char_off)
272     {
273         addAttribute("charoff",Integer.toString(char_off));
274         return(this);
275     }
276
277     /**
278         Sets the charoff="" attribute.
279         @param char_off When present this attribute specifies the offset
280         of the first occurrence of the alignment character on each line.
281     */

282     public th setCharOff(String JavaDoc char_off)
283     {
284         addAttribute("charoff",char_off);
285         return(this);
286     }
287
288     /**
289         Sets the bgcolor="" attribute
290         @param color sets the background color of the cell.
291     */

292     public th setBgColor(String JavaDoc color)
293     {
294         addAttribute("bgcolor",HtmlColor.convertColor(color));
295         return(this);
296     }
297
298     /**
299         Sets the lang="" and xml:lang="" attributes
300         @param lang the lang="" and xml:lang="" attributes
301     */

302     public Element setLang(String JavaDoc lang)
303     {
304         addAttribute("lang",lang);
305         addAttribute("xml:lang",lang);
306         return this;
307     }
308
309     /**
310         Adds an Element to the element.
311         @param hashcode name of element for hash table
312         @param element Adds an Element to the element.
313      */

314     public th addElement(String JavaDoc hashcode,Element element)
315     {
316         addElementToRegistry(hashcode,element);
317         return(this);
318     }
319
320     /**
321         Adds an Element to the element.
322         @param hashcode name of element for hash table
323         @param element Adds an Element to the element.
324      */

325     public th addElement(String JavaDoc hashcode,String JavaDoc element)
326     {
327         addElementToRegistry(hashcode,element);
328         return(this);
329     }
330
331     /**
332         Adds an Element to the element.
333         @param element Adds an Element to the element.
334      */

335     public th addElement(Element element)
336     {
337         addElementToRegistry(element);
338         return(this);
339     }
340
341     /**
342         Adds an Element to the element.
343         @param element Adds an Element to the element.
344      */

345     public th addElement(String JavaDoc element)
346     {
347         addElementToRegistry(element);
348         return(this);
349     }
350     /**
351         Removes an Element from the element.
352         @param hashcode the name of the element to be removed.
353     */

354     public th removeElement(String JavaDoc hashcode)
355     {
356         removeElementFromRegistry(hashcode);
357         return(this);
358     }
359
360     /**
361         The onclick event occurs when the pointing device button is clicked
362         over an element. This attribute may be used with most elements.
363         
364         @param The script
365     */

366     public void setOnClick(String JavaDoc script)
367     {
368         addAttribute ( "onclick", script );
369     }
370     /**
371         The ondblclick event occurs when the pointing device button is double
372         clicked over an element. This attribute may be used with most elements.
373
374         @param The script
375     */

376     public void setOnDblClick(String JavaDoc script)
377     {
378         addAttribute ( "ondblclick", script );
379     }
380     /**
381         The onmousedown event occurs when the pointing device button is pressed
382         over an element. This attribute may be used with most elements.
383
384         @param The script
385     */

386     public void setOnMouseDown(String JavaDoc script)
387     {
388         addAttribute ( "onmousedown", script );
389     }
390     /**
391         The onmouseup event occurs when the pointing device button is released
392         over an element. This attribute may be used with most elements.
393
394         @param The script
395     */

396     public void setOnMouseUp(String JavaDoc script)
397     {
398         addAttribute ( "onmouseup", script );
399     }
400     /**
401         The onmouseover event occurs when the pointing device is moved onto an
402         element. This attribute may be used with most elements.
403
404         @param The script
405     */

406     public void setOnMouseOver(String JavaDoc script)
407     {
408         addAttribute ( "onmouseover", script );
409     }
410     /**
411         The onmousemove event occurs when the pointing device is moved while it
412         is over an element. This attribute may be used with most elements.
413
414         @param The script
415     */

416     public void setOnMouseMove(String JavaDoc script)
417     {
418         addAttribute ( "onmousemove", script );
419     }
420     /**
421         The onmouseout event occurs when the pointing device is moved away from
422         an element. This attribute may be used with most elements.
423
424         @param The script
425     */

426     public void setOnMouseOut(String JavaDoc script)
427     {
428         addAttribute ( "onmouseout", script );
429     }
430
431     /**
432         The onkeypress event occurs when a key is pressed and released over an
433         element. This attribute may be used with most elements.
434         
435         @param The script
436     */

437     public void setOnKeyPress(String JavaDoc script)
438     {
439         addAttribute ( "onkeypress", script );
440     }
441
442     /**
443         The onkeydown event occurs when a key is pressed down over an element.
444         This attribute may be used with most elements.
445         
446         @param The script
447     */

448     public void setOnKeyDown(String JavaDoc script)
449     {
450         addAttribute ( "onkeydown", script );
451     }
452
453     /**
454         The onkeyup event occurs when a key is released over an element. This
455         attribute may be used with most elements.
456         
457         @param The script
458     */

459     public void setOnKeyUp(String JavaDoc script)
460     {
461         addAttribute ( "onkeyup", script );
462     }
463 }
464
Popular Tags