001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.html.dom;
018:
019: import org.w3c.dom.Node;
020: import org.w3c.dom.html.HTMLTableCellElement;
021: import org.w3c.dom.html.HTMLTableRowElement;
022:
023: /**
024: * @xerces.internal
025: * @version $Revision: 449313 $ $Date: 2006-09-23 18:01:43 -0400 (Sat, 23 Sep 2006) $
026: * @author <a href="mailto:arkin@exoffice.com">Assaf Arkin</a>
027: * @see org.w3c.dom.html.HTMLTableCellElement
028: * @see org.apache.xerces.dom.ElementImpl
029: */
030: public class HTMLTableCellElementImpl extends HTMLElementImpl implements
031: HTMLTableCellElement {
032:
033: private static final long serialVersionUID = -2406518157464313922L;
034:
035: public int getCellIndex() {
036: Node parent;
037: Node child;
038: int index;
039:
040: parent = getParentNode();
041: index = 0;
042: if (parent instanceof HTMLTableRowElement) {
043: child = parent.getFirstChild();
044: while (child != null) {
045: if (child instanceof HTMLTableCellElement) {
046: if (child == this )
047: return index;
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:
060: parent = getParentNode();
061: if (parent instanceof HTMLTableRowElement) {
062: child = parent.getFirstChild();
063: while (child != null) {
064: if (child instanceof HTMLTableCellElement) {
065: if (cellIndex == 0) {
066: if (this != child)
067: parent.insertBefore(this , child);
068: return;
069: }
070: --cellIndex;
071: }
072: child = child.getNextSibling();
073: }
074: }
075: parent.appendChild(this );
076: }
077:
078: public String getAbbr() {
079: return getAttribute("abbr");
080: }
081:
082: public void setAbbr(String abbr) {
083: setAttribute("abbr", abbr);
084: }
085:
086: public String getAlign() {
087: return capitalize(getAttribute("align"));
088: }
089:
090: public void setAlign(String align) {
091: setAttribute("align", align);
092: }
093:
094: public String getAxis() {
095: return getAttribute("axis");
096: }
097:
098: public void setAxis(String axis) {
099: setAttribute("axis", axis);
100: }
101:
102: public String getBgColor() {
103: return getAttribute("bgcolor");
104: }
105:
106: public void setBgColor(String bgColor) {
107: setAttribute("bgcolor", bgColor);
108: }
109:
110: public String getCh() {
111: String ch;
112:
113: // Make sure that the access key is a single character.
114: ch = getAttribute("char");
115: if (ch != null && ch.length() > 1)
116: ch = ch.substring(0, 1);
117: return ch;
118: }
119:
120: public void setCh(String ch) {
121: // Make sure that the access key is a single character.
122: if (ch != null && ch.length() > 1)
123: ch = ch.substring(0, 1);
124: setAttribute("char", ch);
125: }
126:
127: public String getChOff() {
128: return getAttribute("charoff");
129: }
130:
131: public void setChOff(String chOff) {
132: setAttribute("charoff", chOff);
133: }
134:
135: public int getColSpan() {
136: return getInteger(getAttribute("colspan"));
137: }
138:
139: public void setColSpan(int colspan) {
140: setAttribute("colspan", String.valueOf(colspan));
141: }
142:
143: public String getHeaders() {
144: return getAttribute("headers");
145: }
146:
147: public void setHeaders(String headers) {
148: setAttribute("headers", headers);
149: }
150:
151: public String getHeight() {
152: return getAttribute("height");
153: }
154:
155: public void setHeight(String height) {
156: setAttribute("height", height);
157: }
158:
159: public boolean getNoWrap() {
160: return getBinary("nowrap");
161: }
162:
163: public void setNoWrap(boolean noWrap) {
164: setAttribute("nowrap", noWrap);
165: }
166:
167: public int getRowSpan() {
168: return getInteger(getAttribute("rowspan"));
169: }
170:
171: public void setRowSpan(int rowspan) {
172: setAttribute("rowspan", String.valueOf(rowspan));
173: }
174:
175: public String getScope() {
176: return getAttribute("scope");
177: }
178:
179: public void setScope(String scope) {
180: setAttribute("scope", scope);
181: }
182:
183: public String getVAlign() {
184: return capitalize(getAttribute("valign"));
185: }
186:
187: public void setVAlign(String vAlign) {
188: setAttribute("valign", vAlign);
189: }
190:
191: public String getWidth() {
192: return getAttribute("width");
193: }
194:
195: public void setWidth(String width) {
196: setAttribute("width", width);
197: }
198:
199: /**
200: * Constructor requires owner document.
201: *
202: * @param owner The owner HTML document
203: */
204: public HTMLTableCellElementImpl(HTMLDocumentImpl owner, String name) {
205: super(owner, name);
206: }
207:
208: }
|