001: /**
002: * org/ozone-db/xml/dom/html/HTMLTableSectionElementImpl.java
003: *
004: * The contents of this file are subject to the OpenXML Public
005: * License Version 1.0; you may not use this file except in compliance
006: * with the License. You may obtain a copy of the License at
007: * http://www.openxml.org/license.html
008: *
009: * THIS SOFTWARE IS DISTRIBUTED ON AN "AS IS" BASIS WITHOUT WARRANTY
010: * OF ANY KIND, EITHER EXPRESSED OR IMPLIED. THE INITIAL DEVELOPER
011: * AND ALL CONTRIBUTORS SHALL NOT BE LIABLE FOR ANY DAMAGES AS A
012: * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
013: * DERIVATIVES. SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING
014: * RIGHTS AND LIMITATIONS UNDER THE LICENSE.
015: *
016: * The Initial Developer of this code under the License is Assaf Arkin.
017: * Portions created by Assaf Arkin are Copyright (C) 1998, 1999.
018: * All Rights Reserved.
019: */package org.ozoneDB.xml.dom.html;
020:
021: import org.ozoneDB.xml.dom.*;
022: import org.w3c.dom.*;
023: import org.w3c.dom.html.*;
024:
025: /**
026: * @version $Revision: 1.1 $ $Date: 2001/12/18 11:03:24 $
027: * @author <a href="mailto:arkin@trendline.co.il">Assaf Arkin</a>
028: * @see org.w3c.dom.html.HTMLTableSectionElement
029: * @see ElementImpl
030: */
031: public final class HTMLTableSectionElementImpl extends HTMLElementImpl
032: implements HTMLTableSectionElement {
033:
034: public String getAlign() {
035: return capitalize(getAttribute("align"));
036: }
037:
038: public void setAlign(String align) {
039: setAttribute("align", align);
040: }
041:
042: public String getCh() {
043: String ch;
044:
045: // Make sure that the access key is a single character.
046: ch = getAttribute("char");
047: if (ch != null && ch.length() > 1) {
048: ch = ch.substring(0, 1);
049: }
050: return ch;
051: }
052:
053: public void setCh(String ch) {
054: // Make sure that the access key is a single character.
055: if (ch != null && ch.length() > 1) {
056: ch = ch.substring(0, 1);
057: }
058: setAttribute("char", ch);
059: }
060:
061: public String getChOff() {
062: return getAttribute("charoff");
063: }
064:
065: public void setChOff(String chOff) {
066: setAttribute("charoff", chOff);
067: }
068:
069: public String getVAlign() {
070: return capitalize(getAttribute("valign"));
071: }
072:
073: public void setVAlign(String vAlign) {
074: setAttribute("valign", vAlign);
075: }
076:
077: public HTMLCollection getRows() {
078: if (_rows == null) {
079: _rows = new HTMLCollectionImpl(this , HTMLCollectionImpl.ROW);
080: }
081: return _rows;
082: }
083:
084: public HTMLElement insertRow(int index) {
085: HTMLTableRowElementImpl newRow;
086:
087: newRow = new HTMLTableRowElementImpl(
088: (HTMLDocumentImpl) getOwnerDocument(), "TR");
089: newRow.insertCell(0);
090: if (insertRowX(index, newRow) >= 0) {
091: appendChild(newRow);
092: }
093: return newRow;
094: }
095:
096: int insertRowX(int index, HTMLTableRowElementImpl newRow) {
097: Node child;
098:
099: child = getFirstChild();
100: while (child != null) {
101: if (child instanceof HTMLTableRowElement) {
102: if (index == 0) {
103: insertBefore(newRow, child);
104: return -1;
105: }
106: --index;
107: }
108: child = child.getNextSibling();
109: }
110: return index;
111: }
112:
113: public void deleteRow(int index) {
114: deleteRowX(index);
115: }
116:
117: int deleteRowX(int index) {
118: Node child;
119:
120: child = getFirstChild();
121: while (child != null) {
122: if (child instanceof HTMLTableRowElement) {
123: if (index == 0) {
124: removeChild(child);
125: return -1;
126: }
127: --index;
128: }
129: child = child.getNextSibling();
130: }
131: return index;
132: }
133:
134: /**
135: * Constructor requires owner document.
136: *
137: * @param owner The owner HTML document
138: */
139: public HTMLTableSectionElementImpl(HTMLDocumentImpl owner,
140: String section) {
141: super (owner, section);
142: }
143:
144: private HTMLCollectionImpl _rows;
145:
146: }
|