1 16 package org.apache.html.dom; 17 18 import org.w3c.dom.Node ; 19 import org.w3c.dom.html.HTMLCollection; 20 import org.w3c.dom.html.HTMLElement; 21 import org.w3c.dom.html.HTMLTableRowElement; 22 import org.w3c.dom.html.HTMLTableSectionElement; 23 24 31 public class HTMLTableSectionElementImpl 32 extends HTMLElementImpl 33 implements HTMLTableSectionElement 34 { 35 36 private static final long serialVersionUID = 3257001042984973618L; 37 38 public String getAlign() 39 { 40 return capitalize( getAttribute( "align" ) ); 41 } 42 43 44 public void setAlign( String align ) 45 { 46 setAttribute( "align", align ); 47 } 48 49 50 public String getCh() 51 { 52 String ch; 53 54 ch = getAttribute( "char" ); 56 if ( ch != null && ch.length() > 1 ) 57 ch = ch.substring( 0, 1 ); 58 return ch; 59 } 60 61 62 public void setCh( String ch ) 63 { 64 if ( ch != null && ch.length() > 1 ) 66 ch = ch.substring( 0, 1 ); 67 setAttribute( "char", ch ); 68 } 69 70 71 public String getChOff() 72 { 73 return getAttribute( "charoff" ); 74 } 75 76 77 public void setChOff( String chOff ) 78 { 79 setAttribute( "charoff", chOff ); 80 } 81 82 83 public String getVAlign() 84 { 85 return capitalize( getAttribute( "valign" ) ); 86 } 87 88 89 public void setVAlign( String vAlign ) 90 { 91 setAttribute( "valign", vAlign ); 92 } 93 94 95 public HTMLCollection getRows() 96 { 97 if ( _rows == null ) 98 _rows = new HTMLCollectionImpl( this, HTMLCollectionImpl.ROW ); 99 return _rows; 100 } 101 102 103 public HTMLElement insertRow( int index ) 104 { 105 HTMLTableRowElementImpl newRow; 106 107 newRow = new HTMLTableRowElementImpl( (HTMLDocumentImpl) getOwnerDocument(), "TR" ); 108 newRow.insertCell( 0 ); 109 if ( insertRowX( index, newRow ) >= 0 ) 110 appendChild( newRow ); 111 return newRow; 112 } 113 114 115 int insertRowX( int index, HTMLTableRowElementImpl newRow ) 116 { 117 Node child; 118 119 child = getFirstChild(); 120 while ( child != null ) 121 { 122 if ( child instanceof HTMLTableRowElement ) 123 { 124 if ( index == 0 ) 125 { 126 insertBefore( newRow, child ); 127 return -1; 128 } 129 --index; 130 } 131 child = child.getNextSibling(); 132 } 133 return index; 134 } 135 136 137 public void deleteRow( int index ) 138 { 139 deleteRowX( index ); 140 } 141 142 143 int deleteRowX( int index ) 144 { 145 Node child; 146 147 child = getFirstChild(); 148 while ( child != null ) 149 { 150 if ( child instanceof HTMLTableRowElement ) 151 { 152 if ( index == 0 ) 153 { 154 removeChild ( child ); 155 return -1; 156 } 157 --index; 158 } 159 child = child.getNextSibling(); 160 } 161 return index; 162 } 163 164 168 public Node cloneNode( boolean deep ) { 169 HTMLTableSectionElementImpl clonedNode = (HTMLTableSectionElementImpl)super.cloneNode( deep ); 170 clonedNode._rows = null; 171 return clonedNode; 172 } 173 174 179 public HTMLTableSectionElementImpl( HTMLDocumentImpl owner, String name ) 180 { 181 super( owner, name ); 182 } 183 184 185 private HTMLCollectionImpl _rows; 186 187 188 } 189 190 | Popular Tags |