summaryrefslogtreecommitdiff
path: root/gnu/xml/dom/html2/DomHTMLTableElement.java
diff options
context:
space:
mode:
authorChris Burdess <dog@bluezoo.org>2005-03-14 21:10:55 +0000
committerChris Burdess <dog@bluezoo.org>2005-03-14 21:10:55 +0000
commit979240c8070a8c66ab7cea9af3c83e110f1cb183 (patch)
treeeb3d6c35c5896c24ba267c9d2ce57b44344ce20b /gnu/xml/dom/html2/DomHTMLTableElement.java
parentf519552dd3a17e6c8896050a9e2c767db5f21734 (diff)
downloadclasspath-979240c8070a8c66ab7cea9af3c83e110f1cb183.tar.gz
2005-03-14 Chris Burdess <dog@gnu.org>
* gnu/xml/dom/DomImpl.java, gnu/xml/dom/html2/DomHTMLAnchorElement.java, gnu/xml/dom/html2/DomHTMLDocument.java, gnu/xml/dom/html2/DomHTMLElement.java, gnu/xml/dom/html2/DomHTMLFormElement.java, gnu/xml/dom/html2/DomHTMLFrameElement.java, gnu/xml/dom/html2/DomHTMLIFrameElement.java, gnu/xml/dom/html2/DomHTMLImpl.java, gnu/xml/dom/html2/DomHTMLInputElement.java, gnu/xml/dom/html2/DomHTMLObjectElement.java, gnu/xml/dom/html2/DomHTMLOptionElement.java, gnu/xml/dom/html2/DomHTMLSelectElement.java, gnu/xml/dom/html2/DomHTMLTableCellElement.java, gnu/xml/dom/html2/DomHTMLTableElement.java, gnu/xml/dom/html2/DomHTMLTableRowElement.java, gnu/xml/dom/html2/DomHTMLTableSectionElement.java, gnu/xml/dom/html2/DomHTMLTextAreaElement.java: JAXP integration, UI events, and tree utility functions.
Diffstat (limited to 'gnu/xml/dom/html2/DomHTMLTableElement.java')
-rw-r--r--gnu/xml/dom/html2/DomHTMLTableElement.java179
1 files changed, 157 insertions, 22 deletions
diff --git a/gnu/xml/dom/html2/DomHTMLTableElement.java b/gnu/xml/dom/html2/DomHTMLTableElement.java
index 570b3f1e0..95e295733 100644
--- a/gnu/xml/dom/html2/DomHTMLTableElement.java
+++ b/gnu/xml/dom/html2/DomHTMLTableElement.java
@@ -37,6 +37,9 @@ exception statement from your version. */
package gnu.xml.dom.html2;
+import gnu.xml.dom.DomDOMException;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Node;
import org.w3c.dom.html2.HTMLCollection;
import org.w3c.dom.html2.HTMLElement;
import org.w3c.dom.html2.HTMLTableCaptionElement;
@@ -61,35 +64,56 @@ public class DomHTMLTableElement
public HTMLTableCaptionElement getCaption()
{
- // TODO
- return null;
+ return (HTMLTableCaptionElement) getChildElement("caption");
}
public void setCaption(HTMLTableCaptionElement caption)
{
- // TODO
+ HTMLTableCaptionElement ref = getCaption();
+ if (ref == null)
+ {
+ appendChild(caption);
+ }
+ else
+ {
+ replaceChild(caption, ref);
+ }
}
public HTMLTableSectionElement getTHead()
{
- // TODO
- return null;
+ return (HTMLTableSectionElement) getChildElement("thead");
}
public void setTHead(HTMLTableSectionElement tHead)
{
- // TODO
+ HTMLTableSectionElement ref = getTHead();
+ if (ref == null)
+ {
+ appendChild(tHead);
+ }
+ else
+ {
+ replaceChild(tHead, ref);
+ }
}
public HTMLTableSectionElement getTFoot()
{
- // TODO
- return null;
+ return (HTMLTableSectionElement) getChildElement("tfoot");
}
public void setTFoot(HTMLTableSectionElement tFoot)
{
- // TODO
+ HTMLTableSectionElement ref = getTFoot();
+ if (ref == null)
+ {
+ appendChild(tFoot);
+ }
+ else
+ {
+ replaceChild(tFoot, ref);
+ }
}
public HTMLCollection getRows()
@@ -202,47 +226,158 @@ public class DomHTMLTableElement
public HTMLElement createTHead()
{
- // TODO
- return null;
+ HTMLTableSectionElement ref = getTHead();
+ if (ref == null)
+ {
+ return (HTMLElement) getOwnerDocument().createElement("thead");
+ }
+ else
+ {
+ return ref;
+ }
}
public void deleteTHead()
{
- // TODO
+ HTMLTableSectionElement ref = getTHead();
+ if (ref != null)
+ {
+ removeChild(ref);
+ }
}
public HTMLElement createTFoot()
{
- // TODO
- return null;
+ HTMLTableSectionElement ref = getTFoot();
+ if (ref == null)
+ {
+ return (HTMLElement) getOwnerDocument().createElement("tfoot");
+ }
+ else
+ {
+ return ref;
+ }
}
public void deleteTFoot()
{
- // TODO
+ HTMLTableSectionElement ref = getTFoot();
+ if (ref != null)
+ {
+ removeChild(ref);
+ }
}
public HTMLElement createCaption()
{
- // TODO
- return null;
+ HTMLTableCaptionElement ref = getCaption();
+ if (ref == null)
+ {
+ return (HTMLElement) getOwnerDocument().createElement("caption");
+ }
+ else
+ {
+ return ref;
+ }
}
public void deleteCaption()
{
- // TODO
+ HTMLTableCaptionElement ref = getCaption();
+ if (ref != null)
+ {
+ removeChild(ref);
+ }
}
public HTMLElement insertRow(int index)
{
- // TODO
- return null;
+ Node ref = getRow(index);
+ Node row = getOwnerDocument().createElement("tr");
+ if (ref == null)
+ {
+ Node tbody = getChildElement("tbody");
+ if (tbody == null)
+ {
+ tbody = getOwnerDocument().createElement("tfoot");
+ appendChild(tbody);
+ }
+ tbody.appendChild(row);
+ }
+ else
+ {
+ ref.getParentNode().insertBefore(row, ref);
+ }
+ return (HTMLElement) row;
}
public void deleteRow(int index)
{
- // TODO
+ Node ref = getRow(index);
+ if (ref == null)
+ {
+ throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
+ }
+ ref.getParentNode().removeChild(ref);
+ }
+
+ Node getRow(final int index)
+ {
+ int i = 0;
+ Node thead = getChildElement("thead");
+ if (thead != null)
+ {
+ for (Node ctx = thead.getFirstChild(); ctx != null;
+ ctx = ctx.getNextSibling())
+ {
+ if (!"tr".equalsIgnoreCase(ctx.getLocalName()))
+ {
+ continue;
+ }
+ if (index == i)
+ {
+ return ctx;
+ }
+ i++;
+ }
+ }
+ Node tbody = getChildElement("tbody");
+ if (tbody == null)
+ {
+ tbody = this;
+ }
+ for (Node ctx = tbody.getFirstChild(); ctx != null;
+ ctx = ctx.getNextSibling())
+ {
+ if (!"tr".equalsIgnoreCase(ctx.getLocalName()))
+ {
+ continue;
+ }
+ if (index == i)
+ {
+ return ctx;
+ }
+ i++;
+ }
+ Node tfoot = getChildElement("tfoot");
+ if (tfoot != null)
+ {
+ for (Node ctx = tfoot.getFirstChild(); ctx != null;
+ ctx = ctx.getNextSibling())
+ {
+ if (!"tr".equalsIgnoreCase(ctx.getLocalName()))
+ {
+ continue;
+ }
+ if (index == i)
+ {
+ return ctx;
+ }
+ i++;
+ }
+ }
+ return null;
}
-
+
}