checkChildType(n, replace); if (isReadonly()) throw createDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.node", new Object[] {(int) getNodeType(), getNodeName() }); if (n.getOwnerDocument() != getCurrentDocument()) throw createDOMException(DOMException.WRONG_DOCUMENT_ERR, "node.from.wrong.document", new Object[] {(int) getNodeType(), getNodeName() }); if (this == n) throw createDOMException (DOMException.HIERARCHY_REQUEST_ERR, "add.self", new Object[] { getNodeName() }); throw createDOMException (DOMException.HIERARCHY_REQUEST_ERR, "add.ancestor", new Object[] {(int) getNodeType(), getNodeName() });
/** * Copy the fields of the current node into the given node. * @param n a node of the type of this. */ protected Node copyInto(Node n) { super.copyInto(n); AbstractEntity ae = (AbstractEntity)n; ae.nodeName = nodeName; ae.publicId = publicId; ae.systemId = systemId; return n; }
/** * Deeply copy the fields of the current node into the given node. * @param n a node of the type of this. */ protected Node deepCopyInto(Node n) { super.deepCopyInto(n); AbstractAttr aa = (AbstractAttr)n; aa.nodeName = nodeName; aa.unspecified = unspecified; aa.isIdAttr = isIdAttr; return n; }
throws DOMException { if ((childNodes == null) || (oldChild.getParentNode() != this) ) throw createDOMException (DOMException.NOT_FOUND_ERR, "child.missing", checkAndRemove(newChild, true); replaceChild(n, oldChild); Node ns = n; n = ps; while (n != null) { ps = n.getPreviousSibling(); insertBefore(n, ns); ns = n; n = ps; fireDOMNodeRemovedEvent(oldChild); getCurrentDocument().nodeToBeRemoved(oldChild); nodeToBeRemoved(oldChild); nodeAdded(n); fireDOMNodeInsertedEvent(n); fireDOMSubtreeModifiedEvent(); return n;
/** * <b>DOM</b>: Implements {@link org.w3c.dom.Node#removeChild(Node)}. */ public Node removeChild(Node oldChild) throws DOMException { if (childNodes == null || oldChild.getParentNode() != this) { throw createDOMException (DOMException.NOT_FOUND_ERR, "child.missing", new Object[] {(int) oldChild.getNodeType(), oldChild.getNodeName() }); } if (isReadonly()) { throw createDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.node", new Object[] {(int) getNodeType(), getNodeName() }); } // Mutation event fireDOMNodeRemovedEvent(oldChild); getCurrentDocument().nodeToBeRemoved(oldChild); nodeToBeRemoved(oldChild); // Node modification ExtendedNode result = childNodes.remove((ExtendedNode)oldChild); result.setParentNode(null); // Mutation event fireDOMSubtreeModifiedEvent(); return result; }
if ((refChild != null) && ((childNodes == null) || (refChild.getParentNode() != this))) throw createDOMException (DOMException.NOT_FOUND_ERR, "child.missing", refChild.getNodeName() }); checkAndRemove(newChild, false); while (n != null) { Node ns = n.getNextSibling(); insertBefore(n, refChild); n = ns; n.setParentNode(this); nodeAdded(n); fireDOMNodeInsertedEvent(n); fireDOMSubtreeModifiedEvent(); return n;
/** * <b>DOM</b>: Implements {@link org.w3c.dom.Node#appendChild(Node)}. */ public Node appendChild(Node newChild) throws DOMException { checkAndRemove(newChild, false); if (newChild.getNodeType() == DOCUMENT_FRAGMENT_NODE) { Node n = newChild.getFirstChild(); while (n != null) { Node ns = n.getNextSibling(); appendChild(n); n = ns; } return newChild; } else { if (childNodes == null) childNodes = new ChildNodes(); // Node modification ExtendedNode n = childNodes.append((ExtendedNode)newChild); n.setParentNode(this); nodeAdded(n); // Mutation event fireDOMNodeInsertedEvent(n); fireDOMSubtreeModifiedEvent(); return n; } }
/** * Fires a DOMSubtreeModified event. */ protected void fireDOMSubtreeModifiedEvent() { AbstractDocument doc = getCurrentDocument(); if (doc.getEventsEnabled()) { DOMMutationEvent ev = (DOMMutationEvent) doc.createEvent("MutationEvents"); ev.initMutationEventNS(XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMSubtreeModified", true, // canBubbleArg false, // cancelableArg null, // relatedNodeArg null, // prevValueArg null, // newValueArg null, // attrNameArg MutationEvent.MODIFICATION); dispatchEvent(ev); } }
throw createDOMException (DOMException.NOT_FOUND_ERR, "child.missing",
/** * Deeply exports this node to the given document. */ protected Node deepExport(Node n, AbstractDocument d) { super.deepExport(n, d); AbstractEntity ae = (AbstractEntity)n; ae.nodeName = nodeName; ae.publicId = publicId; ae.systemId = systemId; return n; }
/** * Exports this node to the given document. */ protected Node export(Node n, AbstractDocument d) { super.export(n, d); AbstractEntity ae = (AbstractEntity)n; ae.nodeName = nodeName; ae.publicId = publicId; ae.systemId = systemId; return n; }
throws DOMException { if ((childNodes == null) || (oldChild.getParentNode() != this) ) throw createDOMException (DOMException.NOT_FOUND_ERR, "child.missing", checkAndRemove(newChild, true); replaceChild(n, oldChild); Node ns = n; n = ps; while (n != null) { ps = n.getPreviousSibling(); insertBefore(n, ns); ns = n; n = ps; fireDOMNodeRemovedEvent(oldChild); getCurrentDocument().nodeToBeRemoved(oldChild); nodeToBeRemoved(oldChild); nodeAdded(n); fireDOMNodeInsertedEvent(n); fireDOMSubtreeModifiedEvent(); return n;
/** * <b>DOM</b>: Implements {@link org.w3c.dom.Node#removeChild(Node)}. */ public Node removeChild(Node oldChild) throws DOMException { if (childNodes == null || oldChild.getParentNode() != this) { throw createDOMException (DOMException.NOT_FOUND_ERR, "child.missing", new Object[] { new Integer(oldChild.getNodeType()), oldChild.getNodeName() }); } if (isReadonly()) { throw createDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.node", new Object[] { new Integer(getNodeType()), getNodeName() }); } // Mutation event fireDOMNodeRemovedEvent(oldChild); getCurrentDocument().nodeToBeRemoved(oldChild); nodeToBeRemoved(oldChild); // Node modification ExtendedNode result = childNodes.remove((ExtendedNode)oldChild); result.setParentNode(null); // Mutation event fireDOMSubtreeModifiedEvent(); return result; }
if ((refChild != null) && ((childNodes == null) || (refChild.getParentNode() != this))) throw createDOMException (DOMException.NOT_FOUND_ERR, "child.missing", refChild.getNodeName() }); checkAndRemove(newChild, false); while (n != null) { Node ns = n.getNextSibling(); insertBefore(n, refChild); n = ns; n.setParentNode(this); nodeAdded(n); fireDOMNodeInsertedEvent(n); fireDOMSubtreeModifiedEvent(); return n;
/** * <b>DOM</b>: Implements {@link org.w3c.dom.Node#appendChild(Node)}. */ public Node appendChild(Node newChild) throws DOMException { checkAndRemove(newChild, false); if (newChild.getNodeType() == DOCUMENT_FRAGMENT_NODE) { Node n = newChild.getFirstChild(); while (n != null) { Node ns = n.getNextSibling(); appendChild(n); n = ns; } return newChild; } else { if (childNodes == null) childNodes = new ChildNodes(); // Node modification ExtendedNode n = childNodes.append((ExtendedNode)newChild); n.setParentNode(this); nodeAdded(n); // Mutation event fireDOMNodeInsertedEvent(n); fireDOMSubtreeModifiedEvent(); return n; } }
/** * Fires a DOMSubtreeModified event. */ protected void fireDOMSubtreeModifiedEvent() { AbstractDocument doc = getCurrentDocument(); if (doc.getEventsEnabled()) { DOMMutationEvent ev = (DOMMutationEvent) doc.createEvent("MutationEvents"); ev.initMutationEventNS(XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMSubtreeModified", true, // canBubbleArg false, // cancelableArg null, // relatedNodeArg null, // prevValueArg null, // newValueArg null, // attrNameArg MutationEvent.MODIFICATION); dispatchEvent(ev); } }
throw createDOMException (DOMException.NOT_FOUND_ERR, "child.missing",
/** * Deeply exports this node to the given document. */ protected Node deepExport(Node n, AbstractDocument d) { super.deepExport(n, d); AbstractEntity ae = (AbstractEntity)n; ae.nodeName = nodeName; ae.publicId = publicId; ae.systemId = systemId; return n; }
/** * Exports this node to the given document. */ protected Node export(Node n, AbstractDocument d) { super.export(n, d); AbstractEntity ae = (AbstractEntity)n; ae.nodeName = nodeName; ae.publicId = publicId; ae.systemId = systemId; return n; }
throws DOMException { if ((childNodes == null) || (oldChild.getParentNode() != this) ) throw createDOMException (DOMException.NOT_FOUND_ERR, "child.missing", checkAndRemove(newChild, true); replaceChild(n, oldChild); Node ns = n; n = ps; while (n != null) { ps = n.getPreviousSibling(); insertBefore(n, ns); ns = n; n = ps; fireDOMNodeRemovedEvent(oldChild); getCurrentDocument().nodeToBeRemoved(oldChild); nodeToBeRemoved(oldChild); nodeAdded(n); fireDOMNodeInsertedEvent(n); fireDOMSubtreeModifiedEvent(); return n;