KickJava   Java API By Example, From Geeks To Geeks.

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


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.HTMLTableCellElement;
20 import org.w3c.dom.html.HTMLTableRowElement;
21
22 /**
23  * @xerces.internal
24  * @version $Revision: 1.9 $ $Date: 2005/04/18 01:20:21 $
25  * @author <a HREF="mailto:arkin@exoffice.com">Assaf Arkin</a>
26  * @see org.w3c.dom.html.HTMLTableCellElement
27  * @see org.apache.xerces.dom.ElementImpl
28  */

29 public class HTMLTableCellElementImpl
30     extends HTMLElementImpl
31     implements HTMLTableCellElement
32 {
33
34     private static final long serialVersionUID = 3256722862214820152L;
35
36     public int getCellIndex()
37     {
38         Node JavaDoc parent;
39         Node JavaDoc child;
40         int index;
41         
42         parent = getParentNode();
43         index = 0;
44         if ( parent instanceof HTMLTableRowElement )
45         {
46             child = parent.getFirstChild();
47             while ( child != null )
48             {
49                 if ( child instanceof HTMLTableCellElement )
50                 {
51                     if ( child == this )
52                         return index;
53                     ++ index;
54                 }
55                 child = child.getNextSibling();
56             }
57         }
58         return -1;
59     }
60     
61     
62     public void setCellIndex( int cellIndex )
63     {
64         Node JavaDoc parent;
65         Node JavaDoc child;
66         int index;
67         
68         parent = getParentNode();
69         if ( parent instanceof HTMLTableRowElement )
70         {
71             child = parent.getFirstChild();
72             while ( child != null )
73             {
74                 if ( child instanceof HTMLTableCellElement )
75                 {
76                     if ( cellIndex == 0 )
77                     {
78                         if ( this != child )
79                             parent.insertBefore( this, child );
80                         return;
81                     }
82                     -- cellIndex;
83                 }
84                 child = child.getNextSibling();
85             }
86         }
87         parent.appendChild( this );
88     }
89
90   
91     public String JavaDoc getAbbr()
92     {
93         return getAttribute( "abbr" );
94     }
95     
96     
97     public void setAbbr( String JavaDoc abbr )
98     {
99         setAttribute( "abbr", abbr );
100     }
101
102   
103     public String JavaDoc getAlign()
104     {
105         return capitalize( getAttribute( "align" ) );
106     }
107     
108     
109     public void setAlign( String JavaDoc align )
110     {
111         setAttribute( "align", align );
112     }
113   
114     
115     public String JavaDoc getAxis()
116     {
117         return getAttribute( "axis" );
118     }
119     
120     
121     public void setAxis( String JavaDoc axis )
122     {
123         setAttribute( "axis", axis );
124     }
125     
126     public String JavaDoc getBgColor()
127     {
128         return getAttribute( "bgcolor" );
129     }
130     
131     
132     public void setBgColor( String JavaDoc bgColor )
133     {
134         setAttribute( "bgcolor", bgColor );
135     }
136
137   
138     public String JavaDoc getCh()
139     {
140         String JavaDoc ch;
141         
142         // Make sure that the access key is a single character.
143
ch = getAttribute( "char" );
144         if ( ch != null && ch.length() > 1 )
145             ch = ch.substring( 0, 1 );
146         return ch;
147     }
148     
149     
150     public void setCh( String JavaDoc ch )
151     {
152         // Make sure that the access key is a single character.
153
if ( ch != null && ch.length() > 1 )
154             ch = ch.substring( 0, 1 );
155         setAttribute( "char", ch );
156     }
157
158     
159     public String JavaDoc getChOff()
160     {
161         return getAttribute( "charoff" );
162     }
163     
164     
165     public void setChOff( String JavaDoc chOff )
166     {
167         setAttribute( "charoff", chOff );
168     }
169   
170   
171     public int getColSpan()
172     {
173         return getInteger( getAttribute( "colspan" ) );
174     }
175     
176     
177     public void setColSpan( int colspan )
178     {
179         setAttribute( "colspan", String.valueOf( colspan ) );
180     }
181     
182     
183     public String JavaDoc getHeaders()
184     {
185         return getAttribute( "headers" );
186     }
187     
188     
189     public void setHeaders( String JavaDoc headers )
190     {
191         setAttribute( "headers", headers );
192     }
193   
194   
195     public String JavaDoc getHeight()
196     {
197         return getAttribute( "height" );
198     }
199     
200     
201     public void setHeight( String JavaDoc height )
202     {
203         setAttribute( "height", height );
204     }
205
206   
207       public boolean getNoWrap()
208     {
209         return getBinary( "nowrap" );
210     }
211     
212     
213     public void setNoWrap( boolean noWrap )
214     {
215         setAttribute( "nowrap", noWrap );
216     }
217
218     public int getRowSpan()
219     {
220         return getInteger( getAttribute( "rowspan" ) );
221     }
222     
223     
224     public void setRowSpan( int rowspan )
225     {
226         setAttribute( "rowspan", String.valueOf( rowspan ) );
227     }
228   
229     
230     public String JavaDoc getScope()
231     {
232         return getAttribute( "scope" );
233     }
234     
235     
236     public void setScope( String JavaDoc scope )
237     {
238         setAttribute( "scope", scope );
239     }
240   
241   
242     public String JavaDoc getVAlign()
243     {
244         return capitalize( getAttribute( "valign" ) );
245     }
246     
247     
248     public void setVAlign( String JavaDoc vAlign )
249     {
250         setAttribute( "valign", vAlign );
251     }
252
253   
254       public String JavaDoc getWidth()
255     {
256         return getAttribute( "width" );
257     }
258     
259     
260     public void setWidth( String JavaDoc width )
261     {
262         setAttribute( "width", width );
263     }
264
265     
266     /**
267      * Constructor requires owner document.
268      *
269      * @param owner The owner HTML document
270      */

271     public HTMLTableCellElementImpl( HTMLDocumentImpl owner, String JavaDoc name )
272     {
273         super( owner, name );
274     }
275
276   
277 }
278
279
Popular Tags