KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * org/ozone-db/xml/dom/html/HTMLTableCellElementImpl.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.HTMLTableCellElement;
28 import org.w3c.dom.html.HTMLTableRowElement;
29
30
31 /**
32  * @version $Revision: 1.2 $ $Date: 2003/11/20 23:18:42 $
33  * @author <a HREF="mailto:arkin@trendline.co.il">Assaf Arkin</a>
34  * @see org.w3c.dom.html.HTMLTableCellElement
35  * @see ElementImpl
36  */

37 public final class HTMLTableCellElementImpl extends HTMLElementImpl implements HTMLTableCellElement {
38
39
40     public int getCellIndex() {
41         Node JavaDoc parent;
42         Node JavaDoc child;
43         int index;
44
45         parent = getParentNode();
46         index = 0;
47         if (parent instanceof HTMLTableRowElement) {
48             child = parent.getFirstChild();
49             while (child != null) {
50                 if (child instanceof HTMLTableCellElement) {
51                     if (child == this) {
52                         return index;
53                     }
54                     ++index;
55                 }
56                 child = child.getNextSibling();
57             }
58         }
59         return -1;
60     }
61
62
63     public void setCellIndex( int cellIndex ) {
64         Node JavaDoc parent;
65         Node JavaDoc child;
66
67         parent = getParentNode();
68         if (parent instanceof HTMLTableRowElement) {
69             child = parent.getFirstChild();
70             while (child != null) {
71                 if (child instanceof HTMLTableCellElement) {
72                     if (cellIndex == 0) {
73                         if (this != child) {
74                             parent.insertBefore( this, child );
75                         }
76                         return;
77                     }
78                     --cellIndex;
79                 }
80                 child = child.getNextSibling();
81             }
82         }
83         parent.appendChild( this );
84     }
85
86
87     public String JavaDoc getAbbr() {
88         return getAttribute( "abbr" );
89     }
90
91
92     public void setAbbr( String JavaDoc abbr ) {
93         setAttribute( "abbr", abbr );
94     }
95
96
97     public String JavaDoc getAlign() {
98         return capitalize( getAttribute( "align" ) );
99     }
100
101
102     public void setAlign( String JavaDoc align ) {
103         setAttribute( "align", align );
104     }
105
106
107     public String JavaDoc getAxis() {
108         return getAttribute( "axis" );
109     }
110
111
112     public void setAxis( String JavaDoc axis ) {
113         setAttribute( "axis", axis );
114     }
115
116
117     public String JavaDoc getBgColor() {
118         return getAttribute( "bgcolor" );
119     }
120
121
122     public void setBgColor( String JavaDoc bgColor ) {
123         setAttribute( "bgcolor", bgColor );
124     }
125
126
127     public String JavaDoc getCh() {
128         String JavaDoc ch;
129
130         // Make sure that the access key is a single character.
131
ch = getAttribute( "char" );
132         if (ch != null && ch.length() > 1) {
133             ch = ch.substring( 0, 1 );
134         }
135         return ch;
136     }
137
138
139     public void setCh( String JavaDoc ch ) {
140         // Make sure that the access key is a single character.
141
if (ch != null && ch.length() > 1) {
142             ch = ch.substring( 0, 1 );
143         }
144         setAttribute( "char", ch );
145     }
146
147
148     public String JavaDoc getChOff() {
149         return getAttribute( "charoff" );
150     }
151
152
153     public void setChOff( String JavaDoc chOff ) {
154         setAttribute( "charoff", chOff );
155     }
156
157
158     public int getColSpan() {
159         return toInteger( getAttribute( "colspan" ) );
160     }
161
162
163     public void setColSpan( int colspan ) {
164         setAttribute( "colspan", String.valueOf( colspan ) );
165     }
166
167
168     public String JavaDoc getHeaders() {
169         return getAttribute( "headers" );
170     }
171
172
173     public void setHeaders( String JavaDoc headers ) {
174         setAttribute( "headers", headers );
175     }
176
177
178     public String JavaDoc getHeight() {
179         return getAttribute( "height" );
180     }
181
182
183     public void setHeight( String JavaDoc height ) {
184         setAttribute( "height", height );
185     }
186
187
188     public boolean getNoWrap() {
189         return getAttribute( "nowrap" ) != null;
190     }
191
192
193     public void setNoWrap( boolean noWrap ) {
194         setAttribute( "nowrap", noWrap ? "" : null );
195     }
196
197
198     public int getRowSpan() {
199         return toInteger( getAttribute( "rowspan" ) );
200     }
201
202
203     public void setRowSpan( int rowspan ) {
204         setAttribute( "rowspan", String.valueOf( rowspan ) );
205     }
206
207
208     public String JavaDoc getScope() {
209         return getAttribute( "scope" );
210     }
211
212
213     public void setScope( String JavaDoc scope ) {
214         setAttribute( "scope", scope );
215     }
216
217
218     public String JavaDoc getVAlign() {
219         return capitalize( getAttribute( "valign" ) );
220     }
221
222
223     public void setVAlign( String JavaDoc vAlign ) {
224         setAttribute( "valign", vAlign );
225     }
226
227
228     public String JavaDoc getWidth() {
229         return getAttribute( "width" );
230     }
231
232
233     public void setWidth( String JavaDoc width ) {
234         setAttribute( "width", width );
235     }
236
237
238     /**
239      * Constructor requires owner document.
240      *
241      * @param owner The owner HTML document
242      */

243     public HTMLTableCellElementImpl( HTMLDocumentImpl owner, String JavaDoc name ) {
244         super( owner, "TD" );
245     }
246
247
248 }
249
Popular Tags