2
* The Apache Software License, Version 1.1
5
* Copyright (c) 1999,2000 The Apache Software Foundation. All rights
8
* Redistribution and use in source and binary forms, with or without
9
* modification, are permitted provided that the following conditions
12
* 1. Redistributions of source code must retain the above copyright
13
* notice, this list of conditions and the following disclaimer.
15
* 2. Redistributions in binary form must reproduce the above copyright
16
* notice, this list of conditions and the following disclaimer in
17
* the documentation and/or other materials provided with the
20
* 3. The end-user documentation included with the redistribution,
21
* if any, must include the following acknowledgment:
22
* "This product includes software developed by the
23
* Apache Software Foundation (http://www.apache.org/)."
24
* Alternately, this acknowledgment may appear in the software itself,
25
* if and wherever such third-party acknowledgments normally appear.
27
* 4. The names "Xerces" and "Apache Software Foundation" must
28
* not be used to endorse or promote products derived from this
29
* software without prior written permission. For written
30
* permission, please contact apache@apache.org.
32
* 5. Products derived from this software may not be called "Apache",
33
* nor may "Apache" appear in their name, without prior written
34
* permission of the Apache Software Foundation.
36
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48
* ====================================================================
50
* This software consists of voluntary contributions made by many
51
* individuals on behalf of the Apache Software Foundation and was
52
* originally based on software copyright (c) 1999, International
53
* Business Machines, Inc., http://www.apache.org. For more
54
* information on the Apache Software Foundation, please see
55
* <http://www.apache.org/>.
57
package org.apache.html.dom;
60
import org.w3c.dom.Node;
61
import org.w3c.dom.NodeList;
62
import org.w3c.dom.html.HTMLCollection;
63
import org.w3c.dom.html.HTMLElement;
64
import org.w3c.dom.html.HTMLTableCellElement;
65
import org.w3c.dom.html.HTMLTableElement;
66
import org.w3c.dom.html.HTMLTableRowElement;
67
import org.w3c.dom.html.HTMLTableSectionElement;
71
* @version $Revision: 1.6 $ $Date: 2003/05/08 20:13:09 $
72
* @author <a href="mailto:arkin@exoffice.com">Assaf Arkin</a>
73
* @see org.w3c.dom.html.HTMLTableRowElement
74
* @see org.apache.xerces.dom.ElementImpl
76
public class HTMLTableRowElementImpl
77
extends HTMLElementImpl
78
implements HTMLTableRowElement
82
public int getRowIndex()
86
parent = getParentNode();
87
if ( parent instanceof HTMLTableSectionElement )
88
parent = parent.getParentNode();
89
if ( parent instanceof HTMLTableElement )
90
return getRowIndex( parent );;
95
public void setRowIndex( int rowIndex )
99
parent = getParentNode();
100
if ( parent instanceof HTMLTableSectionElement )
101
parent = parent.getParentNode();
102
if ( parent instanceof HTMLTableElement )
103
( (HTMLTableElementImpl) parent ).insertRowX( rowIndex, this );
107
public int getSectionRowIndex()
111
parent = getParentNode();
112
if ( parent instanceof HTMLTableSectionElement )
113
return getRowIndex( parent );
119
public void setSectionRowIndex( int sectionRowIndex )
123
parent = getParentNode();
124
if ( parent instanceof HTMLTableSectionElement )
125
( (HTMLTableSectionElementImpl) parent ).insertRowX( sectionRowIndex, this );
129
int getRowIndex( Node parent )
134
// Use getElementsByTagName() which creates a snapshot of all the
135
// TR elements under the TABLE/section. Access to the returned NodeList
136
// is very fast and the snapshot solves many synchronization problems.
137
rows = ( (HTMLElement) parent ).getElementsByTagName( "TR" );
138
for ( i = 0 ; i < rows.getLength() ; ++i )
139
if ( rows.item( i ) == this )
145
public HTMLCollection getCells()
147
if ( _cells == null )
148
_cells = new HTMLCollectionImpl( this, HTMLCollectionImpl.CELL );
153
public void setCells( HTMLCollection cells )
158
child = getFirstChild();
159
while ( child != null )
161
removeChild( child );
162
child = child.getNextSibling();
165
child = cells.item( i );
166
while ( child != null )
168
appendChild ( child );
170
child = cells.item( i );
175
public HTMLElement insertCell( int index )
180
newCell = new HTMLTableCellElementImpl( (HTMLDocumentImpl) getOwnerDocument(), "TD" );
181
child = getFirstChild();
182
while ( child != null )
184
if ( child instanceof HTMLTableCellElement )
188
insertBefore( newCell, child );
193
child = child.getNextSibling();
195
appendChild( newCell );
200
public void deleteCell( int index )
204
child = getFirstChild();
205
while ( child != null )
207
if ( child instanceof HTMLTableCellElement )
211
removeChild ( child );
216
child = child.getNextSibling();
221
public String getAlign()
223
return capitalize( getAttribute( "align" ) );
227
public void setAlign( String align )
229
setAttribute( "align", align );
233
public String getBgColor()
235
return getAttribute( "bgcolor" );
239
public void setBgColor( String bgColor )
241
setAttribute( "bgcolor", bgColor );
245
public String getCh()
249
// Make sure that the access key is a single character.
250
ch = getAttribute( "char" );
251
if ( ch != null && ch.length() > 1 )
252
ch = ch.substring( 0, 1 );
257
public void setCh( String ch )
259
// Make sure that the access key is a single character.
260
if ( ch != null && ch.length() > 1 )
261
ch = ch.substring( 0, 1 );
262
setAttribute( "char", ch );
266
public String getChOff()
268
return getAttribute( "charoff" );
272
public void setChOff( String chOff )
274
setAttribute( "charoff", chOff );
278
public String getVAlign()
280
return capitalize( getAttribute( "valign" ) );
284
public void setVAlign( String vAlign )
286
setAttribute( "valign", vAlign );
291
* Constructor requires owner document.
293
* @param owner The owner HTML document
295
public HTMLTableRowElementImpl( HTMLDocumentImpl owner, String name )
297
super( owner, name );
301
HTMLCollection _cells;