37 |
|
|
38 |
package gnu.xml.dom.html2; |
package gnu.xml.dom.html2; |
39 |
|
|
40 |
|
import gnu.xml.dom.DomDOMException; |
41 |
import gnu.xml.dom.DomElement; |
import gnu.xml.dom.DomElement; |
42 |
|
import gnu.xml.dom.DomEvent; |
43 |
|
import org.w3c.dom.DOMException; |
44 |
import org.w3c.dom.NamedNodeMap; |
import org.w3c.dom.NamedNodeMap; |
45 |
import org.w3c.dom.Node; |
import org.w3c.dom.Node; |
46 |
|
import org.w3c.dom.events.UIEvent; |
47 |
import org.w3c.dom.html2.HTMLElement; |
import org.w3c.dom.html2.HTMLElement; |
48 |
|
|
49 |
/** |
/** |
170 |
return null; |
return null; |
171 |
} |
} |
172 |
|
|
173 |
|
/** |
174 |
|
* Returns the first child element with the specified name. |
175 |
|
*/ |
176 |
|
protected Node getChildElement(String name) |
177 |
|
{ |
178 |
|
for (Node child = getFirstChild(); child != null; |
179 |
|
child = child.getNextSibling()) |
180 |
|
{ |
181 |
|
if (name.equalsIgnoreCase(child.getLocalName())) |
182 |
|
{ |
183 |
|
return child; |
184 |
|
} |
185 |
|
} |
186 |
|
return null; |
187 |
|
} |
188 |
|
|
189 |
|
/** |
190 |
|
* Returns the index of this element among elements of the same name, |
191 |
|
* relative to its parent. |
192 |
|
*/ |
193 |
|
protected int getIndex() |
194 |
|
{ |
195 |
|
int index = 0; |
196 |
|
Node parent = getParentNode(); |
197 |
|
if (parent != null) |
198 |
|
{ |
199 |
|
for (Node ctx = parent.getFirstChild(); ctx != null; |
200 |
|
ctx = ctx.getNextSibling()) |
201 |
|
{ |
202 |
|
if (ctx == this) |
203 |
|
{ |
204 |
|
return index; |
205 |
|
} |
206 |
|
index++; |
207 |
|
} |
208 |
|
} |
209 |
|
throw new DomDOMException(DOMException.NOT_FOUND_ERR); |
210 |
|
} |
211 |
|
|
212 |
|
protected void dispatchUIEvent(String name) |
213 |
|
{ |
214 |
|
UIEvent event = new DomEvent.DomUIEvent(name); |
215 |
|
dispatchEvent(event); |
216 |
|
} |
217 |
|
|
218 |
public String getId() |
public String getId() |
219 |
{ |
{ |
220 |
return getHTMLAttribute("id"); |
return getHTMLAttribute("id"); |