KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > xml > xhtml > dom > xerces > XHTMLTableElementImpl


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Original Code is DigitalSesame
15  * Portions created by DigitalSesame are Copyright (C) 1997-2000 DigitalSesame
16  * All Rights Reserved.
17  *
18  * Contributor(s):
19  * Rex Tsai <chihchun@digitalsesame.com>
20  * David Li <david@digitalsesam.com>
21  *
22  * $Id: XHTMLTableElementImpl.java,v 1.2 2005/01/26 08:29:24 jkjome Exp $
23  */

24
25 package org.enhydra.xml.xhtml.dom.xerces;
26
27 import org.w3c.dom.Node JavaDoc;
28 import org.w3c.dom.html.HTMLCollection;
29 import org.w3c.dom.html.HTMLElement;
30 import org.w3c.dom.html.HTMLTableCaptionElement;
31 import org.w3c.dom.html.HTMLTableRowElement;
32 import org.w3c.dom.html.HTMLTableSectionElement;
33
34 public class XHTMLTableElementImpl
35     extends XHTMLElementImpl
36     implements org.enhydra.xml.xhtml.dom.XHTMLTableElement
37 {
38
39     public XHTMLTableElementImpl (XHTMLDocumentBase owner, String JavaDoc namespaceURI, String JavaDoc tagName) {
40     super( owner, namespaceURI, tagName);
41     }
42
43         public void setId (String JavaDoc newValue) {
44     setAttribute("id", newValue);
45     }
46
47     public String JavaDoc getId () {
48     return getAttribute ("id");
49     }
50     public void setLang (String JavaDoc newValue) {
51     setAttribute("lang", newValue);
52     }
53
54     public String JavaDoc getLang () {
55     return getAttribute ("lang");
56     }
57     public void setDir (String JavaDoc newValue) {
58     setAttribute("dir", newValue);
59     }
60
61     public String JavaDoc getDir () {
62     return getAttribute ("dir");
63     }
64     public void setClassName (String JavaDoc newValue) {
65     setAttribute("class", newValue);
66     }
67
68     public String JavaDoc getClassName () {
69     return getAttribute ("class");
70     }
71     public void setTitle (String JavaDoc newValue) {
72     setAttribute("title", newValue);
73     }
74
75     public String JavaDoc getTitle () {
76     return getAttribute ("title");
77     }
78     public void setAlign (String JavaDoc newValue) {
79     setAttribute("align", newValue);
80     }
81
82     public String JavaDoc getAlign () {
83     return getAttribute ("align");
84     }
85     public void setWidth (String JavaDoc newValue) {
86     setAttribute("width", newValue);
87     }
88
89     public String JavaDoc getWidth () {
90     return getAttribute ("width");
91     }
92     public void setBgColor (String JavaDoc newValue) {
93     setAttribute("bgcolor", newValue);
94     }
95
96     public String JavaDoc getBgColor () {
97     return getAttribute ("bgcolor");
98     }
99     public void setBorder (String JavaDoc newValue) {
100     setAttribute("border", newValue);
101     }
102
103     public String JavaDoc getBorder () {
104     return getAttribute ("border");
105     }
106     public void setCellPadding (String JavaDoc newValue) {
107     setAttribute("cellpadding", newValue);
108     }
109
110     public String JavaDoc getCellPadding () {
111     return getAttribute ("cellpadding");
112     }
113     public void setCellSpacing (String JavaDoc newValue) {
114     setAttribute("cellspacing", newValue);
115     }
116
117     public String JavaDoc getCellSpacing () {
118     return getAttribute ("cellspacing");
119     }
120     public void setFrame (String JavaDoc newValue) {
121     setAttribute("frame", newValue);
122     }
123
124     public String JavaDoc getFrame () {
125     return getAttribute ("frame");
126     }
127     public void setRules (String JavaDoc newValue) {
128     setAttribute("rules", newValue);
129     }
130
131     public String JavaDoc getRules () {
132     return getAttribute ("rules");
133     }
134     public void setSummary (String JavaDoc newValue) {
135     setAttribute("summary", newValue);
136     }
137
138     public String JavaDoc getSummary () {
139     return getAttribute ("summary");
140     }
141     public void setOnKeyUp (String JavaDoc newValue) {
142     setAttribute("onkeyup", newValue);
143     }
144
145     public String JavaDoc getOnKeyUp () {
146     return getAttribute ("onkeyup");
147     }
148     public void setStyle (String JavaDoc newValue) {
149     setAttribute("style", newValue);
150     }
151
152     public String JavaDoc getStyle () {
153     return getAttribute ("style");
154     }
155     public void setOnMouseDown (String JavaDoc newValue) {
156     setAttribute("onmousedown", newValue);
157     }
158
159     public String JavaDoc getOnMouseDown () {
160     return getAttribute ("onmousedown");
161     }
162     public void setOnKeyPress (String JavaDoc newValue) {
163     setAttribute("onkeypress", newValue);
164     }
165
166     public String JavaDoc getOnKeyPress () {
167     return getAttribute ("onkeypress");
168     }
169     public void setOnDblClick (String JavaDoc newValue) {
170     setAttribute("ondblclick", newValue);
171     }
172
173     public String JavaDoc getOnDblClick () {
174     return getAttribute ("ondblclick");
175     }
176     public void setOnKeyDown (String JavaDoc newValue) {
177     setAttribute("onkeydown", newValue);
178     }
179
180     public String JavaDoc getOnKeyDown () {
181     return getAttribute ("onkeydown");
182     }
183     public void setOnMouseMove (String JavaDoc newValue) {
184     setAttribute("onmousemove", newValue);
185     }
186
187     public String JavaDoc getOnMouseMove () {
188     return getAttribute ("onmousemove");
189     }
190     public void setOnMouseUp (String JavaDoc newValue) {
191     setAttribute("onmouseup", newValue);
192     }
193
194     public String JavaDoc getOnMouseUp () {
195     return getAttribute ("onmouseup");
196     }
197     public void setXmlLang (String JavaDoc newValue) {
198     setAttribute("xml:lang", newValue);
199     }
200
201     public String JavaDoc getXmlLang () {
202     return getAttribute ("xml:lang");
203     }
204     public void setOnMouseOut (String JavaDoc newValue) {
205     setAttribute("onmouseout", newValue);
206     }
207
208     public String JavaDoc getOnMouseOut () {
209     return getAttribute ("onmouseout");
210     }
211     public void setOnClick (String JavaDoc newValue) {
212     setAttribute("onclick", newValue);
213     }
214
215     public String JavaDoc getOnClick () {
216     return getAttribute ("onclick");
217     }
218     public void setOnMouseOver (String JavaDoc newValue) {
219     setAttribute("onmouseover", newValue);
220     }
221
222     public String JavaDoc getOnMouseOver () {
223     return getAttribute ("onmouseover");
224     }
225 ;
226
227         
228     public synchronized HTMLTableCaptionElement getCaption() {
229         Node JavaDoc child;
230         
231         child = getFirstChild();
232         while ( child != null ) {
233             if ( child instanceof HTMLTableCaptionElement &&
234                  child.getNodeName().equals( "CAPTION" ) )
235                 return (HTMLTableCaptionElement) child;
236             child = child.getNextSibling();
237         }
238         return null;
239     }
240     
241     
242     public synchronized void setCaption( HTMLTableCaptionElement caption )
243     {
244         if ( caption != null && ! caption.getTagName().equals( "CAPTION" ) )
245             throw new IllegalArgumentException JavaDoc( "HTM016 Argument 'caption' is not an element of type <CAPTION>." );
246         deleteCaption();
247         if ( caption != null )
248             appendChild( caption );
249     }
250     
251     
252     public synchronized HTMLElement createCaption() {
253         HTMLElement section;
254         
255         section = getCaption();
256         if ( section != null )
257             return section;
258         section = new XHTMLTableCaptionElementImpl( (XHTMLDocumentBase) getOwnerDocument(), getNamespaceURI(), "CAPTION" );
259         appendChild( section );
260         return section;
261     }
262   
263     public synchronized void deleteCaption() {
264         Node JavaDoc old;
265         
266         old = getCaption();
267         if ( old != null )
268             removeChild ( old );
269     }
270     
271     public synchronized HTMLTableSectionElement getTHead() {
272         Node JavaDoc child;
273         
274         child = getFirstChild();
275         while ( child != null ) {
276             if ( child instanceof HTMLTableSectionElement &&
277                  child.getNodeName().equals( "THEAD" ) )
278                 return (HTMLTableSectionElement) child;
279             child = child.getNextSibling();
280         }
281         return null;
282     }
283     
284     public synchronized void setTHead( HTMLTableSectionElement tHead ) {
285         if ( tHead != null && ! tHead.getTagName().equals( "THEAD" ) )
286             throw new IllegalArgumentException JavaDoc( "HTM017 Argument 'tHead' is not an element of type <THEAD>." );
287         deleteTHead();
288         if ( tHead != null )
289             appendChild( tHead );
290     }
291     
292     public synchronized HTMLElement createTHead() {
293         HTMLElement section;
294         
295         section = getTHead();
296         if ( section != null )
297             return section;
298         section = new XHTMLTableSectionElementImpl( (XHTMLDocumentBase) getOwnerDocument(), getNamespaceURI(), "THEAD" );
299         appendChild( section );
300         return section;
301     }
302
303     
304     public synchronized void deleteTHead() {
305         Node JavaDoc old;
306         
307         old = getTHead();
308         if ( old != null )
309             removeChild ( old );
310     }
311     
312     public synchronized HTMLTableSectionElement getTFoot() {
313         Node JavaDoc child;
314         
315         child = getFirstChild();
316         while ( child != null )
317         {
318             if ( child instanceof HTMLTableSectionElement &&
319                  child.getNodeName().equals( "tfoot" ) )
320                 return (HTMLTableSectionElement) child;
321             child = child.getNextSibling();
322         }
323         return null;
324     }
325     
326     
327     public synchronized void setTFoot( HTMLTableSectionElement tFoot ) {
328         if ( tFoot != null && ! tFoot.getTagName().equals( "tfoot" ) )
329             throw new IllegalArgumentException JavaDoc( "HTM018 Argument 'tFoot' is not an element of type <TFOOT>." );
330         deleteTFoot();
331         if ( tFoot != null )
332             appendChild( tFoot );
333     }
334     
335     
336     public synchronized HTMLElement createTFoot() {
337         HTMLElement section;
338         
339         section = getTFoot();
340         if ( section != null )
341             return section;
342         section = new XHTMLTableSectionElementImpl( (XHTMLDocumentBase) getOwnerDocument(), getNamespaceURI(), "TFOOT" );
343         appendChild( section );
344         return section;
345     }
346
347     
348     public synchronized void deleteTFoot() {
349         Node JavaDoc old;
350         
351         old = getTFoot();
352         if ( old != null )
353             removeChild ( old );
354     }
355     
356     public HTMLCollection getRows() {
357         if ( _rows == null )
358             _rows = new XHTMLCollectionImpl( this, XHTMLCollectionImpl.ROW );
359         return _rows;
360     }
361     
362
363     public HTMLCollection getTBodies() {
364         if ( _bodies == null )
365             _bodies = new XHTMLCollectionImpl( this, XHTMLCollectionImpl.TBODY );
366         return _bodies;
367     }
368   
369     public HTMLElement insertRow( int index ) {
370         XHTMLTableRowElementImpl newRow;
371
372         newRow = new XHTMLTableRowElementImpl( (XHTMLDocumentBase) getOwnerDocument(), getNamespaceURI(), "TR" );
373         //newRow.insertCell( 0 );
374
insertRowX( index, newRow );
375         return newRow;
376     }
377         
378         
379     void insertRowX( int index, XHTMLTableRowElementImpl newRow ) {
380         Node JavaDoc child;
381         Node JavaDoc lastSection = null;
382                 
383         child = getFirstChild();
384         while ( child != null ) {
385             if ( child instanceof HTMLTableRowElement ) {
386                 if ( index == 0 ) {
387                     insertBefore( newRow, child );
388                     return;
389                 }
390             } else if ( child instanceof XHTMLTableSectionElementImpl ) {
391                 lastSection = child;
392                 index = ( (XHTMLTableSectionElementImpl) child ).insertRowX( index, newRow );
393                 if ( index < 0 )
394                     return;
395             }
396             child = child.getNextSibling();
397         }
398         if ( lastSection != null )
399             lastSection.appendChild( newRow );
400         else
401             appendChild( newRow );
402     }
403     
404     
405     public synchronized void deleteRow( int index ) {
406         Node JavaDoc child;
407         
408         child = getFirstChild();
409         while ( child != null ) {
410             if ( child instanceof HTMLTableRowElement ) {
411                 if ( index == 0 ) {
412                     removeChild ( child );
413                     return;
414                 }
415             } else if ( child instanceof XHTMLTableSectionElementImpl ) {
416                 index = ( (XHTMLTableSectionElementImpl) child ).deleteRowX( index );
417                 if ( index < 0 )
418                     return;
419             }
420             child = child.getNextSibling();
421         }
422     }
423
424     private XHTMLCollectionImpl _rows;
425     
426     private XHTMLCollectionImpl _bodies;
427
428 ;
429 }
430
431
432
Popular Tags