< prev index next >
src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/ElementImpl.java
Print this page
@@ -25,25 +25,41 @@
package com.sun.xml.internal.messaging.saaj.soap.impl;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
-import javax.xml.soap.*;
-import org.w3c.dom.*;
import org.w3c.dom.Node;
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocument;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
-import com.sun.xml.internal.messaging.saaj.util.*;
+import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
+import com.sun.xml.internal.messaging.saaj.util.NamespaceContextIterator;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPBodyElement;
+import javax.xml.soap.SOAPConstants;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import org.w3c.dom.Attr;
+import org.w3c.dom.CharacterData;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.TypeInfo;
+import org.w3c.dom.UserDataHandler;
public class ElementImpl implements SOAPElement, SOAPBodyElement {
public static final String DSIG_NS = "http://www.w3.org/2000/09/xmldsig#".intern();
public static final String XENC_NS = "http://www.w3.org/2001/04/xmlenc#".intern();
@@ -106,11 +122,11 @@
return element.removeAttributeNode(oldAttr);
}
@Override
public NodeList getElementsByTagName(String name) {
- return new NodeListImpl(getSoapDocument(), element.getElementsByTagName(name));
+ return new NodeListImpl(soapDocument, element.getElementsByTagName(name));
}
@Override
public String getAttributeNS(String namespaceURI, String localName) throws DOMException {
return element.getAttributeNS(namespaceURI, localName);
@@ -137,25 +153,25 @@
public ElementImpl(SOAPDocumentImpl ownerDoc, Name name) {
this.soapDocument = ownerDoc;
this.element = ownerDoc.getDomDocument().createElementNS(name.getURI(), name.getQualifiedName());
elementQName = NameImpl.convertToQName(name);
- getSoapDocument().register(this);
+ soapDocument.register(this);
}
public ElementImpl(SOAPDocumentImpl ownerDoc, QName name) {
this.soapDocument = ownerDoc;
this.element = ownerDoc.getDomDocument().createElementNS(name.getNamespaceURI(), getQualifiedName(name));
elementQName = name;
- getSoapDocument().register(this);
+ soapDocument.register(this);
}
public ElementImpl(SOAPDocumentImpl ownerDoc, Element domElement) {
this.element = domElement;
this.soapDocument = ownerDoc;
this.elementQName = new QName(domElement.getNamespaceURI(), domElement.getLocalName());
- getSoapDocument().register(this);
+ soapDocument.register(this);
}
public ElementImpl(
SOAPDocumentImpl ownerDoc,
String uri,
@@ -163,11 +179,11 @@
this.soapDocument = ownerDoc;
this.element = ownerDoc.getDomDocument().createElementNS(uri, qualifiedName);
elementQName =
new QName(uri, getLocalPart(qualifiedName), getPrefix(qualifiedName));
- getSoapDocument().register(this);
+ soapDocument.register(this);
}
public void ensureNamespaceIsDeclared(String prefix, String uri) {
String alreadyDeclaredUri = getNamespaceURI(prefix);
if (alreadyDeclaredUri == null || !alreadyDeclaredUri.equals(uri)) {
@@ -176,32 +192,33 @@
} catch (SOAPException e) { /*ignore*/
}
}
}
+ @Override
public Document getOwnerDocument() {
return soapDocument;
}
@Override
public Node insertBefore(Node newChild, Node refChild) throws DOMException {
- return element.insertBefore(getSoapDocument().getDomNode(newChild), getSoapDocument().getDomNode(refChild));
+ return soapDocument.findIfPresent(element.insertBefore(soapDocument.getDomNode(newChild), soapDocument.getDomNode(refChild)));
}
@Override
public Node replaceChild(Node newChild, Node oldChild) throws DOMException {
- return element.replaceChild(getSoapDocument().getDomNode(newChild), getSoapDocument().getDomNode(oldChild));
+ return soapDocument.findIfPresent(element.replaceChild(soapDocument.getDomNode(newChild), soapDocument.getDomNode(oldChild)));
}
@Override
public Node removeChild(Node oldChild) throws DOMException {
- return element.removeChild(getSoapDocument().getDomNode(oldChild));
+ return soapDocument.findIfPresent(element.removeChild(soapDocument.getDomNode(oldChild)));
}
@Override
public Node appendChild(Node newChild) throws DOMException {
- return element.appendChild(getSoapDocument().getDomNode(newChild));
+ return soapDocument.findIfPresent(element.appendChild(soapDocument.getDomNode(newChild)));
}
@Override
public boolean hasChildNodes() {
return element.hasChildNodes();
@@ -305,26 +322,30 @@
@Override
public Object getUserData(String key) {
return element.getUserData(key);
}
+ @Override
public SOAPElement addChildElement(Name name) throws SOAPException {
return addElement(name);
}
+ @Override
public SOAPElement addChildElement(QName qname) throws SOAPException {
return addElement(qname);
}
+ @Override
public SOAPElement addChildElement(String localName) throws SOAPException {
String nsUri = getNamespaceURI("");
Name name = (nsUri == null || nsUri.isEmpty())
? NameImpl.createFromUnqualifiedName(localName)
: NameImpl.createFromQualifiedName(localName, nsUri);
return addChildElement(name);
}
+ @Override
public SOAPElement addChildElement(String localName, String prefix)
throws SOAPException {
String uri = getNamespaceURI(prefix);
if (uri == null) {
log.log(
@@ -335,10 +356,11 @@
"Unable to locate namespace for prefix " + prefix);
}
return addChildElement(localName, prefix, uri);
}
+ @Override
public String getNamespaceURI(String prefix) {
if ("xmlns".equals(prefix)) {
return XMLNS_URI;
}
@@ -413,16 +435,18 @@
}
return null;
}
+ @Override
public SOAPElement setElementQName(QName newName) throws SOAPException {
ElementImpl copy =
new ElementImpl((SOAPDocumentImpl) getOwnerDocument(), newName);
return replaceElementWithSOAPElement(this,copy);
}
+ @Override
public QName createQName(String localName, String prefix)
throws SOAPException {
String uri = getNamespaceURI(prefix);
if (uri == null) {
log.log(Level.SEVERE, "SAAJ0102.impl.cannot.locate.ns",
@@ -483,10 +507,11 @@
public NamespaceContextIterator getNamespaceContextNodes(boolean traverseStack) {
return new NamespaceContextIterator(this, traverseStack);
}
+ @Override
public SOAPElement addChildElement(
String localName,
String prefix,
String uri)
throws SOAPException {
@@ -494,10 +519,11 @@
SOAPElement newElement = createElement(NameImpl.create(localName, prefix, uri));
addNode(newElement);
return convertToSoapElement(newElement);
}
+ @Override
public SOAPElement addChildElement(SOAPElement element)
throws SOAPException {
// check if Element falls in SOAP 1.1 or 1.2 namespace.
String elementURI = element.getElementName().getURI();
@@ -529,11 +555,11 @@
// if body is not empty throw an exception
if (!elementURI.equals(this.getElementName().getURI())) {
log.severe("SAAJ0158.impl.version.mismatch.fault");
throw new SOAPExceptionImpl("SOAP Version mismatch encountered when trying to add SOAPFault to SOAPBody");
}
- Iterator<Node> it = this.getChildElements();
+ Iterator<javax.xml.soap.Node> it = this.getChildElements();
if (it.hasNext()) {
log.severe("SAAJ0156.impl.adding.fault.error");
throw new SOAPExceptionImpl("Cannot add SOAPFault as a child of a non-Empty SOAPBody");
}
}
@@ -601,11 +627,11 @@
getOwnerDocument().createElement(getQualifiedName(name));
}
}
protected void addNode(org.w3c.dom.Node newElement) throws SOAPException {
- insertBefore(getSoapDocument().getDomNode(newElement), null);
+ insertBefore(soapDocument.getDomNode(newElement), null);
if (getOwnerDocument() instanceof DocumentFragment)
return;
if (newElement instanceof ElementImpl) {
@@ -621,22 +647,22 @@
Element getFirstChildElement() {
Node child = getFirstChild();
while (child != null) {
if (child instanceof Element) {
- return (Element) getSoapDocument().find(child);
+ return (Element) soapDocument.find(child);
}
child = child.getNextSibling();
}
return null;
}
protected SOAPElement findChild(NameImpl name) {
Node eachChild = getFirstChild();
while (eachChild != null) {
if (eachChild instanceof Element) {
- SOAPElement eachChildSoap = (SOAPElement) getSoapDocument().find(eachChild);
+ SOAPElement eachChildSoap = (SOAPElement) soapDocument.find(eachChild);
if (eachChildSoap != null) {
if (eachChildSoap.getElementName().equals(name)) {
return eachChildSoap;
}
}
@@ -656,10 +682,11 @@
}
return null;
}
+ @Override
public SOAPElement addTextNode(String text) throws SOAPException {
if (text.startsWith(CDATAImpl.cdataUC)
|| text.startsWith(CDATAImpl.cdataLC))
return addCDATA(
text.substring(CDATAImpl.cdataUC.length(), text.length() - 3));
@@ -678,19 +705,21 @@
getOwnerDocument().createTextNode(text);
addNode(textNode);
return this;
}
+ @Override
public SOAPElement addAttribute(Name name, String value)
throws SOAPException {
addAttributeBare(name, value);
if (!"".equals(name.getURI())) {
ensureNamespaceIsDeclared(name.getPrefix(), name.getURI());
}
return this;
}
+ @Override
public SOAPElement addAttribute(QName qname, String value)
throws SOAPException {
addAttributeBare(qname, value);
if (!"".equals(qname.getNamespaceURI())) {
ensureNamespaceIsDeclared(qname.getPrefix(), qname.getNamespaceURI());
@@ -729,10 +758,11 @@
} else {
setAttributeNS(uri, qualifiedName, value);
}
}
+ @Override
public SOAPElement addNamespaceDeclaration(String prefix, String uri)
throws SOAPException {
if (prefix.length() > 0) {
setAttributeNS(XMLNS_URI, "xmlns:" + prefix, uri);
} else {
@@ -741,52 +771,58 @@
//Fix for CR:6474641
//tryToFindEncodingStyleAttributeName();
return this;
}
+ @Override
public String getAttributeValue(Name name) {
return getAttributeValueFrom(this, name);
}
+ @Override
public String getAttributeValue(QName qname) {
return getAttributeValueFrom(
this,
qname.getNamespaceURI(),
qname.getLocalPart(),
qname.getPrefix(),
getQualifiedName(qname));
}
- public Iterator getAllAttributes() {
+ @Override
+ public Iterator<Name> getAllAttributes() {
Iterator<Name> i = getAllAttributesFrom(this);
- ArrayList<Name> list = new ArrayList<Name>();
+ ArrayList<Name> list = new ArrayList<>();
while (i.hasNext()) {
Name name = i.next();
if (!"xmlns".equalsIgnoreCase(name.getPrefix()))
list.add(name);
}
return list.iterator();
}
- public Iterator getAllAttributesAsQNames() {
+ @Override
+ public Iterator<QName> getAllAttributesAsQNames() {
Iterator<Name> i = getAllAttributesFrom(this);
- ArrayList<QName> list = new ArrayList<QName>();
+ ArrayList<QName> list = new ArrayList<>();
while (i.hasNext()) {
Name name = i.next();
if (!"xmlns".equalsIgnoreCase(name.getPrefix())) {
list.add(NameImpl.convertToQName(name));
}
}
return list.iterator();
}
- public Iterator getNamespacePrefixes() {
+ @Override
+ public Iterator<String> getNamespacePrefixes() {
return doGetNamespacePrefixes(false);
}
- public Iterator getVisibleNamespacePrefixes() {
+ @Override
+ public Iterator<String> getVisibleNamespacePrefixes() {
return doGetNamespacePrefixes(true);
}
protected Iterator<String> doGetNamespacePrefixes(final boolean deep) {
return new Iterator<String>() {
@@ -803,15 +839,17 @@
next = attributeKey.substring("xmlns:".length());
}
}
}
+ @Override
public boolean hasNext() {
findNext();
return next != null;
}
+ @Override
public String next() {
findNext();
if (next == null) {
throw new NoSuchElementException();
}
@@ -819,10 +857,11 @@
last = next;
next = null;
return last;
}
+ @Override
public void remove() {
if (last == null) {
throw new IllegalStateException();
}
eachNamespace.remove();
@@ -830,22 +869,26 @@
last = null;
}
};
}
+ @Override
public Name getElementName() {
return NameImpl.convertToName(elementQName);
}
+ @Override
public QName getElementQName() {
return elementQName;
}
+ @Override
public boolean removeAttribute(Name name) {
return removeAttribute(name.getURI(), name.getLocalName());
}
+ @Override
public boolean removeAttribute(QName name) {
return removeAttribute(name.getNamespaceURI(), name.getLocalPart());
}
private boolean removeAttribute(String uri, String localName) {
@@ -858,10 +901,11 @@
}
removeAttributeNode(attribute);
return true;
}
+ @Override
public boolean removeNamespaceDeclaration(String prefix) {
org.w3c.dom.Attr declaration = getNamespaceAttr(prefix);
if (declaration == null) {
return false;
}
@@ -871,77 +915,163 @@
// ignore
}
return true;
}
- public Iterator<Node> getChildElements() {
+ @Override
+ public Iterator<javax.xml.soap.Node> getChildElements() {
return getChildElementsFrom(this);
}
protected SOAPElement convertToSoapElement(Element element) {
- final Node soapNode = getSoapDocument().findIfPresent(element);
+ final Node soapNode = soapDocument.findIfPresent(element);
if (soapNode instanceof SOAPElement) {
return (SOAPElement) soapNode;
} else {
return replaceElementWithSOAPElement(
element,
(ElementImpl) createElement(NameImpl.copyElementName(element)));
}
}
+ protected TextImpl convertToSoapText(CharacterData characterData) {
+ final Node soapNode = getSoapDocument().findIfPresent(characterData);
+ if (soapNode instanceof TextImpl) {
+ return (TextImpl) soapNode;
+ } else {
+ TextImpl t = null;
+ switch (characterData.getNodeType()) {
+ case CDATA_SECTION_NODE:
+ t = new CDATAImpl(getSoapDocument(), characterData.getData());
+ break;
+ case COMMENT_NODE:
+ t = new SOAPCommentImpl(getSoapDocument(), characterData.getData());
+ break;
+ case TEXT_NODE:
+ t = new SOAPTextImpl(getSoapDocument(), characterData.getData());
+ break;
+ }
+ Node parent = getSoapDocument().find(characterData.getParentNode());
+ if (parent != null) {
+ parent.replaceChild(t, characterData);
+ } // XXX else throw an exception?
+
+ return t;
+
+// return replaceElementWithSOAPElement(
+// element,
+// (ElementImpl) createElement(NameImpl.copyElementName(element)));
+ }
+ }
+
protected SOAPElement replaceElementWithSOAPElement(
Element element,
ElementImpl copy) {
Iterator<Name> eachAttribute = getAllAttributesFrom(element);
while (eachAttribute.hasNext()) {
Name name = eachAttribute.next();
copy.addAttributeBare(name, getAttributeValueFrom(element, name));
}
- Iterator<Node> eachChild = getChildElementsFrom(element);
+ Iterator<Node> eachChild = getChildElementsFromDOM(element);
while (eachChild.hasNext()) {
Node nextChild = eachChild.next();
copy.insertBefore(nextChild, null);
}
- Node parent = getSoapDocument().find(element.getParentNode());
+ Node parent = soapDocument.find(element.getParentNode());
if (parent != null) {
parent.replaceChild(copy, element);
} // XXX else throw an exception?
return copy;
}
+ private Iterator<Node> getChildElementsFromDOM(final Element el) {
+ return new Iterator<Node>() {
+ Node next = el.getFirstChild();
+ Node nextNext = null;
+ Node last = null;
+ Node soapElement = getSoapDocument().findIfPresent(el);
+
+ @Override
+ public boolean hasNext() {
+ if (next != null) {
+ return true;
+ }
+ if (nextNext != null) {
+ next = nextNext;
+ }
+
+ return next != null;
+ }
+
+ public Node next() {
+ if (hasNext()) {
+ last = next;
+ next = null;
+
+ if ((soapElement instanceof ElementImpl)
+ && (last instanceof Element)) {
+ last =
+ ((ElementImpl) soapElement).convertToSoapElement(
+ (Element) last);
+ } else if ((soapElement instanceof ElementImpl) && (last instanceof CharacterData)) {
+ last = ((ElementImpl) soapElement).convertToSoapText(
+ (CharacterData) last);
+ }
+
+ nextNext = last.getNextSibling();
+ return last;
+ }
+ throw new NoSuchElementException();
+ }
+
+ @Override
+ public void remove() {
+ if (last == null) {
+ throw new IllegalStateException();
+ }
+ Node target = last;
+ last = null;
+ el.removeChild(target);
+ }
+ };
+ }
+
protected Iterator<Node> getChildElementNodes() {
return new Iterator<Node>() {
- Iterator<Node> eachNode = getChildElements();
+ Iterator<javax.xml.soap.Node> eachNode = getChildElements();
Node next = null;
Node last = null;
+ @Override
public boolean hasNext() {
if (next == null) {
while (eachNode.hasNext()) {
Node node = eachNode.next();
if (node instanceof Element) {
- next = getSoapDocument().findIfPresent(node);
+ next = soapDocument.findIfPresent(node);
break;
}
}
}
return next != null;
}
- public Node next() {
+ @Override
+ public javax.xml.soap.Node next() {
if (hasNext()) {
last = next;
next = null;
- return last;
+ return (javax.xml.soap.Node) last;
}
throw new NoSuchElementException();
}
+ @Override
public void remove() {
if (last == null) {
throw new IllegalStateException();
}
Node target = last;
@@ -949,24 +1079,27 @@
removeChild(target);
}
};
}
- public Iterator getChildElements(final Name name) {
+ @Override
+ public Iterator<javax.xml.soap.Node> getChildElements(final Name name) {
return getChildElements(name.getURI(), name.getLocalName());
}
- public Iterator getChildElements(final QName qname) {
+ @Override
+ public Iterator<javax.xml.soap.Node> getChildElements(final QName qname) {
return getChildElements(qname.getNamespaceURI(), qname.getLocalPart());
}
- private Iterator<Node> getChildElements(final String nameUri, final String nameLocal) {
- return new Iterator<Node>() {
+ private Iterator<javax.xml.soap.Node> getChildElements(final String nameUri, final String nameLocal) {
+ return new Iterator<javax.xml.soap.Node>() {
Iterator<Node> eachElement = getChildElementNodes();
Node next = null;
Node last = null;
+ @Override
public boolean hasNext() {
if (next == null) {
while (eachElement.hasNext()) {
Node element = eachElement.next();
String elementUri = element.getNamespaceURI();
@@ -980,19 +1113,21 @@
}
}
return next != null;
}
- public Node next() {
+ @Override
+ public javax.xml.soap.Node next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
last = next;
next = null;
- return last;
+ return (javax.xml.soap.Node) last;
}
+ @Override
public void remove() {
if (last == null) {
throw new IllegalStateException();
}
Node target = last;
@@ -1000,10 +1135,11 @@
removeChild(target);
}
};
}
+ @Override
public void removeContents() {
Node currentChild = getFirstChild();
while (currentChild != null) {
Node temp = currentChild.getNextSibling();
@@ -1018,10 +1154,11 @@
}
currentChild = temp;
}
}
+ @Override
public void setEncodingStyle(String encodingStyle) throws SOAPException {
if (!"".equals(encodingStyle)) {
try {
new URI(encodingStyle);
} catch (URISyntaxException m) {
@@ -1035,10 +1172,11 @@
}
encodingStyleAttribute.setValue(encodingStyle);
tryToFindEncodingStyleAttributeName();
}
+ @Override
public String getEncodingStyle() {
String encodingStyle = encodingStyleAttribute.getValue();
if (encodingStyle != null)
return encodingStyle;
String soapNamespace = getSOAPNamespace();
@@ -1056,15 +1194,17 @@
}
return null;
}
// Node methods
+ @Override
public String getValue() {
javax.xml.soap.Node valueNode = getValueNode();
return valueNode == null ? null : valueNode.getValue();
}
+ @Override
public void setValue(String value) {
Node valueNode = getValueNodeStrict();
if (valueNode != null) {
valueNode.setNodeValue(value);
} else {
@@ -1090,25 +1230,26 @@
return null;
}
protected javax.xml.soap.Node getValueNode() {
- Iterator<Node> i = getChildElements();
+ Iterator<javax.xml.soap.Node> i = getChildElements();
while (i.hasNext()) {
Node n = i.next();
if (n.getNodeType() == org.w3c.dom.Node.TEXT_NODE ||
n.getNodeType() == org.w3c.dom.Node.CDATA_SECTION_NODE) {
// TODO: Hack to fix text node split into multiple lines.
normalize();
// Should remove the normalization step when this gets fixed in
// DOM/Xerces.
- return getSoapDocument().find(n);
+ return soapDocument.find(n);
}
}
return null;
}
+ @Override
public void setParentElement(SOAPElement element) throws SOAPException {
if (element == null) {
log.severe("SAAJ0106.impl.no.null.to.parent.elem");
throw new SOAPException("Cannot pass NULL to setParentElement");
}
@@ -1136,16 +1277,17 @@
soapNamespacePrefix,
soapNamespace);
encodingStyleAttribute.setName(encodingStyleAttributeName);
}
+ @Override
public SOAPElement getParentElement() {
Node parentNode = getParentNode();
if (parentNode instanceof SOAPDocument) {
return null;
}
- return (SOAPElement) getSoapDocument().find(parentNode);
+ return (SOAPElement) soapDocument.find(parentNode);
}
protected String getSOAPNamespace() {
String soapNamespace = null;
@@ -1165,10 +1307,11 @@
}
return soapNamespace;
}
+ @Override
public void detachNode() {
Node parent = getParentNode();
if (parent != null) {
parent.removeChild(element);
}
@@ -1182,10 +1325,11 @@
findEncodingStyleAttributeName();
} catch (SOAPException e) { /*okay to fail*/
}
}
+ @Override
public void recycleNode() {
detachNode();
// TBD
// - add this to the factory so subsequent
// creations can reuse this object.
@@ -1258,14 +1402,16 @@
return new Iterator<Name>() {
int attributesLength = attributes.getLength();
int attributeIndex = 0;
String currentName;
+ @Override
public boolean hasNext() {
return attributeIndex < attributesLength;
}
+ @Override
public Name next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
Node current = attributes.item(attributeIndex++);
@@ -1281,10 +1427,11 @@
current.getNamespaceURI());
return attributeName;
}
}
+ @Override
public void remove() {
if (currentName == null) {
throw new IllegalStateException();
}
attributes.removeNamedItem(currentName);
@@ -1329,17 +1476,18 @@
attribute = element.getAttributeNode(qualifiedName);
return attribute == null ? null : attribute.getValue();
}
- protected Iterator<Node> getChildElementsFrom(final Element element) {
- return new Iterator<Node>() {
+ protected Iterator<javax.xml.soap.Node> getChildElementsFrom(final Element element) {
+ return new Iterator<javax.xml.soap.Node>() {
Node next = element.getFirstChild();
Node nextNext = null;
Node last = null;
- Node soapElement = getSoapDocument().findIfPresent(element);
+ Node soapElement = soapDocument.findIfPresent(element);
+ @Override
public boolean hasNext() {
if (next != null) {
return true;
}
if (nextNext != null) {
@@ -1347,11 +1495,12 @@
}
return next != null;
}
- public Node next() {
+ @Override
+ public javax.xml.soap.Node next() {
if (hasNext()) {
last = next;
next = null;
if ((soapElement instanceof ElementImpl)
@@ -1360,15 +1509,16 @@
((ElementImpl) soapElement).convertToSoapElement(
(Element) last);
}
nextNext = last.getNextSibling();
- return getSoapDocument().findIfPresent(last);
+ return (javax.xml.soap.Node) soapDocument.findIfPresent(last);
}
throw new NoSuchElementException();
}
+ @Override
public void remove() {
if (last == null) {
throw new IllegalStateException();
}
Node target = last;
@@ -1426,10 +1576,11 @@
}
//TODO: This is a temporary SAAJ workaround for optimizing XWS
// should be removed once the corresponding JAXP bug is fixed
// It appears the bug will be fixed in JAXP 1.4 (not by Appserver 9 timeframe)
+ @Override
public void setAttributeNS(
String namespaceURI,String qualifiedName, String value) {
int index = qualifiedName.indexOf(':');
String localName;
if (index < 0)
@@ -1481,11 +1632,11 @@
return element.setAttributeNodeNS(newAttr);
}
@Override
public NodeList getElementsByTagNameNS(String namespaceURI, String localName) throws DOMException {
- return new NodeListImpl(getSoapDocument(), element.getElementsByTagNameNS(namespaceURI, localName));
+ return new NodeListImpl(soapDocument, element.getElementsByTagNameNS(namespaceURI, localName));
}
@Override
public boolean hasAttribute(String name) {
return element.hasAttribute(name);
@@ -1536,41 +1687,41 @@
return element.getNodeType();
}
@Override
public Node getParentNode() {
- return getSoapDocument().find(element.getParentNode());
+ return soapDocument.find(element.getParentNode());
}
@Override
public NodeList getChildNodes() {
- return new NodeListImpl(getSoapDocument(), element.getChildNodes());
+ return new NodeListImpl(soapDocument, element.getChildNodes());
}
@Override
public Node getFirstChild() {
- return getSoapDocument().findIfPresent(element.getFirstChild());
+ return soapDocument.findIfPresent(element.getFirstChild());
}
@Override
public Node getLastChild() {
- return getSoapDocument().findIfPresent(element.getLastChild());
+ return soapDocument.findIfPresent(element.getLastChild());
}
@Override
public Node getPreviousSibling() {
- return getSoapDocument().findIfPresent(element.getPreviousSibling());
+ return soapDocument.findIfPresent(element.getPreviousSibling());
}
@Override
public Node getNextSibling() {
- return getSoapDocument().findIfPresent(element.getNextSibling());
+ return soapDocument.findIfPresent(element.getNextSibling());
}
@Override
public NamedNodeMap getAttributes() {
- return element.getAttributes();
+ return new NamedNodeMapImpl(element.getAttributes(), soapDocument);
}
public Element getDomElement() {
return element;
}
< prev index next >