KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > html > internal > dom > HTMLTableSectionElementImpl


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 1999,2000 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
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
18  * distribution.
19  *
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.
26  *
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.
31  *
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.
35  *
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
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
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/>.
56  */

57 package com.sun.org.apache.html.internal.dom;
58
59
60 import org.w3c.dom.Node JavaDoc;
61 import org.w3c.dom.html.HTMLCollection;
62 import org.w3c.dom.html.HTMLElement;
63 import org.w3c.dom.html.HTMLTableRowElement;
64 import org.w3c.dom.html.HTMLTableSectionElement;
65
66
67 /**
68  * @version $Revision: 1.6 $ $Date: 2003/05/08 20:13:09 $
69  * @author <a HREF="mailto:arkin@exoffice.com">Assaf Arkin</a>
70  * @see org.w3c.dom.html.HTMLTableSectionElement
71  * @see com.sun.org.apache.xerces.internal.dom.ElementImpl
72  */

73 public class HTMLTableSectionElementImpl
74     extends HTMLElementImpl
75     implements HTMLTableSectionElement
76 {
77     
78     
79     public String JavaDoc getAlign()
80     {
81         return capitalize( getAttribute( "align" ) );
82     }
83     
84     
85     public void setAlign( String JavaDoc align )
86     {
87         setAttribute( "align", align );
88     }
89       
90     
91     public String JavaDoc getCh()
92     {
93         String JavaDoc ch;
94         
95         // Make sure that the access key is a single character.
96
ch = getAttribute( "char" );
97         if ( ch != null && ch.length() > 1 )
98             ch = ch.substring( 0, 1 );
99         return ch;
100     }
101     
102     
103     public void setCh( String JavaDoc ch )
104     {
105         // Make sure that the access key is a single character.
106
if ( ch != null && ch.length() > 1 )
107             ch = ch.substring( 0, 1 );
108         setAttribute( "char", ch );
109     }
110
111     
112     public String JavaDoc getChOff()
113     {
114         return getAttribute( "charoff" );
115     }
116     
117     
118     public void setChOff( String JavaDoc chOff )
119     {
120         setAttribute( "charoff", chOff );
121     }
122   
123   
124     public String JavaDoc getVAlign()
125     {
126         return capitalize( getAttribute( "valign" ) );
127     }
128     
129     
130     public void setVAlign( String JavaDoc vAlign )
131     {
132         setAttribute( "valign", vAlign );
133     }
134
135     
136     public HTMLCollection getRows()
137     {
138         if ( _rows == null )
139             _rows = new HTMLCollectionImpl( this, HTMLCollectionImpl.ROW );
140         return _rows;
141     }
142     
143     
144     public HTMLElement insertRow( int index )
145     {
146         HTMLTableRowElementImpl newRow;
147         
148         newRow = new HTMLTableRowElementImpl( (HTMLDocumentImpl) getOwnerDocument(), "TR" );
149         newRow.insertCell( 0 );
150         if ( insertRowX( index, newRow ) >= 0 )
151             appendChild( newRow );
152         return newRow;
153     }
154     
155     
156     int insertRowX( int index, HTMLTableRowElementImpl newRow )
157     {
158         Node JavaDoc child;
159         
160         child = getFirstChild();
161         while ( child != null )
162         {
163             if ( child instanceof HTMLTableRowElement )
164             {
165                 if ( index == 0 )
166                 {
167                     insertBefore( newRow, child );
168                     return -1;
169                 }
170                 --index;
171             }
172             child = child.getNextSibling();
173         }
174         return index;
175     }
176
177     
178     public void deleteRow( int index )
179     {
180         deleteRowX( index );
181     }
182
183     
184     int deleteRowX( int index )
185     {
186         Node JavaDoc child;
187         
188         child = getFirstChild();
189         while ( child != null )
190         {
191             if ( child instanceof HTMLTableRowElement )
192             {
193                 if ( index == 0 )
194                 {
195                     removeChild ( child );
196                     return -1;
197                 }
198                 --index;
199             }
200             child = child.getNextSibling();
201         }
202         return index;
203     }
204
205     
206     /**
207      * Constructor requires owner document.
208      *
209      * @param owner The owner HTML document
210      */

211     public HTMLTableSectionElementImpl( HTMLDocumentImpl owner, String JavaDoc name )
212     {
213         super( owner, name );
214     }
215
216   
217     private HTMLCollectionImpl _rows;
218
219
220 }
221
222
Popular Tags