1:
37:
38: package ;
39:
40: import ;
41: import ;
42: import ;
43: import ;
44: import ;
45: import ;
46:
47:
52: public class DomHTMLTableRowElement
53: extends DomHTMLElement
54: implements HTMLTableRowElement
55: {
56:
57: protected DomHTMLTableRowElement(DomHTMLDocument owner,
58: String namespaceURI,
59: String name)
60: {
61: super(owner, namespaceURI, name);
62: }
63:
64: public int getRowIndex()
65: {
66: return getIndex();
67: }
68:
69: public int getSectionRowIndex()
70: {
71: int index = 0;
72: DomHTMLElement parent = (DomHTMLElement) getParentElement("table");
73: if (parent != null)
74: {
75: Node thead = parent.getChildElement("thead");
76: if (thead != null)
77: {
78: for (Node ctx = thead.getFirstChild(); ctx != null;
79: ctx = ctx.getNextSibling())
80: {
81: if (ctx == this)
82: {
83: return index;
84: }
85: index++;
86: }
87: }
88: Node tbody = parent.getChildElement("tbody");
89: if (tbody != null)
90: {
91: for (Node ctx = tbody.getFirstChild(); ctx != null;
92: ctx = ctx.getNextSibling())
93: {
94: if (ctx == this)
95: {
96: return index;
97: }
98: index++;
99: }
100: }
101: Node tfoot = parent.getChildElement("tfoot");
102: if (tfoot != null)
103: {
104: for (Node ctx = tfoot.getFirstChild(); ctx != null;
105: ctx = ctx.getNextSibling())
106: {
107: if (ctx == this)
108: {
109: return index;
110: }
111: index++;
112: }
113: }
114: }
115: throw new DomDOMException(DOMException.NOT_FOUND_ERR);
116: }
117:
118: public HTMLCollection getCells()
119: {
120: DomHTMLCollection ret =
121: new DomHTMLCollection((DomHTMLDocument) getOwnerDocument(), this);
122: ret.addNodeName("th");
123: ret.addNodeName("td");
124: ret.evaluate();
125: return ret;
126: }
127:
128: public String getAlign()
129: {
130: return getHTMLAttribute("align");
131: }
132:
133: public void setAlign(String align)
134: {
135: setHTMLAttribute("align", align);
136: }
137:
138: public String getBgColor()
139: {
140: return getHTMLAttribute("bgcolor");
141: }
142:
143: public void setBgColor(String bgColor)
144: {
145: setHTMLAttribute("bgcolor", bgColor);
146: }
147:
148: public String getCh()
149: {
150: return getHTMLAttribute("char");
151: }
152:
153: public void setCh(String ch)
154: {
155: setHTMLAttribute("char", ch);
156: }
157:
158: public String getChOff()
159: {
160: return getHTMLAttribute("charoff");
161: }
162:
163: public void setChOff(String chOff)
164: {
165: setHTMLAttribute("charoff", chOff);
166: }
167:
168: public String getVAlign()
169: {
170: return getHTMLAttribute("valign");
171: }
172:
173: public void setVAlign(String vAlign)
174: {
175: setHTMLAttribute("valign", vAlign);
176: }
177:
178: public HTMLElement insertCell(int index)
179: {
180: Node ref = getCell(index);
181: Node cell = getOwnerDocument().createElement("td");
182: if (ref == null)
183: {
184: appendChild(cell);
185: }
186: else
187: {
188: insertBefore(cell, ref);
189: }
190: return (HTMLElement) cell;
191: }
192:
193: public void deleteCell(int index)
194: {
195: Node ref = getCell(index);
196: if (ref == null)
197: {
198: throw new DomDOMException(DOMException.INDEX_SIZE_ERR);
199: }
200: removeChild(ref);
201: }
202:
203: Node getCell(final int index)
204: {
205: int i = 0;
206: for (Node ctx = getFirstChild(); ctx != null;
207: ctx = ctx.getNextSibling())
208: {
209: String name = ctx.getLocalName();
210: if (name == null)
211: {
212: name = ctx.getNodeName();
213: }
214: if (!"td".equalsIgnoreCase(name) &&
215: !"th".equalsIgnoreCase(name))
216: {
217: continue;
218: }
219: if (index == i)
220: {
221: return ctx;
222: }
223: i++;
224: }
225: return null;
226: }
227:
228: }