< prev index next >
src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/ElementImpl.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 160,171 ****
org.w3c.dom.Node currentAncestor = this;
while (currentAncestor != null &&
!(currentAncestor instanceof Document)) {
if (currentAncestor instanceof ElementImpl) {
- QName name = ((ElementImpl) currentAncestor).getElementQName();
/*
if (prefix.equals(name.getPrefix())) {
String uri = name.getNamespaceURI();
if ("".equals(uri)) {
return null;
}
--- 160,171 ----
org.w3c.dom.Node currentAncestor = this;
while (currentAncestor != null &&
!(currentAncestor instanceof Document)) {
if (currentAncestor instanceof ElementImpl) {
/*
+ QName name = ((ElementImpl) currentAncestor).getElementQName();
if (prefix.equals(name.getPrefix())) {
String uri = name.getNamespaceURI();
if ("".equals(uri)) {
return null;
}
*** 337,347 ****
// 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 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");
}
}
--- 337,347 ----
// 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();
if (it.hasNext()) {
log.severe("SAAJ0156.impl.adding.fault.error");
throw new SOAPExceptionImpl("Cannot add SOAPFault as a child of a non-Empty SOAPBody");
}
}
*** 448,458 ****
}
return null;
}
protected SOAPElement findAndConvertChildElement(NameImpl name) {
! Iterator eachChild = getChildElementNodes();
while (eachChild.hasNext()) {
SOAPElement child = (SOAPElement) eachChild.next();
if (child.getElementName().equals(name)) {
return child;
}
--- 448,458 ----
}
return null;
}
protected SOAPElement findAndConvertChildElement(NameImpl name) {
! Iterator<Node> eachChild = getChildElementNodes();
while (eachChild.hasNext()) {
SOAPElement child = (SOAPElement) eachChild.next();
if (child.getElementName().equals(name)) {
return child;
}
*** 558,582 ****
qname.getPrefix(),
getQualifiedName(qname));
}
public Iterator getAllAttributes() {
! Iterator i = getAllAttributesFrom(this);
! ArrayList list = new ArrayList();
while (i.hasNext()) {
! Name name = (Name) i.next();
if (!"xmlns".equalsIgnoreCase(name.getPrefix()))
list.add(name);
}
return list.iterator();
}
public Iterator getAllAttributesAsQNames() {
! Iterator i = getAllAttributesFrom(this);
! ArrayList list = new ArrayList();
while (i.hasNext()) {
! Name name = (Name) i.next();
if (!"xmlns".equalsIgnoreCase(name.getPrefix())) {
list.add(NameImpl.convertToQName(name));
}
}
return list.iterator();
--- 558,582 ----
qname.getPrefix(),
getQualifiedName(qname));
}
public Iterator getAllAttributes() {
! Iterator<Name> i = getAllAttributesFrom(this);
! ArrayList<Name> list = new ArrayList<Name>();
while (i.hasNext()) {
! Name name = i.next();
if (!"xmlns".equalsIgnoreCase(name.getPrefix()))
list.add(name);
}
return list.iterator();
}
public Iterator getAllAttributesAsQNames() {
! Iterator<Name> i = getAllAttributesFrom(this);
! ArrayList<QName> list = new ArrayList<QName>();
while (i.hasNext()) {
! Name name = i.next();
if (!"xmlns".equalsIgnoreCase(name.getPrefix())) {
list.add(NameImpl.convertToQName(name));
}
}
return list.iterator();
*** 589,600 ****
public Iterator getVisibleNamespacePrefixes() {
return doGetNamespacePrefixes(true);
}
! protected Iterator doGetNamespacePrefixes(final boolean deep) {
! return new Iterator() {
String next = null;
String last = null;
NamespaceContextIterator eachNamespace =
getNamespaceContextNodes(deep);
--- 589,600 ----
public Iterator getVisibleNamespacePrefixes() {
return doGetNamespacePrefixes(true);
}
! protected Iterator<String> doGetNamespacePrefixes(final boolean deep) {
! return new Iterator<String>() {
String next = null;
String last = null;
NamespaceContextIterator eachNamespace =
getNamespaceContextNodes(deep);
*** 611,621 ****
public boolean hasNext() {
findNext();
return next != null;
}
! public Object next() {
findNext();
if (next == null) {
throw new NoSuchElementException();
}
--- 611,621 ----
public boolean hasNext() {
findNext();
return next != null;
}
! public String next() {
findNext();
if (next == null) {
throw new NoSuchElementException();
}
*** 674,684 ****
// ignore
}
return true;
}
! public Iterator getChildElements() {
return getChildElementsFrom(this);
}
protected SOAPElement convertToSoapElement(Element element) {
if (element instanceof SOAPElement) {
--- 674,684 ----
// ignore
}
return true;
}
! public Iterator<Node> getChildElements() {
return getChildElementsFrom(this);
}
protected SOAPElement convertToSoapElement(Element element) {
if (element instanceof SOAPElement) {
*** 692,710 ****
protected static SOAPElement replaceElementWithSOAPElement(
Element element,
ElementImpl copy) {
! Iterator eachAttribute = getAllAttributesFrom(element);
while (eachAttribute.hasNext()) {
! Name name = (Name) eachAttribute.next();
copy.addAttributeBare(name, getAttributeValueFrom(element, name));
}
! Iterator eachChild = getChildElementsFrom(element);
while (eachChild.hasNext()) {
! Node nextChild = (Node) eachChild.next();
copy.insertBefore(nextChild, null);
}
Node parent = element.getParentNode();
if (parent != null) {
--- 692,710 ----
protected static 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);
while (eachChild.hasNext()) {
! Node nextChild = eachChild.next();
copy.insertBefore(nextChild, null);
}
Node parent = element.getParentNode();
if (parent != null) {
*** 712,741 ****
} // XXX else throw an exception?
return copy;
}
! protected Iterator getChildElementNodes() {
! return new Iterator() {
! Iterator eachNode = getChildElements();
Node next = null;
Node last = null;
public boolean hasNext() {
if (next == null) {
while (eachNode.hasNext()) {
! Node node = (Node) eachNode.next();
if (node instanceof SOAPElement) {
next = node;
break;
}
}
}
return next != null;
}
! public Object next() {
if (hasNext()) {
last = next;
next = null;
return last;
}
--- 712,741 ----
} // XXX else throw an exception?
return copy;
}
! protected Iterator<Node> getChildElementNodes() {
! return new Iterator<Node>() {
! Iterator<Node> eachNode = getChildElements();
Node next = null;
Node last = null;
public boolean hasNext() {
if (next == null) {
while (eachNode.hasNext()) {
! Node node = eachNode.next();
if (node instanceof SOAPElement) {
next = node;
break;
}
}
}
return next != null;
}
! public Node next() {
if (hasNext()) {
last = next;
next = null;
return last;
}
*** 759,778 ****
public Iterator getChildElements(final QName qname) {
return getChildElements(qname.getNamespaceURI(), qname.getLocalPart());
}
! private Iterator getChildElements(final String nameUri, final String nameLocal) {
! return new Iterator() {
! Iterator eachElement = getChildElementNodes();
Node next = null;
Node last = null;
public boolean hasNext() {
if (next == null) {
while (eachElement.hasNext()) {
! Node element = (Node) eachElement.next();
String elementUri = element.getNamespaceURI();
elementUri = elementUri == null ? "" : elementUri;
String elementName = element.getLocalName();
if (elementUri.equals(nameUri)
&& elementName.equals(nameLocal)) {
--- 759,778 ----
public Iterator getChildElements(final QName qname) {
return getChildElements(qname.getNamespaceURI(), qname.getLocalPart());
}
! private Iterator<Node> getChildElements(final String nameUri, final String nameLocal) {
! return new Iterator<Node>() {
! Iterator<Node> eachElement = getChildElementNodes();
Node next = null;
Node last = null;
public boolean hasNext() {
if (next == null) {
while (eachElement.hasNext()) {
! Node element = eachElement.next();
String elementUri = element.getNamespaceURI();
elementUri = elementUri == null ? "" : elementUri;
String elementName = element.getLocalName();
if (elementUri.equals(nameUri)
&& elementName.equals(nameLocal)) {
*** 782,792 ****
}
}
return next != null;
}
! public Object next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
last = next;
next = null;
--- 782,792 ----
}
}
return next != null;
}
! public Node next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
last = next;
next = null;
*** 892,902 ****
return null;
}
protected javax.xml.soap.Node getValueNode() {
! Iterator i = getChildElements();
while (i.hasNext()) {
javax.xml.soap.Node n = (javax.xml.soap.Node) 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.
--- 892,902 ----
return null;
}
protected javax.xml.soap.Node getValueNode() {
! Iterator<Node> i = getChildElements();
while (i.hasNext()) {
javax.xml.soap.Node n = (javax.xml.soap.Node) 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.
*** 1052,1074 ****
}
}
return null;
}
! protected static Iterator getAllAttributesFrom(final Element element) {
final NamedNodeMap attributes = element.getAttributes();
! return new Iterator() {
int attributesLength = attributes.getLength();
int attributeIndex = 0;
String currentName;
public boolean hasNext() {
return attributeIndex < attributesLength;
}
! public Object next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
Node current = attributes.item(attributeIndex++);
currentName = current.getNodeName();
--- 1052,1074 ----
}
}
return null;
}
! protected static Iterator<Name> getAllAttributesFrom(final Element element) {
final NamedNodeMap attributes = element.getAttributes();
! return new Iterator<Name>() {
int attributesLength = attributes.getLength();
int attributeIndex = 0;
String currentName;
public boolean hasNext() {
return attributeIndex < attributesLength;
}
! public Name next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
Node current = attributes.item(attributeIndex++);
currentName = current.getNodeName();
*** 1131,1142 ****
attribute = element.getAttributeNode(qualifiedName);
return attribute == null ? null : attribute.getValue();
}
! protected static Iterator getChildElementsFrom(final Element element) {
! return new Iterator() {
Node next = element.getFirstChild();
Node nextNext = null;
Node last = null;
public boolean hasNext() {
--- 1131,1142 ----
attribute = element.getAttributeNode(qualifiedName);
return attribute == null ? null : attribute.getValue();
}
! protected static Iterator<Node> getChildElementsFrom(final Element element) {
! return new Iterator<Node>() {
Node next = element.getFirstChild();
Node nextNext = null;
Node last = null;
public boolean hasNext() {
*** 1148,1158 ****
}
return next != null;
}
! public Object next() {
if (hasNext()) {
last = next;
next = null;
if ((element instanceof ElementImpl)
--- 1148,1158 ----
}
return next != null;
}
! public Node next() {
if (hasNext()) {
last = next;
next = null;
if ((element instanceof ElementImpl)
< prev index next >