001: /**
002: * org/ozone-db/xml/dom/html/HTMLTableCellElementImpl.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.HTMLTableCellElement
029: * @see ElementImpl
030: */
031: public final class HTMLTableCellElementImpl extends HTMLElementImpl
032: implements HTMLTableCellElement {
033:
034: public int getCellIndex() {
035: Node parent;
036: Node child;
037: int index;
038:
039: parent = getParentNode();
040: index = 0;
041: if (parent instanceof HTMLTableRowElement) {
042: child = parent.getFirstChild();
043: while (child != null) {
044: if (child instanceof HTMLTableCellElement) {
045: if (child == this ) {
046: return index;
047: }
048: ++index;
049: }
050: child = child.getNextSibling();
051: }
052: }
053: return -1;
054: }
055:
056: public void setCellIndex(int cellIndex) {
057: Node parent;
058: Node child;
059: int index;
060:
061: parent = getParentNode();
062: if (parent instanceof HTMLTableRowElement) {
063: child = parent.getFirstChild();
064: while (child != null) {
065: if (child instanceof HTMLTableCellElement) {
066: if (cellIndex == 0) {
067: if (this != child) {
068: parent.insertBefore(this , child);
069: }
070: return;
071: }
072: --cellIndex;
073: }
074: child = child.getNextSibling();
075: }
076: }
077: parent.appendChild(this );
078: }
079:
080: public String getAbbr() {
081: return getAttribute("abbr");
082: }
083:
084: public void setAbbr(String abbr) {
085: setAttribute("abbr", abbr);
086: }
087:
088: public String getAlign() {
089: return capitalize(getAttribute("align"));
090: }
091:
092: public void setAlign(String align) {
093: setAttribute("align", align);
094: }
095:
096: public String getAxis() {
097: return getAttribute("axis");
098: }
099:
100: public void setAxis(String axis) {
101: setAttribute("axis", axis);
102: }
103:
104: public String getBgColor() {
105: return getAttribute("bgcolor");
106: }
107:
108: public void setBgColor(String bgColor) {
109: setAttribute("bgcolor", bgColor);
110: }
111:
112: public String getCh() {
113: String ch;
114:
115: // Make sure that the access key is a single character.
116: ch = getAttribute("char");
117: if (ch != null && ch.length() > 1) {
118: ch = ch.substring(0, 1);
119: }
120: return ch;
121: }
122:
123: public void setCh(String ch) {
124: // Make sure that the access key is a single character.
125: if (ch != null && ch.length() > 1) {
126: ch = ch.substring(0, 1);
127: }
128: setAttribute("char", ch);
129: }
130:
131: public String getChOff() {
132: return getAttribute("charoff");
133: }
134:
135: public void setChOff(String chOff) {
136: setAttribute("charoff", chOff);
137: }
138:
139: public int getColSpan() {
140: return toInteger(getAttribute("colspan"));
141: }
142:
143: public void setColSpan(int colspan) {
144: setAttribute("colspan", String.valueOf(colspan));
145: }
146:
147: public String getHeaders() {
148: return getAttribute("headers");
149: }
150:
151: public void setHeaders(String headers) {
152: setAttribute("headers", headers);
153: }
154:
155: public String getHeight() {
156: return getAttribute("height");
157: }
158:
159: public void setHeight(String height) {
160: setAttribute("height", height);
161: }
162:
163: public boolean getNoWrap() {
164: return getAttribute("nowrap") != null;
165: }
166:
167: public void setNoWrap(boolean noWrap) {
168: setAttribute("nowrap", noWrap ? "" : null);
169: }
170:
171: public int getRowSpan() {
172: return toInteger(getAttribute("rowspan"));
173: }
174:
175: public void setRowSpan(int rowspan) {
176: setAttribute("rowspan", String.valueOf(rowspan));
177: }
178:
179: public String getScope() {
180: return getAttribute("scope");
181: }
182:
183: public void setScope(String scope) {
184: setAttribute("scope", scope);
185: }
186:
187: public String getVAlign() {
188: return capitalize(getAttribute("valign"));
189: }
190:
191: public void setVAlign(String vAlign) {
192: setAttribute("valign", vAlign);
193: }
194:
195: public String getWidth() {
196: return getAttribute("width");
197: }
198:
199: public void setWidth(String width) {
200: setAttribute("width", width);
201: }
202:
203: /**
204: * Constructor requires owner document.
205: *
206: * @param owner The owner HTML document
207: */
208: public HTMLTableCellElementImpl(HTMLDocumentImpl owner, String name) {
209: super (owner, "TD");
210: }
211:
212: }
|