001: /*
002: * The Apache Software License, Version 1.1
003: *
004: *
005: * Copyright (c) 1999,2000 The Apache Software Foundation. All rights
006: * reserved.
007: *
008: * Redistribution and use in source and binary forms, with or without
009: * modification, are permitted provided that the following conditions
010: * are met:
011: *
012: * 1. Redistributions of source code must retain the above copyright
013: * notice, this list of conditions and the following disclaimer.
014: *
015: * 2. Redistributions in binary form must reproduce the above copyright
016: * notice, this list of conditions and the following disclaimer in
017: * the documentation and/or other materials provided with the
018: * distribution.
019: *
020: * 3. The end-user documentation included with the redistribution,
021: * if any, must include the following acknowledgment:
022: * "This product includes software developed by the
023: * Apache Software Foundation (http://www.apache.org/)."
024: * Alternately, this acknowledgment may appear in the software itself,
025: * if and wherever such third-party acknowledgments normally appear.
026: *
027: * 4. The names "Xerces" and "Apache Software Foundation" must
028: * not be used to endorse or promote products derived from this
029: * software without prior written permission. For written
030: * permission, please contact apache@apache.org.
031: *
032: * 5. Products derived from this software may not be called "Apache",
033: * nor may "Apache" appear in their name, without prior written
034: * permission of the Apache Software Foundation.
035: *
036: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
037: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
038: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
039: * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
040: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
041: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
042: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
043: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
044: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
045: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
046: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
047: * SUCH DAMAGE.
048: * ====================================================================
049: *
050: * This software consists of voluntary contributions made by many
051: * individuals on behalf of the Apache Software Foundation and was
052: * originally based on software copyright (c) 1999, International
053: * Business Machines, Inc., http://www.apache.org. For more
054: * information on the Apache Software Foundation, please see
055: * <http://www.apache.org/>.
056: */
057: package org.apache.html.dom;
058:
059: import org.w3c.dom.*;
060: import org.w3c.dom.html.*;
061:
062: /**
063: * @version $Revision: 1.4 $ $Date: 2001/01/30 23:58:04 $
064: * @author <a href="mailto:arkin@exoffice.com">Assaf Arkin</a>
065: * @see org.w3c.dom.html.HTMLTableCellElement
066: * @see ElementImpl
067: */
068: public class HTMLTableCellElementImpl extends HTMLElementImpl implements
069: HTMLTableCellElement {
070:
071: public int getCellIndex() {
072: Node parent;
073: Node child;
074: int index;
075:
076: parent = getParentNode();
077: index = 0;
078: if (parent instanceof HTMLTableRowElement) {
079: child = parent.getFirstChild();
080: while (child != null) {
081: if (child instanceof HTMLTableCellElement) {
082: if (child == this )
083: return index;
084: ++index;
085: }
086: child = child.getNextSibling();
087: }
088: }
089: return -1;
090: }
091:
092: public void setCellIndex(int cellIndex) {
093: Node parent;
094: Node child;
095: int index;
096:
097: parent = getParentNode();
098: if (parent instanceof HTMLTableRowElement) {
099: child = parent.getFirstChild();
100: while (child != null) {
101: if (child instanceof HTMLTableCellElement) {
102: if (cellIndex == 0) {
103: if (this != child)
104: parent.insertBefore(this , child);
105: return;
106: }
107: --cellIndex;
108: }
109: child = child.getNextSibling();
110: }
111: }
112: parent.appendChild(this );
113: }
114:
115: public String getAbbr() {
116: return getAttribute("abbr");
117: }
118:
119: public void setAbbr(String abbr) {
120: setAttribute("abbr", abbr);
121: }
122:
123: public String getAlign() {
124: return capitalize(getAttribute("align"));
125: }
126:
127: public void setAlign(String align) {
128: setAttribute("align", align);
129: }
130:
131: public String getAxis() {
132: return getAttribute("axis");
133: }
134:
135: public void setAxis(String axis) {
136: setAttribute("axis", axis);
137: }
138:
139: public String getBgColor() {
140: return getAttribute("bgcolor");
141: }
142:
143: public void setBgColor(String bgColor) {
144: setAttribute("bgcolor", bgColor);
145: }
146:
147: public String getCh() {
148: String ch;
149:
150: // Make sure that the access key is a single character.
151: ch = getAttribute("char");
152: if (ch != null && ch.length() > 1)
153: ch = ch.substring(0, 1);
154: return ch;
155: }
156:
157: public void setCh(String ch) {
158: // Make sure that the access key is a single character.
159: if (ch != null && ch.length() > 1)
160: ch = ch.substring(0, 1);
161: setAttribute("char", ch);
162: }
163:
164: public String getChOff() {
165: return getAttribute("charoff");
166: }
167:
168: public void setChOff(String chOff) {
169: setAttribute("charoff", chOff);
170: }
171:
172: public int getColSpan() {
173: return getInteger(getAttribute("colspan"));
174: }
175:
176: public void setColSpan(int colspan) {
177: setAttribute("colspan", String.valueOf(colspan));
178: }
179:
180: public String getHeaders() {
181: return getAttribute("headers");
182: }
183:
184: public void setHeaders(String headers) {
185: setAttribute("headers", headers);
186: }
187:
188: public String getHeight() {
189: return getAttribute("height");
190: }
191:
192: public void setHeight(String height) {
193: setAttribute("height", height);
194: }
195:
196: public boolean getNoWrap() {
197: return getBinary("nowrap");
198: }
199:
200: public void setNoWrap(boolean noWrap) {
201: setAttribute("nowrap", noWrap);
202: }
203:
204: public int getRowSpan() {
205: return getInteger(getAttribute("rowspan"));
206: }
207:
208: public void setRowSpan(int rowspan) {
209: setAttribute("rowspan", String.valueOf(rowspan));
210: }
211:
212: public String getScope() {
213: return getAttribute("scope");
214: }
215:
216: public void setScope(String scope) {
217: setAttribute("scope", scope);
218: }
219:
220: public String getVAlign() {
221: return capitalize(getAttribute("valign"));
222: }
223:
224: public void setVAlign(String vAlign) {
225: setAttribute("valign", vAlign);
226: }
227:
228: public String getWidth() {
229: return getAttribute("width");
230: }
231:
232: public void setWidth(String width) {
233: setAttribute("width", width);
234: }
235:
236: /**
237: * Constructor requires owner document.
238: *
239: * @param owner The owner HTML document
240: */
241: public HTMLTableCellElementImpl(HTMLDocumentImpl owner, String name) {
242: super(owner, name);
243: }
244:
245: }
|