diff options
Diffstat (limited to 'libjava/gnu/xml/dom/DomNode.java')
-rw-r--r-- | libjava/gnu/xml/dom/DomNode.java | 83 |
1 files changed, 46 insertions, 37 deletions
diff --git a/libjava/gnu/xml/dom/DomNode.java b/libjava/gnu/xml/dom/DomNode.java index 3858fe8bbb9..f763adf995a 100644 --- a/libjava/gnu/xml/dom/DomNode.java +++ b/libjava/gnu/xml/dom/DomNode.java @@ -40,7 +40,6 @@ package gnu.xml.dom; import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import javax.xml.XMLConstants; import org.w3c.dom.Document; import org.w3c.dom.DOMException; @@ -58,7 +57,6 @@ import org.w3c.dom.events.EventTarget; import org.w3c.dom.events.MutationEvent; import org.w3c.dom.traversal.NodeFilter; import org.w3c.dom.traversal.NodeIterator; -import org.w3c.dom.traversal.TreeWalker; /** * <p> "Node", "EventTarget", and "DocumentEvent" implementation. @@ -308,15 +306,16 @@ public abstract class DomNode { if (readonly && !owner.building) { - throw new DomEx(DomEx.NO_MODIFICATION_ALLOWED_ERR, - null, this, 0); + throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, + null, this, 0); } for (DomNode ctx = this; ctx != null; ctx = ctx.parent) { if (child == ctx) { - throw new DomEx(DomEx.HIERARCHY_REQUEST_ERR, - "can't make ancestor into a child", this, 0); + throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR, + "can't make ancestor into a child", + this, 0); } } @@ -330,8 +329,8 @@ public abstract class DomNode // new in DOM L2, this case -- patch it up later, in reparent() if (!(childNodeType == DOCUMENT_TYPE_NODE && childOwner == null)) { - throw new DomEx(DomEx.WRONG_DOCUMENT_ERR, - null, child, 0); + throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR, + null, child, 0); } } @@ -376,10 +375,12 @@ public abstract class DomNode } if (owner.checkingWellformedness) { - throw new DomEx(DomEx.HIERARCHY_REQUEST_ERR, - "can't append " + nodeTypeToString(childNodeType) + - " to node of type " + nodeTypeToString(nodeType), - this, 0); + throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR, + "can't append " + + nodeTypeToString(childNodeType) + + " to node of type " + + nodeTypeToString(nodeType), + this, 0); } } @@ -578,8 +579,8 @@ public abstract class DomNode } catch (ClassCastException e) { - throw new DomEx(DomEx.WRONG_DOCUMENT_ERR, - null, newChild, 0); + throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR, + null, newChild, 0); } } @@ -630,12 +631,14 @@ public abstract class DomNode checkMisc(child); if (ref == null || ref.parent != this) { - throw new DomEx(DomEx.NOT_FOUND_ERR, null, ref, 0); + throw new DomDOMException(DOMException.NOT_FOUND_ERR, + null, ref, 0); } if (ref == child) { - throw new DomEx(DomEx.HIERARCHY_REQUEST_ERR, - "can't insert node before itself", ref, 0); + throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR, + "can't insert node before itself", + ref, 0); } if (child.parent != null) @@ -672,8 +675,8 @@ public abstract class DomNode } catch (ClassCastException e) { - throw new DomEx(DomEx.WRONG_DOCUMENT_ERR, - null, newChild, 0); + throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR, + null, newChild, 0); } } @@ -721,7 +724,8 @@ public abstract class DomNode } if (ref == null || ref.parent != this) { - throw new DomEx(DomEx.NOT_FOUND_ERR, null, ref, 0); + throw new DomDOMException(DOMException.NOT_FOUND_ERR, + null, ref, 0); } if (reportMutations) @@ -784,7 +788,8 @@ public abstract class DomNode checkMisc(child); if (ref == null || ref.parent != this) { - throw new DomEx(DomEx.NOT_FOUND_ERR, null, ref, 0); + throw new DomDOMException(DOMException.NOT_FOUND_ERR, + null, ref, 0); } if (reportMutations) @@ -837,8 +842,8 @@ public abstract class DomNode } catch (ClassCastException e) { - throw new DomEx(DomEx.WRONG_DOCUMENT_ERR, - null, newChild, 0); + throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR, + null, newChild, 0); } } @@ -860,12 +865,13 @@ public abstract class DomNode if (ref == null || ref.parent != this) { - throw new DomEx(DomEx.NOT_FOUND_ERR, null, ref, 0); + throw new DomDOMException(DOMException.NOT_FOUND_ERR, + null, ref, 0); } if (readonly && !owner.building) { - throw new DomEx(DomEx.NO_MODIFICATION_ALLOWED_ERR, - null, this, 0); + throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, + null, this, 0); } for (DomNode child = first; child != null; child = child.next) @@ -909,13 +915,13 @@ public abstract class DomNode return ref; } } - throw new DomEx(DomEx.NOT_FOUND_ERR, - "that's no child of mine", refChild, 0); + throw new DomDOMException(DOMException.NOT_FOUND_ERR, + "that's no child of mine", refChild, 0); } catch (ClassCastException e) { - throw new DomEx(DomEx.WRONG_DOCUMENT_ERR, - null, refChild, 0); + throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR, + null, refChild, 0); } } @@ -1446,8 +1452,8 @@ public abstract class DomNode // mouse events - throw new DomEx(DomEx.NOT_SUPPORTED_ERR, - eventType, null, 0); + throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR, + eventType, null, 0); } /** @@ -1680,13 +1686,16 @@ public abstract class DomNode { continue; } - if (count < notificationSet.length) + if (count >= notificationSet.length) { - notificationSet[count++] = rec; + // very simple growth algorithm + int len = Math.max(notificationSet.length, 1); + ListenerRecord[] tmp = new ListenerRecord[len * 2]; + System.arraycopy(notificationSet, 0, tmp, 0, + notificationSet.length); + notificationSet = tmp; } - else - // XXX fire up some cheap growth algorithm - throw new RuntimeException("Event notification set size exceeded"); + notificationSet[count++] = rec; } // Notify just those listeners |