37 |
|
|
38 |
package gnu.xml.dom.html2; |
package gnu.xml.dom.html2; |
39 |
|
|
40 |
|
import gnu.xml.dom.DomDOMException; |
41 |
|
import org.w3c.dom.DOMException; |
42 |
|
import org.w3c.dom.Node; |
43 |
import org.w3c.dom.html2.HTMLCollection; |
import org.w3c.dom.html2.HTMLCollection; |
44 |
import org.w3c.dom.html2.HTMLElement; |
import org.w3c.dom.html2.HTMLElement; |
45 |
import org.w3c.dom.html2.HTMLTableSectionElement; |
import org.w3c.dom.html2.HTMLTableSectionElement; |
112 |
|
|
113 |
public HTMLElement insertRow(int index) |
public HTMLElement insertRow(int index) |
114 |
{ |
{ |
115 |
// TODO |
Node ref = getRow(index); |
116 |
return null; |
Node row = getOwnerDocument().createElement("tr"); |
117 |
|
if (ref == null) |
118 |
|
{ |
119 |
|
appendChild(row); |
120 |
|
} |
121 |
|
else |
122 |
|
{ |
123 |
|
insertBefore(row, ref); |
124 |
|
} |
125 |
|
return (HTMLElement) row; |
126 |
} |
} |
127 |
|
|
128 |
public void deleteRow(int index) |
public void deleteRow(int index) |
129 |
{ |
{ |
130 |
// TODO |
Node ref = getRow(index); |
131 |
|
if (ref == null) |
132 |
|
{ |
133 |
|
throw new DomDOMException(DOMException.INDEX_SIZE_ERR); |
134 |
|
} |
135 |
|
removeChild(ref); |
136 |
|
} |
137 |
|
|
138 |
|
Node getRow(final int index) |
139 |
|
{ |
140 |
|
int i = 0; |
141 |
|
for (Node ctx = getFirstChild(); ctx != null; |
142 |
|
ctx = ctx.getNextSibling()) |
143 |
|
{ |
144 |
|
if (!"tr".equalsIgnoreCase(ctx.getLocalName())) |
145 |
|
{ |
146 |
|
continue; |
147 |
|
} |
148 |
|
if (index == i) |
149 |
|
{ |
150 |
|
return ctx; |
151 |
|
} |
152 |
|
i++; |
153 |
|
} |
154 |
|
return null; |
155 |
} |
} |
156 |
|
|
157 |
} |
} |