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.HTMLTableRowElement; |
import org.w3c.dom.html2.HTMLTableRowElement; |
63 |
|
|
64 |
public int getRowIndex() |
public int getRowIndex() |
65 |
{ |
{ |
66 |
// TODO |
return getIndex(); |
|
return -1; |
|
67 |
} |
} |
68 |
|
|
69 |
public int getSectionRowIndex() |
public int getSectionRowIndex() |
70 |
{ |
{ |
71 |
// TODO |
int index = 0; |
72 |
return -1; |
DomHTMLElement parent = (DomHTMLElement) getParentElement("table"); |
73 |
|
if (parent != null) |
74 |
|
{ |
75 |
|
Node thead = parent.getChildElement("thead"); |
76 |
|
if (thead != null) |
77 |
|
{ |
78 |
|
for (Node ctx = thead.getFirstChild(); ctx != null; |
79 |
|
ctx = ctx.getNextSibling()) |
80 |
|
{ |
81 |
|
if (ctx == this) |
82 |
|
{ |
83 |
|
return index; |
84 |
|
} |
85 |
|
index++; |
86 |
|
} |
87 |
|
} |
88 |
|
Node tbody = parent.getChildElement("tbody"); |
89 |
|
if (tbody != null) |
90 |
|
{ |
91 |
|
for (Node ctx = tbody.getFirstChild(); ctx != null; |
92 |
|
ctx = ctx.getNextSibling()) |
93 |
|
{ |
94 |
|
if (ctx == this) |
95 |
|
{ |
96 |
|
return index; |
97 |
|
} |
98 |
|
index++; |
99 |
|
} |
100 |
|
} |
101 |
|
Node tfoot = parent.getChildElement("tfoot"); |
102 |
|
if (tfoot != null) |
103 |
|
{ |
104 |
|
for (Node ctx = tfoot.getFirstChild(); ctx != null; |
105 |
|
ctx = ctx.getNextSibling()) |
106 |
|
{ |
107 |
|
if (ctx == this) |
108 |
|
{ |
109 |
|
return index; |
110 |
|
} |
111 |
|
index++; |
112 |
|
} |
113 |
|
} |
114 |
|
} |
115 |
|
throw new DomDOMException(DOMException.NOT_FOUND_ERR); |
116 |
} |
} |
117 |
|
|
118 |
public HTMLCollection getCells() |
public HTMLCollection getCells() |
177 |
|
|
178 |
public HTMLElement insertCell(int index) |
public HTMLElement insertCell(int index) |
179 |
{ |
{ |
180 |
// TODO |
Node ref = getCell(index); |
181 |
return null; |
Node cell = getOwnerDocument().createElement("td"); |
182 |
|
if (ref == null) |
183 |
|
{ |
184 |
|
appendChild(cell); |
185 |
|
} |
186 |
|
else |
187 |
|
{ |
188 |
|
insertBefore(cell, ref); |
189 |
|
} |
190 |
|
return (HTMLElement) cell; |
191 |
} |
} |
192 |
|
|
193 |
public void deleteCell(int index) |
public void deleteCell(int index) |
194 |
{ |
{ |
195 |
// TODO |
Node ref = getCell(index); |
196 |
|
if (ref == null) |
197 |
|
{ |
198 |
|
throw new DomDOMException(DOMException.INDEX_SIZE_ERR); |
199 |
|
} |
200 |
|
removeChild(ref); |
201 |
|
} |
202 |
|
|
203 |
|
Node getCell(final int index) |
204 |
|
{ |
205 |
|
int i = 0; |
206 |
|
for (Node ctx = getFirstChild(); ctx != null; |
207 |
|
ctx = ctx.getNextSibling()) |
208 |
|
{ |
209 |
|
String name = ctx.getLocalName(); |
210 |
|
if (!"td".equalsIgnoreCase(name) && |
211 |
|
!"th".equalsIgnoreCase(name)) |
212 |
|
{ |
213 |
|
continue; |
214 |
|
} |
215 |
|
if (index == i) |
216 |
|
{ |
217 |
|
return ctx; |
218 |
|
} |
219 |
|
i++; |
220 |
|
} |
221 |
|
return null; |
222 |
} |
} |
223 |
|
|
224 |
} |
} |