Author: seanoc
Date: Mon Jan 5 07:58:18 2009
New Revision: 731604
URL: http://svn.apache.org/viewvc?rev=731604&view=rev
Log:
Removed more uses of NodeList
Modified:
cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/ReadHeaderInterceptorTest.java
cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsSimpleDomNode.java
cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
Modified:
cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/ReadHeaderInterceptorTest.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/ReadHeaderInterceptorTest.java?rev=731604&r1=731603&r2=731604&view=diff
==============================================================================
---
cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/ReadHeaderInterceptorTest.java
(original)
+++
cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/ReadHeaderInterceptorTest.java
Mon Jan 5 07:58:18 2009
@@ -37,6 +37,7 @@
import org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor;
import org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor;
import org.apache.cxf.headers.Header;
+import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.interceptor.StaxInInterceptor;
import org.apache.cxf.message.Attachment;
import org.junit.Before;
@@ -104,11 +105,10 @@
if (ele.getLocalName().equals("reservation")) {
Element reservation = ele;
List<Element> reservationChilds = new ArrayList<Element>();
- for (int j = 0; j < reservation.getChildNodes().getLength();
j++) {
- if (reservation.getChildNodes().item(j) instanceof
Element) {
- Element element =
(Element)reservation.getChildNodes().item(j);
- reservationChilds.add(element);
- }
+ Element elem = DOMUtils.getFirstElement(reservation);
+ while (elem != null) {
+ reservationChilds.add(elem);
+ elem = DOMUtils.getNextElement(elem);
}
assertEquals(2, reservationChilds.size());
assertEquals("reference",
reservationChilds.get(0).getLocalName());
@@ -122,13 +122,8 @@
if (ele.getLocalName().equals("passenger")) {
Element passenger = ele;
assertNotNull(passenger);
- Element child = null;
- for (int j = 0; j < passenger.getChildNodes().getLength();
j++) {
- if (passenger.getChildNodes().item(j) instanceof Element) {
- child = (Element)passenger.getChildNodes().item(j);
- }
- }
- assertNotNull("passenger should has child element", child);
+ Element child = DOMUtils.getFirstElement(passenger);
+ assertNotNull("passenger should have a child element", child);
assertEquals("name", child.getLocalName());
assertEquals("Bob", child.getTextContent());
}
Modified:
cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsSimpleDomNode.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsSimpleDomNode.java?rev=731604&r1=731603&r2=731604&view=diff
==============================================================================
---
cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsSimpleDomNode.java
(original)
+++
cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsSimpleDomNode.java
Mon Jan 5 07:58:18 2009
@@ -20,6 +20,8 @@
package org.apache.cxf.javascript;
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
import org.w3c.dom.Attr;
import org.w3c.dom.NamedNodeMap;
@@ -38,7 +40,7 @@
private boolean attributesWrapped;
private JsSimpleDomNode previousSibling;
private JsSimpleDomNode nextSibling;
- private JsSimpleDomNode[] children;
+ private List<JsSimpleDomNode> children;
private JsNamedNodeMap attributes;
/**
@@ -79,8 +81,8 @@
public Object jsGet_firstChild() {
establishChildren();
- if (children.length > 0)
- return children[0];
+ if (children.size() > 0)
+ return children.get(0);
else
return null;
}
@@ -116,13 +118,13 @@
return null;
} else {
establishChildren();
- return children[0]; // it is, after all, just a convenience
feature.
+ return children.get(0); // it is, after all, just a convenience
feature.
}
}
public Object[] jsGet_childNodes() {
establishChildren();
- return children;
+ return children.toArray();
}
public Object jsGet_attributes() {
@@ -175,23 +177,23 @@
private void establishChildren() {
if (!childrenWrapped) {
if (wrappedNode.hasChildNodes()) {
- children = new
JsSimpleDomNode[wrappedNode.getChildNodes().getLength()];
+ children = new ArrayList<JsSimpleDomNode>();
Node node = wrappedNode.getFirstChild();
int x = 0;
while (node != null) {
JsSimpleDomNode prev = null;
if (x > 0) {
- prev = (JsSimpleDomNode)children[x - 1];
+ prev = (JsSimpleDomNode)children.get(x - 1);
}
- children[x] = newObject(node, prev);
+ children.add(x, newObject(node, prev));
if (x > 0) {
- children[x - 1].setNext(children[x]);
+ children.get(x - 1).setNext(children.get(x));
}
node = node.getNextSibling();
x++;
}
} else {
- children = new JsSimpleDomNode[0];
+ children = new ArrayList<JsSimpleDomNode>();
}
childrenWrapped = true;
}
Modified:
cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java?rev=731604&r1=731603&r2=731604&view=diff
==============================================================================
---
cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
(original)
+++
cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
Mon Jan 5 07:58:18 2009
@@ -248,11 +248,13 @@
Element childEl = (Element)childNode;
if (isJaxbBindingsElement(childEl)) {
+
NodeList nlist = nodeSelector.queryNodes(schemaNode,
childEl.getAttribute("node"));
for (int i = 0; i < nlist.getLength(); i++) {
Node node = nlist.item(i);
copyAllJaxbDeclarations(node, childEl);
- }
+ }
+
} else {
Element cloneNode =
(Element)ProcessorUtil.cloneNode(schemaNode.getOwnerDocument(),
childEl,
true);
@@ -270,9 +272,9 @@
childNode = childNode.getNextSibling();
}
}
-
- if (schemaNode.getChildNodes().getLength() > 0) {
- schemaNode.insertBefore(annotationNode,
schemaNode.getChildNodes().item(0));
+
+ if (schemaNode.getFirstChild() != null) {
+ schemaNode.insertBefore(annotationNode,
schemaNode.getFirstChild());
} else {
schemaNode.appendChild(annotationNode);
}
@@ -370,13 +372,17 @@
}
- for (int i = 0; i < bindings.getChildNodes().getLength(); i++) {
- Node childNode = bindings.getChildNodes().item(i);
- if (childNode.getNodeType() == Element.ELEMENT_NODE
- &&
childNode.getNamespaceURI().equals(ToolConstants.JAXWS_BINDINGS.getNamespaceURI()))
{
- childNode.setPrefix("jaxws");
+
+
+ Element element = DOMUtils.getFirstElement(bindings);
+ while (element != null) {
+ if
(element.getNamespaceURI().equals(ToolConstants.JAXWS_BINDINGS.getNamespaceURI()))
{
+ element.setPrefix("jaxws");
}
+ element = DOMUtils.getNextElement(element);
}
+
+
Node cloneNode = ProcessorUtil.cloneNode(node.getOwnerDocument(),
bindings, true);
Node firstChild = DOMUtils.getChild(node, "jaxws:bindings");