1 20 21 22 package org.ozoneDB.xml.dom.html; 23 24 25 import org.ozoneDB.xml.dom.ElementImpl; 26 import org.w3c.dom.Node ; 27 import org.w3c.dom.NodeList ; 28 import org.w3c.dom.html.*; 29 30 31 37 public final class HTMLTableRowElementImpl extends HTMLElementImpl implements HTMLTableRowElement { 38 39 40 public int getRowIndex() { 41 Node parent; 42 43 parent = getParentNode(); 44 if (parent instanceof HTMLTableSectionElement) { 45 parent = parent.getParentNode(); 46 } 47 if (parent instanceof HTMLTableElement) { 48 return getRowIndex( parent ); 49 } 50 ; 51 return -1; 52 } 53 54 55 public void setRowIndex( int rowIndex ) { 56 Node parent; 57 58 parent = getParentNode(); 59 if (parent instanceof HTMLTableSectionElement) { 60 parent = parent.getParentNode(); 61 } 62 if (parent instanceof HTMLTableElement) { 63 ((HTMLTableElementImpl)parent).insertRowX( rowIndex, this ); 64 } 65 } 66 67 68 public int getSectionRowIndex() { 69 Node parent; 70 71 parent = getParentNode(); 72 if (parent instanceof HTMLTableSectionElement) { 73 return getRowIndex( parent ); 74 } else { 75 return -1; 76 } 77 } 78 79 80 public void setSectionRowIndex( int sectionRowIndex ) { 81 Node parent; 82 83 parent = getParentNode(); 84 if (parent instanceof HTMLTableSectionElement) { 85 ((HTMLTableSectionElementImpl)parent).insertRowX( sectionRowIndex, this ); 86 } 87 } 88 89 90 int getRowIndex( Node parent ) { 91 NodeList rows; 92 int i; 93 94 rows = ((HTMLElement)parent).getElementsByTagName( "TR" ); 98 for (i = 0; i < rows.getLength(); ++i) { 99 if (rows.item( i ) == this) { 100 return i; 101 } 102 } 103 return -1; 104 } 105 106 107 public HTMLCollection getCells() { 108 if (_cells == null) { 109 _cells = new HTMLCollectionImpl( this, HTMLCollectionImpl.CELL ); 110 } 111 return _cells; 112 } 113 114 115 public void setCells( HTMLCollection cells ) { 116 Node child; 117 int i; 118 119 child = getFirstChild(); 120 while (child != null) { 121 removeChild( child ); 122 child = child.getNextSibling(); 123 } 124 i = 0; 125 child = cells.item( i ); 126 while (child != null) { 127 appendChild( child ); 128 ++i; 129 child = cells.item( i ); 130 } 131 } 132 133 134 public HTMLElement insertCell( int index ) { 135 Node child; 136 HTMLElement newCell; 137 138 newCell = new HTMLTableCellElementImpl( (HTMLDocumentImpl)getOwnerDocument(), "TD" ); 139 child = getFirstChild(); 140 while (child != null) { 141 if (child instanceof HTMLTableCellElement) { 142 if (index == 0) { 143 insertBefore( newCell, child ); 144 return newCell; 145 } 146 --index; 147 } 148 child = child.getNextSibling(); 149 } 150 appendChild( newCell ); 151 return newCell; 152 } 153 154 155 public void deleteCell( int index ) { 156 Node child; 157 158 child = getFirstChild(); 159 while (child != null) { 160 if (child instanceof HTMLTableCellElement) { 161 if (index == 0) { 162 removeChild( child ); 163 return; 164 } 165 --index; 166 } 167 child = child.getNextSibling(); 168 } 169 } 170 171 172 public String getAlign() { 173 return capitalize( getAttribute( "align" ) ); 174 } 175 176 177 public void setAlign( String align ) { 178 setAttribute( "align", align ); 179 } 180 181 182 public String getBgColor() { 183 return getAttribute( "bgcolor" ); 184 } 185 186 187 public void setBgColor( String bgColor ) { 188 setAttribute( "bgcolor", bgColor ); 189 } 190 191 192 public String getCh() { 193 String ch; 194 195 ch = getAttribute( "char" ); 197 if (ch != null && ch.length() > 1) { 198 ch = ch.substring( 0, 1 ); 199 } 200 return ch; 201 } 202 203 204 public void setCh( String ch ) { 205 if (ch != null && ch.length() > 1) { 207 ch = ch.substring( 0, 1 ); 208 } 209 setAttribute( "char", ch ); 210 } 211 212 213 public String getChOff() { 214 return getAttribute( "charoff" ); 215 } 216 217 218 public void setChOff( String chOff ) { 219 setAttribute( "charoff", chOff ); 220 } 221 222 223 public String getVAlign() { 224 return capitalize( getAttribute( "valign" ) ); 225 } 226 227 228 public void setVAlign( String vAlign ) { 229 setAttribute( "valign", vAlign ); 230 } 231 232 233 238 public HTMLTableRowElementImpl( HTMLDocumentImpl owner, String name ) { 239 super( owner, "TR" ); 240 } 241 242 243 HTMLCollection _cells; 244 245 246 } 247 | Popular Tags |