You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2011/08/29 22:13:51 UTC
svn commit: r1162975 - in /webservices/commons/trunk/modules/axiom/modules:
axiom-api/src/main/java/org/apache/axiom/om/xpath/
axiom-tests/src/test/java/org/apache/axiom/attachments/
axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/
Author: veithen
Date: Mon Aug 29 20:13:51 2011
New Revision: 1162975
URL: http://svn.apache.org/viewvc?rev=1162975&view=rev
Log:
OMNamespace objects should always be created using the appropriate factory methods.
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/xpath/DocumentNavigator.java
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/ImageSampleTest.java
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMOutputTest.java
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMSourcedElementTest.java
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/xpath/DocumentNavigator.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/xpath/DocumentNavigator.java?rev=1162975&r1=1162974&r2=1162975&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/xpath/DocumentNavigator.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/xpath/DocumentNavigator.java Mon Aug 29 20:13:51 2011
@@ -29,7 +29,6 @@ import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMNode;
import org.apache.axiom.om.OMProcessingInstruction;
import org.apache.axiom.om.OMText;
-import org.apache.axiom.om.impl.OMNamespaceImpl;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.axiom.om.util.StAXUtils;
import org.jaxen.BaseXPath;
@@ -359,9 +358,10 @@ public class DocumentNavigator extends D
contextNode instanceof OMElement)) {
return JaxenConstants.EMPTY_ITERATOR;
}
+ OMContainer omContextNode = (OMContainer) contextNode;
List nsList = new ArrayList();
HashSet prefixes = new HashSet();
- for (OMContainer context = (OMContainer) contextNode;
+ for (OMContainer context = omContextNode;
context != null && !(context instanceof OMDocument);
context = ((OMElement) context).getParent()) {
OMElement element = (OMElement) context;
@@ -393,10 +393,10 @@ public class DocumentNavigator extends D
}
nsList.add(
new OMNamespaceEx(
- new OMNamespaceImpl(
+ omContextNode.getOMFactory().createOMNamespace(
"http://www.w3.org/XML/1998/namespace",
"xml"),
- (OMContainer) contextNode));
+ omContextNode));
return nsList.iterator();
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/ImageSampleTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/ImageSampleTest.java?rev=1162975&r1=1162974&r2=1162975&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/ImageSampleTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/ImageSampleTest.java Mon Aug 29 20:13:51 2011
@@ -23,9 +23,9 @@ import org.apache.axiom.om.AbstractTestC
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMOutputFormat;
import org.apache.axiom.om.OMText;
-import org.apache.axiom.om.impl.OMNamespaceImpl;
import org.apache.axiom.om.impl.llom.OMElementImpl;
import org.apache.axiom.om.impl.llom.OMTextImpl;
import org.apache.axiom.om.util.StAXUtils;
@@ -91,12 +91,12 @@ public class ImageSampleTest extends Abs
baseOutputFormat.setDoOptimize(false);
OMFactory fac = OMAbstractFactory.getOMFactory();
- OMNamespaceImpl soap = new OMNamespaceImpl(
+ OMNamespace soap = fac.createOMNamespace(
"http://schemas.xmlsoap.org/soap/envelope/", "soap");
OMElement envelope = new OMElementImpl("Envelope", soap, fac);
OMElement body = new OMElementImpl("Body", soap, fac);
- OMNamespaceImpl dataName = new OMNamespaceImpl(
+ OMNamespace dataName = fac.createOMNamespace(
"http://www.example.org/stuff", "m");
OMElement data = new OMElementImpl("data", dataName, fac);
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMOutputTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMOutputTest.java?rev=1162975&r1=1162974&r2=1162975&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMOutputTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMOutputTest.java Mon Aug 29 20:13:51 2011
@@ -25,8 +25,8 @@ import org.apache.axiom.om.OMAbstractFac
import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMOutputFormat;
-import org.apache.axiom.om.impl.OMNamespaceImpl;
import javax.activation.DataHandler;
import java.io.File;
@@ -63,16 +63,16 @@ public class OMOutputTest extends Abstra
OMFactory fac = OMAbstractFactory.getOMFactory();
- OMNamespaceImpl soap = new OMNamespaceImpl(
+ OMNamespace soap = fac.createOMNamespace(
"http://schemas.xmlsoap.org/soap/envelope/", "soap");
envelope = new OMElementImpl("Envelope", soap, fac);
OMElement body = new OMElementImpl("Body", soap, fac);
- OMNamespaceImpl dataName = new OMNamespaceImpl(
+ OMNamespace dataName = fac.createOMNamespace(
"http://www.example.org/stuff", "m");
OMElement data = new OMElementImpl("data", dataName, fac);
- OMNamespaceImpl mime = new OMNamespaceImpl(
+ OMNamespace mime = fac.createOMNamespace(
"http://www.w3.org/2003/06/xmlmime", "mime");
OMElement text = new OMElementImpl("name", dataName, fac);
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMSourcedElementTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMSourcedElementTest.java?rev=1162975&r1=1162974&r2=1162975&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMSourcedElementTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMSourcedElementTest.java Mon Aug 29 20:13:51 2011
@@ -31,7 +31,6 @@ import org.apache.axiom.om.OMOutputForma
import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.om.OMXMLParserWrapper;
import org.apache.axiom.om.ds.CharArrayDataSource;
-import org.apache.axiom.om.impl.OMNamespaceImpl;
import org.apache.axiom.om.impl.llom.factory.OMLinkedListImplFactory;
import org.apache.axiom.om.impl.serialize.StreamingOMSerializer;
import org.apache.axiom.om.util.StAXUtils;
@@ -93,8 +92,8 @@ public class OMSourcedElementTest extend
protected void setUp() throws Exception {
OMFactory f = new OMLinkedListImplFactory();
- OMNamespace ns = new OMNamespaceImpl("http://www.sosnoski.com/uwjws/library", "");
- OMNamespace rootNS = new OMNamespaceImpl("http://sampleroot", "rootPrefix");
+ OMNamespace ns = f.createOMNamespace("http://www.sosnoski.com/uwjws/library", "");
+ OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
element = new OMSourcedElementImpl("library", ns, f, new TestDataSource(testDocument));
root = f.createOMElement("root", rootNS);
root.addChild(element);
@@ -108,8 +107,8 @@ public class OMSourcedElementTest extend
// Build a root element and child OMSE
OMFactory f = new OMLinkedListImplFactory();
- OMNamespace ns = new OMNamespaceImpl("http://www.sosnoski.com/uwjws/library", "");
- OMNamespace rootNS = new OMNamespaceImpl("http://sampleroot", "rootPrefix");
+ OMNamespace ns = f.createOMNamespace("http://www.sosnoski.com/uwjws/library", "");
+ OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
OMElement child = new OMSourcedElementImpl("library", ns, f, new TestDataSource(testDocument));
OMElement root = f.createOMElement("root", rootNS);
@@ -310,9 +309,9 @@ public class OMSourcedElementTest extend
OMFactory f = new OMLinkedListImplFactory();
// Create OMSE with a DUMMYPREFIX prefix even though the underlying element uses the default prefix
- OMNamespace rootNS = new OMNamespaceImpl("http://sampleroot", "rootPrefix");
+ OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
OMNamespace ns =
- new OMNamespaceImpl("http://www.sosnoski.com/uwjws/library", "DUMMYPREFIX");
+ f.createOMNamespace("http://www.sosnoski.com/uwjws/library", "DUMMYPREFIX");
OMElement element =
new OMSourcedElementImpl("library", ns, f, new TestDataSource(testDocument));
OMElement root = f.createOMElement("root", rootNS);
@@ -370,9 +369,9 @@ public class OMSourcedElementTest extend
OMFactory f = new OMLinkedListImplFactory();
// Create OMSE with a DUMMYPREFIX prefix even though the underlying element uses the default prefix
- OMNamespace rootNS = new OMNamespaceImpl("http://sampleroot", "rootPrefix");
+ OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
OMNamespace ns =
- new OMNamespaceImpl("http://www.sosnoski.com/uwjws/library", "DUMMYPREFIX");
+ f.createOMNamespace("http://www.sosnoski.com/uwjws/library", "DUMMYPREFIX");
OMElement element =
new OMSourcedElementImpl("library", ns, f, new TestDataSource(testDocument));
OMElement root = f.createOMElement("root", rootNS);
@@ -415,8 +414,8 @@ public class OMSourcedElementTest extend
OMFactory f = new OMLinkedListImplFactory();
// Create OMSE with a DUMMYPREFIX prefix even though the underlying element uses the default prefix
- OMNamespace rootNS = new OMNamespaceImpl("http://sampleroot", "rootPrefix");
- OMNamespace ns = new OMNamespaceImpl("http://DUMMYNS", "DUMMYPREFIX");
+ OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
+ OMNamespace ns = f.createOMNamespace("http://DUMMYNS", "DUMMYPREFIX");
OMElement element =
new OMSourcedElementImpl("DUMMYNAME", ns, f, new TestDataSource(testDocument));
OMElement root = f.createOMElement("root", rootNS);
@@ -484,8 +483,8 @@ public class OMSourcedElementTest extend
OMFactory f = new OMLinkedListImplFactory();
// Create OMSE with a DUMMYPREFIX prefix even though the underlying element uses the default prefix
- OMNamespace rootNS = new OMNamespaceImpl("http://sampleroot", "rootPrefix");
- OMNamespace ns = new OMNamespaceImpl("http://DUMMYNS", "DUMMYPREFIX");
+ OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
+ OMNamespace ns = f.createOMNamespace("http://DUMMYNS", "DUMMYPREFIX");
OMElement element =
new OMSourcedElementImpl("DUMMYNAME", ns, f, new TestDataSource(testDocument));
OMElement root = f.createOMElement("root", rootNS);
@@ -525,8 +524,8 @@ public class OMSourcedElementTest extend
OMFactory f = new OMLinkedListImplFactory();
// Create OMSE with a DUMMYPREFIX prefix even though the underlying element uses the default prefix
- OMNamespace rootNS = new OMNamespaceImpl("http://sampleroot", "rootPrefix");
- OMNamespace ns = new OMNamespaceImpl("http://www.sosnoski.com/uwjws/library", "");
+ OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
+ OMNamespace ns = f.createOMNamespace("http://www.sosnoski.com/uwjws/library", "");
OMElement element =
new OMSourcedElementImpl("library", ns, f, new TestDataSource(testDocument2));
OMElement root = f.createOMElement("root", rootNS);
@@ -584,8 +583,8 @@ public class OMSourcedElementTest extend
OMFactory f = new OMLinkedListImplFactory();
// Create OMSE with a DUMMYPREFIX prefix even though the underlying element uses the default prefix
- OMNamespace rootNS = new OMNamespaceImpl("http://sampleroot", "rootPrefix");
- OMNamespace ns = new OMNamespaceImpl("http://www.sosnoski.com/uwjws/library", "");
+ OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
+ OMNamespace ns = f.createOMNamespace("http://www.sosnoski.com/uwjws/library", "");
OMElement element =
new OMSourcedElementImpl("library", ns, f, new TestDataSource(testDocument2));
OMElement root = f.createOMElement("root", rootNS);
@@ -627,8 +626,8 @@ public class OMSourcedElementTest extend
OMFactory f = new OMLinkedListImplFactory();
// Create OMSE with a DUMMYPREFIX prefix even though the underlying element uses the default prefix
- OMNamespace rootNS = new OMNamespaceImpl("http://sampleroot", "rootPrefix");
- OMNamespace ns = new OMNamespaceImpl("http://DUMMYNS", "DUMMYPREFIX");
+ OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
+ OMNamespace ns = f.createOMNamespace("http://DUMMYNS", "DUMMYPREFIX");
OMElement element =
new OMSourcedElementImpl("DUMMYNAME", ns, f, new TestDataSource(testDocument2));
OMElement root = f.createOMElement("root", rootNS);
@@ -696,8 +695,8 @@ public class OMSourcedElementTest extend
OMFactory f = new OMLinkedListImplFactory();
// Create OMSE with a DUMMYPREFIX prefix even though the underlying element uses the default prefix
- OMNamespace rootNS = new OMNamespaceImpl("http://sampleroot", "rootPrefix");
- OMNamespace ns = new OMNamespaceImpl("http://DUMMYNS", "");
+ OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
+ OMNamespace ns = f.createOMNamespace("http://DUMMYNS", "");
OMElement element =
new OMSourcedElementImpl("DUMMYNAME", ns, f, new TestDataSource(testDocument2));
OMElement root = f.createOMElement("root", rootNS);
@@ -739,8 +738,8 @@ public class OMSourcedElementTest extend
OMFactory f = new OMLinkedListImplFactory();
// Create OMSE with a DUMMYPREFIX prefix even though the underlying element uses the default prefix
- OMNamespace rootNS = new OMNamespaceImpl("http://sampleroot", "rootPrefix");
- OMNamespace ns = new OMNamespaceImpl("", "");
+ OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
+ OMNamespace ns = f.createOMNamespace("", "");
OMElement element =
new OMSourcedElementImpl("library", ns, f, new TestDataSource(testDocument3));
OMElement root = f.createOMElement("root", rootNS);
@@ -797,8 +796,8 @@ public class OMSourcedElementTest extend
OMFactory f = new OMLinkedListImplFactory();
// Create OMSE with a DUMMYPREFIX prefix even though the underlying element uses the default prefix
- OMNamespace rootNS = new OMNamespaceImpl("http://sampleroot", "rootPrefix");
- OMNamespace ns = new OMNamespaceImpl("", "");
+ OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
+ OMNamespace ns = f.createOMNamespace("", "");
OMElement element =
new OMSourcedElementImpl("library", ns, f, new TestDataSource(testDocument3));
OMElement root = f.createOMElement("root", rootNS);
@@ -838,8 +837,8 @@ public class OMSourcedElementTest extend
OMFactory f = new OMLinkedListImplFactory();
// Create OMSE with a DUMMYPREFIX prefix even though the underlying element uses the default prefix
- OMNamespace rootNS = new OMNamespaceImpl("http://sampleroot", "rootPrefix");
- OMNamespace ns = new OMNamespaceImpl("http://DUMMYNS", "DUMMYPREFIX");
+ OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
+ OMNamespace ns = f.createOMNamespace("http://DUMMYNS", "DUMMYPREFIX");
OMElement element =
new OMSourcedElementImpl("DUMMYNAME", ns, f, new TestDataSource(testDocument3));
OMElement root = f.createOMElement("root", rootNS);
@@ -906,8 +905,8 @@ public class OMSourcedElementTest extend
OMFactory f = new OMLinkedListImplFactory();
// Create OMSE with a DUMMYPREFIX prefix even though the underlying element uses the default prefix
- OMNamespace rootNS = new OMNamespaceImpl("http://sampleroot", "rootPrefix");
- OMNamespace ns = new OMNamespaceImpl("http://DUMMYNS", "");
+ OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
+ OMNamespace ns = f.createOMNamespace("http://DUMMYNS", "");
OMElement element =
new OMSourcedElementImpl("DUMMYNAME", ns, f, new TestDataSource(testDocument3));
OMElement root = f.createOMElement("root", rootNS);