< prev index next >
src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/SOAPDocumentImpl.java
Print this page
*** 218,229 ****
final Node newNode = document.importNode(domNode, deep);
if (importedNode instanceof javax.xml.soap.Node) {
Node newSoapNode = createSoapNode(importedNode.getClass(), newNode);
newNode.setUserData(SAAJ_NODE, newSoapNode, null);
! if (deep && importedNode.hasChildNodes()) {
! NodeList childNodes = importedNode.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
registerChildNodes(childNodes.item(i), deep);
}
}
return newSoapNode;
--- 218,229 ----
final Node newNode = document.importNode(domNode, deep);
if (importedNode instanceof javax.xml.soap.Node) {
Node newSoapNode = createSoapNode(importedNode.getClass(), newNode);
newNode.setUserData(SAAJ_NODE, newSoapNode, null);
! if (deep && newSoapNode.hasChildNodes()) {
! NodeList childNodes = newSoapNode.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
registerChildNodes(childNodes.item(i), deep);
}
}
return newSoapNode;
*** 231,242 ****
registerChildNodes(newNode, deep);
return findIfPresent(newNode);
}
! //If the parentNode is not registered to domToSoap, create soap wapper for parentNode and register it to domToSoap
! //If deep = true, also register all children of parentNode to domToSoap map.
public void registerChildNodes(Node parentNode, boolean deep) {
if (parentNode.getUserData(SAAJ_NODE) == null) {
if (parentNode instanceof Element) {
ElementFactory.createElement(this, (Element) parentNode);
} else if (parentNode instanceof CharacterData) {
--- 231,246 ----
registerChildNodes(newNode, deep);
return findIfPresent(newNode);
}
! /**
! * If the parentNode is not registered to domToSoap, create soap wapper for parentNode and register it to domToSoap
! * If deep = true, also register all children transitively of parentNode to domToSoap map.
! * @param parentNode node to wrap
! * @param deep wrap child nodes transitively
! */
public void registerChildNodes(Node parentNode, boolean deep) {
if (parentNode.getUserData(SAAJ_NODE) == null) {
if (parentNode instanceof Element) {
ElementFactory.createElement(this, (Element) parentNode);
} else if (parentNode instanceof CharacterData) {
*** 249,258 ****
--- 253,264 ----
break;
case TEXT_NODE:
new SOAPTextImpl(this, (CharacterData) parentNode);
break;
}
+ } else if (parentNode instanceof DocumentFragment) {
+ new SOAPDocumentFragment(this, (DocumentFragment) parentNode);
}
}
if (deep) {
NodeList nodeList = parentNode.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
*** 410,420 ****
return findIfPresent(document.getNextSibling());
}
@Override
public NamedNodeMap getAttributes() {
! return new NamedNodeMapImpl(document.getAttributes(), this);
}
@Override
public Document getOwnerDocument() {
return document.getOwnerDocument();
--- 416,430 ----
return findIfPresent(document.getNextSibling());
}
@Override
public NamedNodeMap getAttributes() {
! NamedNodeMap attributes = document.getAttributes();
! if (attributes == null) {
! return null;
! }
! return new NamedNodeMapImpl(attributes, this);
}
@Override
public Document getOwnerDocument() {
return document.getOwnerDocument();
*** 622,631 ****
--- 632,643 ----
return ((SOAPTextImpl)node).getDomElement();
} else if (node instanceof SOAPCommentImpl) {
return ((SOAPCommentImpl)node).getDomElement();
} else if (node instanceof CDATAImpl) {
return ((CDATAImpl) node).getDomElement();
+ } else if (node instanceof SOAPDocumentFragment) {
+ return ((SOAPDocumentFragment)node).getDomNode();
}
return node;
}
*** 634,643 ****
--- 646,657 ----
return new SOAPTextImpl(this, (Text) node);
} else if (SOAPCommentImpl.class.isAssignableFrom(nodeType)) {
return new SOAPCommentImpl(this, (Comment) node);
} else if (CDATAImpl.class.isAssignableFrom(nodeType)) {
return new CDATAImpl(this, (CDATASection) node);
+ } else if (SOAPDocumentFragment.class.isAssignableFrom(nodeType)) {
+ return new SOAPDocumentFragment(this, (DocumentFragment) node);
}
try {
Constructor<Node> constructor = nodeType.getConstructor(SOAPDocumentImpl.class, Element.class);
return constructor.newInstance(this, node);
} catch (Exception e) {
< prev index next >