KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > apache > html > 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 org.enhydra.apache.html.dom;
58
59
60 import org.enhydra.apache.xerces.dom.ElementImpl;
61 import org.w3c.dom.Node JavaDoc;
62 import org.w3c.dom.html.HTMLTableCellElement;
63 import org.w3c.dom.html.HTMLTableRowElement;
64
65
66 /**
67  * @version $Revision: 1.2 $ $Date: 2005/01/26 08:28:44 $
68  * @author <a HREF="mailto:arkin@exoffice.com">Assaf Arkin</a>
69  * @see org.w3c.dom.html.HTMLTableCellElement
70  * @see ElementImpl
71  */

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

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