/** * Sets the parent of this Node object to the given SOAPElement object. * * @param parent the SOAPElement object to be set as the parent of this Node object * @throws javax.xml.soap.SOAPException if there is a problem in setting the parent to the given node */ public void setParentElement(SOAPElement parent) throws SOAPException { // detach from the old parent if (soapParent != null) detachNode(); soapParent = (SOAPElementImpl)parent; }
public org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild, org.w3c.dom.Node oldChild) throws DOMException { newChild = convertDOMNode(newChild); oldChild = convertDOMNode(oldChild); if (newChild instanceof DocumentFragment) { insertBefore(newChild, oldChild); ((NodeImpl)oldChild).detachNode(); return newChild; } int index = soapChildren.indexOf(oldChild); if (index < 0) throw new DOMException(DOMException.NOT_FOUND_ERR, "Cannot find oldChild in list of javax.xml.soap.Node children"); NodeImpl soapNewNode = (NodeImpl)newChild; NodeImpl soapOldNode = (NodeImpl)oldChild; soapNewNode.detachNode(); if (soapNewNode.domNode != soapOldNode.domNode) domNode.replaceChild(soapNewNode.domNode, soapOldNode.domNode); soapChildren.remove(index); soapChildren.add(index, soapNewNode); soapNewNode.soapParent = soapOldNode.soapParent; soapOldNode.soapParent = null; return newChild; }
public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild) throws DOMException { newChild = convertDOMNode(newChild); if (newChild instanceof DocumentFragment) { List<NodeImpl> list = convertDocumentFragment((DocumentFragment)newChild); for (NodeImpl node : list) { appendChild(node); } return newChild; } if ((this instanceof SOAPElementImpl) == false) throw new DOMException(DOMException.INVALID_ACCESS_ERR, "Cannot append child to this node: " + this); NodeImpl soapNode = (NodeImpl)newChild; soapNode.detachNode(); domNode.appendChild(soapNode.domNode); soapNode.soapParent = (SOAPElementImpl)this; soapChildren.add(soapNode); return newChild; }
public org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild) throws DOMException { // DOM says that if refChild is null, an append is performed if (refChild == null) return appendChild(newChild); newChild = convertDOMNode(newChild); refChild = convertDOMNode(refChild); if (newChild instanceof DocumentFragment) { List<NodeImpl> list = convertDocumentFragment((DocumentFragment)newChild); for (NodeImpl node : list) { insertBefore(node, refChild); } return newChild; } int index = soapChildren.indexOf(refChild); if (index < 0) throw new IllegalArgumentException(BundleUtils.getMessage(bundle, "CANNOT_FIND_REFCHILD")); NodeImpl soapNewNode = (NodeImpl)newChild; soapNewNode.detachNode(); NodeImpl soapRefNode = (NodeImpl)refChild; domNode.insertBefore(soapNewNode.domNode, soapRefNode.domNode); soapChildren.add(index, soapNewNode); soapNewNode.soapParent = (SOAPElementImpl)this; return newChild; }