1 57 package org.enhydra.xml.lazydom.html; 58 import org.enhydra.xml.lazydom.LazyElement; 59 import org.enhydra.xml.lazydom.LazyElementNoNS; 60 import org.w3c.dom.Node ; 61 import org.w3c.dom.html.HTMLCollection; 62 import org.w3c.dom.html.HTMLElement; 63 import org.w3c.dom.html.HTMLTableRowElement; 64 import org.w3c.dom.html.HTMLTableSectionElement; 65 66 67 73 public class HTMLTableSectionElementImpl 74 extends LazyHTMLElement 75 implements HTMLTableSectionElement 76 { 77 78 79 public String getAlign() 80 { 81 return capitalize( getAttribute( "align" ) ); 82 } 83 84 85 public void setAlign( String align ) 86 { 87 setAttribute( "align", align ); 88 } 89 90 91 public String getCh() 92 { 93 String ch; 94 95 ch = getAttribute( "char" ); 97 if ( ch != null && ch.length() > 1 ) 98 ch = ch.substring( 0, 1 ); 99 return ch; 100 } 101 102 103 public void setCh( String ch ) 104 { 105 if ( ch != null && ch.length() > 1 ) 107 ch = ch.substring( 0, 1 ); 108 setAttribute( "char", ch ); 109 } 110 111 112 public String getChOff() 113 { 114 return getAttribute( "charoff" ); 115 } 116 117 118 public void setChOff( String chOff ) 119 { 120 setAttribute( "charoff", chOff ); 121 } 122 123 124 public String getVAlign() 125 { 126 return capitalize( getAttribute( "valign" ) ); 127 } 128 129 130 public void setVAlign( String vAlign ) 131 { 132 setAttribute( "valign", vAlign ); 133 } 134 135 136 public HTMLCollection getRows() 137 { 138 if ( _rows == null ) 139 _rows = new HTMLCollectionImpl( this, HTMLCollectionImpl.ROW ); 140 return _rows; 141 } 142 143 144 public HTMLElement insertRow( int index ) 145 { 146 HTMLTableRowElementImpl newRow; 147 148 newRow = new HTMLTableRowElementImpl( (LazyHTMLDocument) getOwnerDocument(), null, "TR" ); 149 newRow.insertCell( 0 ); 150 if ( insertRowX( index, newRow ) >= 0 ) 151 appendChild( newRow ); 152 return newRow; 153 } 154 155 156 int insertRowX( int index, HTMLTableRowElementImpl newRow ) 157 { 158 Node child; 159 160 child = getFirstChild(); 161 while ( child != null ) 162 { 163 if ( child instanceof HTMLTableRowElement ) 164 { 165 if ( index == 0 ) 166 { 167 insertBefore( newRow, child ); 168 return -1; 169 } 170 --index; 171 } 172 child = child.getNextSibling(); 173 } 174 return index; 175 } 176 177 178 public void deleteRow( int index ) 179 { 180 deleteRowX( index ); 181 } 182 183 184 int deleteRowX( int index ) 185 { 186 Node child; 187 188 child = getFirstChild(); 189 while ( child != null ) 190 { 191 if ( child instanceof HTMLTableRowElement ) 192 { 193 if ( index == 0 ) 194 { 195 removeChild ( child ); 196 return -1; 197 } 198 --index; 199 } 200 child = child.getNextSibling(); 201 } 202 return index; 203 } 204 205 209 public Node cloneNode( boolean deep ) { 210 HTMLTableSectionElementImpl clonedNode = (HTMLTableSectionElementImpl)super.cloneNode( deep ); 211 clonedNode._rows = null; 212 return clonedNode; 213 } 214 215 220 public HTMLTableSectionElementImpl( LazyHTMLDocument owner, LazyElement template, String name ) 221 { 222 super( owner, template, name ); 223 } 224 225 226 private HTMLCollectionImpl _rows; 227 228 229 } 230 231 | Popular Tags |