1 57 package org.enhydra.apache.html.dom; 58 59 60 import org.enhydra.apache.xerces.dom.ElementImpl; 61 import org.w3c.dom.Node ; 62 import org.w3c.dom.html.HTMLTableCellElement; 63 import org.w3c.dom.html.HTMLTableRowElement; 64 65 66 72 public class HTMLTableCellElementImpl 73 extends HTMLElementImpl 74 implements HTMLTableCellElement 75 { 76 77 78 public int getCellIndex() 79 { 80 Node parent; 81 Node 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 parent; 107 Node 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 getAbbr() 134 { 135 return getAttribute( "abbr" ); 136 } 137 138 139 public void setAbbr( String abbr ) 140 { 141 setAttribute( "abbr", abbr ); 142 } 143 144 145 public String getAlign() 146 { 147 return capitalize( getAttribute( "align" ) ); 148 } 149 150 151 public void setAlign( String align ) 152 { 153 setAttribute( "align", align ); 154 } 155 156 157 public String getAxis() 158 { 159 return getAttribute( "axis" ); 160 } 161 162 163 public void setAxis( String axis ) 164 { 165 setAttribute( "axis", axis ); 166 } 167 168 public String getBgColor() 169 { 170 return getAttribute( "bgcolor" ); 171 } 172 173 174 public void setBgColor( String bgColor ) 175 { 176 setAttribute( "bgcolor", bgColor ); 177 } 178 179 180 public String getCh() 181 { 182 String ch; 183 184 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 ch ) 193 { 194 if ( ch != null && ch.length() > 1 ) 196 ch = ch.substring( 0, 1 ); 197 setAttribute( "char", ch ); 198 } 199 200 201 public String getChOff() 202 { 203 return getAttribute( "charoff" ); 204 } 205 206 207 public void setChOff( String 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 getHeaders() 226 { 227 return getAttribute( "headers" ); 228 } 229 230 231 public void setHeaders( String headers ) 232 { 233 setAttribute( "headers", headers ); 234 } 235 236 237 public String getHeight() 238 { 239 return getAttribute( "height" ); 240 } 241 242 243 public void setHeight( String 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 getScope() 273 { 274 return getAttribute( "scope" ); 275 } 276 277 278 public void setScope( String scope ) 279 { 280 setAttribute( "scope", scope ); 281 } 282 283 284 public String getVAlign() 285 { 286 return capitalize( getAttribute( "valign" ) ); 287 } 288 289 290 public void setVAlign( String vAlign ) 291 { 292 setAttribute( "valign", vAlign ); 293 } 294 295 296 public String getWidth() 297 { 298 return getAttribute( "width" ); 299 } 300 301 302 public void setWidth( String width ) 303 { 304 setAttribute( "width", width ); 305 } 306 307 308 313 public HTMLTableCellElementImpl( HTMLDocumentImpl owner, String name ) 314 { 315 super( owner, name ); 316 } 317 318 319 } 320 321 | Popular Tags |