KickJava   Java API By Example, From Geeks To Geeks.

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


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.HTMLTableCellElement;
62 import org.w3c.dom.html.HTMLTableRowElement;
63
64
65 /**
66  * @version $Revision: 1.6 $ $Date: 2003/05/08 20:13:09 $
67  * @author <a HREF="mailto:arkin@exoffice.com">Assaf Arkin</a>
68  * @see org.w3c.dom.html.HTMLTableCellElement
69  * @see com.sun.org.apache.xerces.internal.dom.ElementImpl
70  */

71 public class HTMLTableCellElementImpl
72     extends HTMLElementImpl
73     implements HTMLTableCellElement
74 {
75     
76
77     public int getCellIndex()
78     {
79         Node JavaDoc parent;
80         Node JavaDoc child;
81         int index;
82         
83         parent = getParentNode();
84         index = 0;
85         if ( parent instanceof HTMLTableRowElement )
86         {
87             child = parent.getFirstChild();
88             while ( child != null )
89             {
90                 if ( child instanceof HTMLTableCellElement )
91                 {
92                     if ( child == this )
93                         return index;
94                     ++ index;
95                 }
96                 child = child.getNextSibling();
97             }
98         }
99         return -1;
100     }
101     
102     
103     public void setCellIndex( int cellIndex )
104     {
105         Node JavaDoc parent;
106         Node JavaDoc child;
107         int index;
108         
109         parent = getParentNode();
110         if ( parent instanceof HTMLTableRowElement )
111         {
112             child = parent.getFirstChild();
113             while ( child != null )
114             {
115                 if ( child instanceof HTMLTableCellElement )
116                 {
117                     if ( cellIndex == 0 )
118                     {
119                         if ( this != child )
120                             parent.insertBefore( this, child );
121                         return;
122                     }
123                     -- cellIndex;
124                 }
125                 child = child.getNextSibling();
126             }
127         }
128         parent.appendChild( this );
129     }
130
131   
132     public String JavaDoc getAbbr()
133     {
134         return getAttribute( "abbr" );
135     }
136     
137     
138     public void setAbbr( String JavaDoc abbr )
139     {
140         setAttribute( "abbr", abbr );
141     }
142
143   
144     public String JavaDoc getAlign()
145     {
146         return capitalize( getAttribute( "align" ) );
147     }
148     
149     
150     public void setAlign( String JavaDoc align )
151     {
152         setAttribute( "align", align );
153     }
154   
155     
156     public String JavaDoc getAxis()
157     {
158         return getAttribute( "axis" );
159     }
160     
161     
162     public void setAxis( String JavaDoc axis )
163     {
164         setAttribute( "axis", axis );
165     }
166     
167     public String JavaDoc getBgColor()
168     {
169         return getAttribute( "bgcolor" );
170     }
171     
172     
173     public void setBgColor( String JavaDoc bgColor )
174     {
175         setAttribute( "bgcolor", bgColor );
176     }
177
178   
179     public String JavaDoc getCh()
180     {
181         String JavaDoc ch;
182         
183         // Make sure that the access key is a single character.
184
ch = getAttribute( "char" );
185         if ( ch != null && ch.length() > 1 )
186             ch = ch.substring( 0, 1 );
187         return ch;
188     }
189     
190     
191     public void setCh( String JavaDoc ch )
192     {
193         // Make sure that the access key is a single character.
194
if ( ch != null && ch.length() > 1 )
195             ch = ch.substring( 0, 1 );
196         setAttribute( "char", ch );
197     }
198
199     
200     public String JavaDoc getChOff()
201     {
202         return getAttribute( "charoff" );
203     }
204     
205     
206     public void setChOff( String JavaDoc chOff )
207     {
208         setAttribute( "charoff", chOff );
209     }
210   
211   
212     public int getColSpan()
213     {
214         return getInteger( getAttribute( "colspan" ) );
215     }
216     
217     
218     public void setColSpan( int colspan )
219     {
220         setAttribute( "colspan", String.valueOf( colspan ) );
221     }
222     
223     
224     public String JavaDoc getHeaders()
225     {
226         return getAttribute( "headers" );
227     }
228     
229     
230     public void setHeaders( String JavaDoc headers )
231     {
232         setAttribute( "headers", headers );
233     }
234   
235   
236     public String JavaDoc getHeight()
237     {
238         return getAttribute( "height" );
239     }
240     
241     
242     public void setHeight( String JavaDoc height )
243     {
244         setAttribute( "height", height );
245     }
246
247   
248       public boolean getNoWrap()
249     {
250         return getBinary( "nowrap" );
251     }
252     
253     
254     public void setNoWrap( boolean noWrap )
255     {
256         setAttribute( "nowrap", noWrap );
257     }
258
259     public int getRowSpan()
260     {
261         return getInteger( getAttribute( "rowspan" ) );
262     }
263     
264     
265     public void setRowSpan( int rowspan )
266     {
267         setAttribute( "rowspan", String.valueOf( rowspan ) );
268     }
269   
270     
271     public String JavaDoc getScope()
272     {
273         return getAttribute( "scope" );
274     }
275     
276     
277     public void setScope( String JavaDoc scope )
278     {
279         setAttribute( "scope", scope );
280     }
281   
282   
283     public String JavaDoc getVAlign()
284     {
285         return capitalize( getAttribute( "valign" ) );
286     }
287     
288     
289     public void setVAlign( String JavaDoc vAlign )
290     {
291         setAttribute( "valign", vAlign );
292     }
293
294   
295       public String JavaDoc getWidth()
296     {
297         return getAttribute( "width" );
298     }
299     
300     
301     public void setWidth( String JavaDoc width )
302     {
303         setAttribute( "width", width );
304     }
305
306     
307     /**
308      * Constructor requires owner document.
309      *
310      * @param owner The owner HTML document
311      */

312     public HTMLTableCellElementImpl( HTMLDocumentImpl owner, String JavaDoc name )
313     {
314         super( owner, name );
315     }
316
317   
318 }
319
320
Popular Tags