KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > html > dom > HTMLTableSectionElementImpl


1 /*
2  * Copyright 1999,2000,2004,2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.html.dom;
17
18 import org.w3c.dom.Node JavaDoc;
19 import org.w3c.dom.html.HTMLCollection;
20 import org.w3c.dom.html.HTMLElement;
21 import org.w3c.dom.html.HTMLTableRowElement;
22 import org.w3c.dom.html.HTMLTableSectionElement;
23
24 /**
25  * @xerces.internal
26  * @version $Revision: 1.10 $ $Date: 2005/04/18 01:20:21 $
27  * @author <a HREF="mailto:arkin@exoffice.com">Assaf Arkin</a>
28  * @see org.w3c.dom.html.HTMLTableSectionElement
29  * @see org.apache.xerces.dom.ElementImpl
30  */

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

168     public Node JavaDoc cloneNode( boolean deep ) {
169         HTMLTableSectionElementImpl clonedNode = (HTMLTableSectionElementImpl)super.cloneNode( deep );
170         clonedNode._rows = null;
171         return clonedNode;
172     }
173     
174     /**
175      * Constructor requires owner document.
176      *
177      * @param owner The owner HTML document
178      */

179     public HTMLTableSectionElementImpl( HTMLDocumentImpl owner, String JavaDoc name )
180     {
181         super( owner, name );
182     }
183
184   
185     private HTMLCollectionImpl _rows;
186
187
188 }
189
190
Popular Tags