1 24 25 package org.enhydra.xml.xhtml.dom.xerces; 26 27 import org.w3c.dom.Node ; 28 import org.w3c.dom.html.HTMLCollection; 29 import org.w3c.dom.html.HTMLElement; 30 import org.w3c.dom.html.HTMLTableCaptionElement; 31 import org.w3c.dom.html.HTMLTableRowElement; 32 import org.w3c.dom.html.HTMLTableSectionElement; 33 34 public class XHTMLTableElementImpl 35 extends XHTMLElementImpl 36 implements org.enhydra.xml.xhtml.dom.XHTMLTableElement 37 { 38 39 public XHTMLTableElementImpl (XHTMLDocumentBase owner, String namespaceURI, String tagName) { 40 super( owner, namespaceURI, tagName); 41 } 42 43 public void setId (String newValue) { 44 setAttribute("id", newValue); 45 } 46 47 public String getId () { 48 return getAttribute ("id"); 49 } 50 public void setLang (String newValue) { 51 setAttribute("lang", newValue); 52 } 53 54 public String getLang () { 55 return getAttribute ("lang"); 56 } 57 public void setDir (String newValue) { 58 setAttribute("dir", newValue); 59 } 60 61 public String getDir () { 62 return getAttribute ("dir"); 63 } 64 public void setClassName (String newValue) { 65 setAttribute("class", newValue); 66 } 67 68 public String getClassName () { 69 return getAttribute ("class"); 70 } 71 public void setTitle (String newValue) { 72 setAttribute("title", newValue); 73 } 74 75 public String getTitle () { 76 return getAttribute ("title"); 77 } 78 public void setAlign (String newValue) { 79 setAttribute("align", newValue); 80 } 81 82 public String getAlign () { 83 return getAttribute ("align"); 84 } 85 public void setWidth (String newValue) { 86 setAttribute("width", newValue); 87 } 88 89 public String getWidth () { 90 return getAttribute ("width"); 91 } 92 public void setBgColor (String newValue) { 93 setAttribute("bgcolor", newValue); 94 } 95 96 public String getBgColor () { 97 return getAttribute ("bgcolor"); 98 } 99 public void setBorder (String newValue) { 100 setAttribute("border", newValue); 101 } 102 103 public String getBorder () { 104 return getAttribute ("border"); 105 } 106 public void setCellPadding (String newValue) { 107 setAttribute("cellpadding", newValue); 108 } 109 110 public String getCellPadding () { 111 return getAttribute ("cellpadding"); 112 } 113 public void setCellSpacing (String newValue) { 114 setAttribute("cellspacing", newValue); 115 } 116 117 public String getCellSpacing () { 118 return getAttribute ("cellspacing"); 119 } 120 public void setFrame (String newValue) { 121 setAttribute("frame", newValue); 122 } 123 124 public String getFrame () { 125 return getAttribute ("frame"); 126 } 127 public void setRules (String newValue) { 128 setAttribute("rules", newValue); 129 } 130 131 public String getRules () { 132 return getAttribute ("rules"); 133 } 134 public void setSummary (String newValue) { 135 setAttribute("summary", newValue); 136 } 137 138 public String getSummary () { 139 return getAttribute ("summary"); 140 } 141 public void setOnKeyUp (String newValue) { 142 setAttribute("onkeyup", newValue); 143 } 144 145 public String getOnKeyUp () { 146 return getAttribute ("onkeyup"); 147 } 148 public void setStyle (String newValue) { 149 setAttribute("style", newValue); 150 } 151 152 public String getStyle () { 153 return getAttribute ("style"); 154 } 155 public void setOnMouseDown (String newValue) { 156 setAttribute("onmousedown", newValue); 157 } 158 159 public String getOnMouseDown () { 160 return getAttribute ("onmousedown"); 161 } 162 public void setOnKeyPress (String newValue) { 163 setAttribute("onkeypress", newValue); 164 } 165 166 public String getOnKeyPress () { 167 return getAttribute ("onkeypress"); 168 } 169 public void setOnDblClick (String newValue) { 170 setAttribute("ondblclick", newValue); 171 } 172 173 public String getOnDblClick () { 174 return getAttribute ("ondblclick"); 175 } 176 public void setOnKeyDown (String newValue) { 177 setAttribute("onkeydown", newValue); 178 } 179 180 public String getOnKeyDown () { 181 return getAttribute ("onkeydown"); 182 } 183 public void setOnMouseMove (String newValue) { 184 setAttribute("onmousemove", newValue); 185 } 186 187 public String getOnMouseMove () { 188 return getAttribute ("onmousemove"); 189 } 190 public void setOnMouseUp (String newValue) { 191 setAttribute("onmouseup", newValue); 192 } 193 194 public String getOnMouseUp () { 195 return getAttribute ("onmouseup"); 196 } 197 public void setXmlLang (String newValue) { 198 setAttribute("xml:lang", newValue); 199 } 200 201 public String getXmlLang () { 202 return getAttribute ("xml:lang"); 203 } 204 public void setOnMouseOut (String newValue) { 205 setAttribute("onmouseout", newValue); 206 } 207 208 public String getOnMouseOut () { 209 return getAttribute ("onmouseout"); 210 } 211 public void setOnClick (String newValue) { 212 setAttribute("onclick", newValue); 213 } 214 215 public String getOnClick () { 216 return getAttribute ("onclick"); 217 } 218 public void setOnMouseOver (String newValue) { 219 setAttribute("onmouseover", newValue); 220 } 221 222 public String getOnMouseOver () { 223 return getAttribute ("onmouseover"); 224 } 225 ; 226 227 228 public synchronized HTMLTableCaptionElement getCaption() { 229 Node child; 230 231 child = getFirstChild(); 232 while ( child != null ) { 233 if ( child instanceof HTMLTableCaptionElement && 234 child.getNodeName().equals( "CAPTION" ) ) 235 return (HTMLTableCaptionElement) child; 236 child = child.getNextSibling(); 237 } 238 return null; 239 } 240 241 242 public synchronized void setCaption( HTMLTableCaptionElement caption ) 243 { 244 if ( caption != null && ! caption.getTagName().equals( "CAPTION" ) ) 245 throw new IllegalArgumentException ( "HTM016 Argument 'caption' is not an element of type <CAPTION>." ); 246 deleteCaption(); 247 if ( caption != null ) 248 appendChild( caption ); 249 } 250 251 252 public synchronized HTMLElement createCaption() { 253 HTMLElement section; 254 255 section = getCaption(); 256 if ( section != null ) 257 return section; 258 section = new XHTMLTableCaptionElementImpl( (XHTMLDocumentBase) getOwnerDocument(), getNamespaceURI(), "CAPTION" ); 259 appendChild( section ); 260 return section; 261 } 262 263 public synchronized void deleteCaption() { 264 Node old; 265 266 old = getCaption(); 267 if ( old != null ) 268 removeChild ( old ); 269 } 270 271 public synchronized HTMLTableSectionElement getTHead() { 272 Node child; 273 274 child = getFirstChild(); 275 while ( child != null ) { 276 if ( child instanceof HTMLTableSectionElement && 277 child.getNodeName().equals( "THEAD" ) ) 278 return (HTMLTableSectionElement) child; 279 child = child.getNextSibling(); 280 } 281 return null; 282 } 283 284 public synchronized void setTHead( HTMLTableSectionElement tHead ) { 285 if ( tHead != null && ! tHead.getTagName().equals( "THEAD" ) ) 286 throw new IllegalArgumentException ( "HTM017 Argument 'tHead' is not an element of type <THEAD>." ); 287 deleteTHead(); 288 if ( tHead != null ) 289 appendChild( tHead ); 290 } 291 292 public synchronized HTMLElement createTHead() { 293 HTMLElement section; 294 295 section = getTHead(); 296 if ( section != null ) 297 return section; 298 section = new XHTMLTableSectionElementImpl( (XHTMLDocumentBase) getOwnerDocument(), getNamespaceURI(), "THEAD" ); 299 appendChild( section ); 300 return section; 301 } 302 303 304 public synchronized void deleteTHead() { 305 Node old; 306 307 old = getTHead(); 308 if ( old != null ) 309 removeChild ( old ); 310 } 311 312 public synchronized HTMLTableSectionElement getTFoot() { 313 Node child; 314 315 child = getFirstChild(); 316 while ( child != null ) 317 { 318 if ( child instanceof HTMLTableSectionElement && 319 child.getNodeName().equals( "tfoot" ) ) 320 return (HTMLTableSectionElement) child; 321 child = child.getNextSibling(); 322 } 323 return null; 324 } 325 326 327 public synchronized void setTFoot( HTMLTableSectionElement tFoot ) { 328 if ( tFoot != null && ! tFoot.getTagName().equals( "tfoot" ) ) 329 throw new IllegalArgumentException ( "HTM018 Argument 'tFoot' is not an element of type <TFOOT>." ); 330 deleteTFoot(); 331 if ( tFoot != null ) 332 appendChild( tFoot ); 333 } 334 335 336 public synchronized HTMLElement createTFoot() { 337 HTMLElement section; 338 339 section = getTFoot(); 340 if ( section != null ) 341 return section; 342 section = new XHTMLTableSectionElementImpl( (XHTMLDocumentBase) getOwnerDocument(), getNamespaceURI(), "TFOOT" ); 343 appendChild( section ); 344 return section; 345 } 346 347 348 public synchronized void deleteTFoot() { 349 Node old; 350 351 old = getTFoot(); 352 if ( old != null ) 353 removeChild ( old ); 354 } 355 356 public HTMLCollection getRows() { 357 if ( _rows == null ) 358 _rows = new XHTMLCollectionImpl( this, XHTMLCollectionImpl.ROW ); 359 return _rows; 360 } 361 362 363 public HTMLCollection getTBodies() { 364 if ( _bodies == null ) 365 _bodies = new XHTMLCollectionImpl( this, XHTMLCollectionImpl.TBODY ); 366 return _bodies; 367 } 368 369 public HTMLElement insertRow( int index ) { 370 XHTMLTableRowElementImpl newRow; 371 372 newRow = new XHTMLTableRowElementImpl( (XHTMLDocumentBase) getOwnerDocument(), getNamespaceURI(), "TR" ); 373 insertRowX( index, newRow ); 375 return newRow; 376 } 377 378 379 void insertRowX( int index, XHTMLTableRowElementImpl newRow ) { 380 Node child; 381 Node lastSection = null; 382 383 child = getFirstChild(); 384 while ( child != null ) { 385 if ( child instanceof HTMLTableRowElement ) { 386 if ( index == 0 ) { 387 insertBefore( newRow, child ); 388 return; 389 } 390 } else if ( child instanceof XHTMLTableSectionElementImpl ) { 391 lastSection = child; 392 index = ( (XHTMLTableSectionElementImpl) child ).insertRowX( index, newRow ); 393 if ( index < 0 ) 394 return; 395 } 396 child = child.getNextSibling(); 397 } 398 if ( lastSection != null ) 399 lastSection.appendChild( newRow ); 400 else 401 appendChild( newRow ); 402 } 403 404 405 public synchronized void deleteRow( int index ) { 406 Node child; 407 408 child = getFirstChild(); 409 while ( child != null ) { 410 if ( child instanceof HTMLTableRowElement ) { 411 if ( index == 0 ) { 412 removeChild ( child ); 413 return; 414 } 415 } else if ( child instanceof XHTMLTableSectionElementImpl ) { 416 index = ( (XHTMLTableSectionElementImpl) child ).deleteRowX( index ); 417 if ( index < 0 ) 418 return; 419 } 420 child = child.getNextSibling(); 421 } 422 } 423 424 private XHTMLCollectionImpl _rows; 425 426 private XHTMLCollectionImpl _bodies; 427 428 ; 429 } 430 431 432 | Popular Tags |