1 16 package org.apache.html.dom; 17 18 import org.w3c.dom.Node ; 19 import org.w3c.dom.html.HTMLTableCellElement; 20 import org.w3c.dom.html.HTMLTableRowElement; 21 22 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 parent; 39 Node 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 parent; 65 Node 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 getAbbr() 92 { 93 return getAttribute( "abbr" ); 94 } 95 96 97 public void setAbbr( String abbr ) 98 { 99 setAttribute( "abbr", abbr ); 100 } 101 102 103 public String getAlign() 104 { 105 return capitalize( getAttribute( "align" ) ); 106 } 107 108 109 public void setAlign( String align ) 110 { 111 setAttribute( "align", align ); 112 } 113 114 115 public String getAxis() 116 { 117 return getAttribute( "axis" ); 118 } 119 120 121 public void setAxis( String axis ) 122 { 123 setAttribute( "axis", axis ); 124 } 125 126 public String getBgColor() 127 { 128 return getAttribute( "bgcolor" ); 129 } 130 131 132 public void setBgColor( String bgColor ) 133 { 134 setAttribute( "bgcolor", bgColor ); 135 } 136 137 138 public String getCh() 139 { 140 String ch; 141 142 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 ch ) 151 { 152 if ( ch != null && ch.length() > 1 ) 154 ch = ch.substring( 0, 1 ); 155 setAttribute( "char", ch ); 156 } 157 158 159 public String getChOff() 160 { 161 return getAttribute( "charoff" ); 162 } 163 164 165 public void setChOff( String 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 getHeaders() 184 { 185 return getAttribute( "headers" ); 186 } 187 188 189 public void setHeaders( String headers ) 190 { 191 setAttribute( "headers", headers ); 192 } 193 194 195 public String getHeight() 196 { 197 return getAttribute( "height" ); 198 } 199 200 201 public void setHeight( String 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 getScope() 231 { 232 return getAttribute( "scope" ); 233 } 234 235 236 public void setScope( String scope ) 237 { 238 setAttribute( "scope", scope ); 239 } 240 241 242 public String getVAlign() 243 { 244 return capitalize( getAttribute( "valign" ) ); 245 } 246 247 248 public void setVAlign( String vAlign ) 249 { 250 setAttribute( "valign", vAlign ); 251 } 252 253 254 public String getWidth() 255 { 256 return getAttribute( "width" ); 257 } 258 259 260 public void setWidth( String width ) 261 { 262 setAttribute( "width", width ); 263 } 264 265 266 271 public HTMLTableCellElementImpl( HTMLDocumentImpl owner, String name ) 272 { 273 super( owner, name ); 274 } 275 276 277 } 278 279 | Popular Tags |