KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > xml > dom > html > HTMLTableSectionElementImpl


1 /**
2  * org/ozone-db/xml/dom/html/HTMLTableSectionElementImpl.java
3  *
4  * The contents of this file are subject to the OpenXML Public
5  * License Version 1.0; you may not use this file except in compliance
6  * with the License. You may obtain a copy of the License at
7  * http://www.openxml.org/license.html
8  *
9  * THIS SOFTWARE IS DISTRIBUTED ON AN "AS IS" BASIS WITHOUT WARRANTY
10  * OF ANY KIND, EITHER EXPRESSED OR IMPLIED. THE INITIAL DEVELOPER
11  * AND ALL CONTRIBUTORS SHALL NOT BE LIABLE FOR ANY DAMAGES AS A
12  * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
13  * DERIVATIVES. SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING
14  * RIGHTS AND LIMITATIONS UNDER THE LICENSE.
15  *
16  * The Initial Developer of this code under the License is Assaf Arkin.
17  * Portions created by Assaf Arkin are Copyright (C) 1998, 1999.
18  * All Rights Reserved.
19  */

20
21
22 package org.ozoneDB.xml.dom.html;
23
24
25 import org.ozoneDB.xml.dom.ElementImpl;
26 import org.w3c.dom.Node JavaDoc;
27 import org.w3c.dom.html.HTMLCollection;
28 import org.w3c.dom.html.HTMLElement;
29 import org.w3c.dom.html.HTMLTableRowElement;
30 import org.w3c.dom.html.HTMLTableSectionElement;
31
32
33 /**
34  * @version $Revision: 1.2 $ $Date: 2003/11/20 23:18:42 $
35  * @author <a HREF="mailto:arkin@trendline.co.il">Assaf Arkin</a>
36  * @see org.w3c.dom.html.HTMLTableSectionElement
37  * @see ElementImpl
38  */

39 public final class HTMLTableSectionElementImpl extends HTMLElementImpl implements HTMLTableSectionElement {
40
41
42     public String JavaDoc getAlign() {
43         return capitalize( getAttribute( "align" ) );
44     }
45
46
47     public void setAlign( String JavaDoc align ) {
48         setAttribute( "align", align );
49     }
50
51
52     public String JavaDoc getCh() {
53         String JavaDoc ch;
54
55         // Make sure that the access key is a single character.
56
ch = getAttribute( "char" );
57         if (ch != null && ch.length() > 1) {
58             ch = ch.substring( 0, 1 );
59         }
60         return ch;
61     }
62
63
64     public void setCh( String JavaDoc ch ) {
65         // Make sure that the access key is a single character.
66
if (ch != null && ch.length() > 1) {
67             ch = ch.substring( 0, 1 );
68         }
69         setAttribute( "char", ch );
70     }
71
72
73     public String JavaDoc getChOff() {
74         return getAttribute( "charoff" );
75     }
76
77
78     public void setChOff( String JavaDoc chOff ) {
79         setAttribute( "charoff", chOff );
80     }
81
82
83     public String JavaDoc getVAlign() {
84         return capitalize( getAttribute( "valign" ) );
85     }
86
87
88     public void setVAlign( String JavaDoc vAlign ) {
89         setAttribute( "valign", vAlign );
90     }
91
92
93     public HTMLCollection getRows() {
94         if (_rows == null) {
95             _rows = new HTMLCollectionImpl( this, HTMLCollectionImpl.ROW );
96         }
97         return _rows;
98     }
99
100
101     public HTMLElement insertRow( int index ) {
102         HTMLTableRowElementImpl newRow;
103
104         newRow = new HTMLTableRowElementImpl( (HTMLDocumentImpl)getOwnerDocument(), "TR" );
105         newRow.insertCell( 0 );
106         if (insertRowX( index, newRow ) >= 0) {
107             appendChild( newRow );
108         }
109         return newRow;
110     }
111
112
113     int insertRowX( int index, HTMLTableRowElementImpl newRow ) {
114         Node JavaDoc child;
115
116         child = getFirstChild();
117         while (child != null) {
118             if (child instanceof HTMLTableRowElement) {
119                 if (index == 0) {
120                     insertBefore( newRow, child );
121                     return -1;
122                 }
123                 --index;
124             }
125             child = child.getNextSibling();
126         }
127         return index;
128     }
129
130
131     public void deleteRow( int index ) {
132         deleteRowX( index );
133     }
134
135
136     int deleteRowX( int index ) {
137         Node JavaDoc child;
138
139         child = getFirstChild();
140         while (child != null) {
141             if (child instanceof HTMLTableRowElement) {
142                 if (index == 0) {
143                     removeChild( child );
144                     return -1;
145                 }
146                 --index;
147             }
148             child = child.getNextSibling();
149         }
150         return index;
151     }
152
153
154     /**
155      * Constructor requires owner document.
156      *
157      * @param owner The owner HTML document
158      */

159     public HTMLTableSectionElementImpl( HTMLDocumentImpl owner, String JavaDoc section ) {
160         super( owner, section );
161     }
162
163
164     private HTMLCollectionImpl _rows;
165
166
167 }
168
Popular Tags