ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1308046 - in /webservices/commons/trunk/modules/axiom/modules/axiom-dom/src: main/java/org/apache/axiom/om/impl/dom/ main/java/org/apache/axiom/om/impl/dom/factory/ test/java/org/apache/axiom/om/impl/dom/
Date Sun, 01 Apr 2012 09:03:42 GMT
Author: veithen
Date: Sun Apr  1 09:03:41 2012
New Revision: 1308046

URL: http://svn.apache.org/viewvc?rev=1308046&view=rev
Log:
Implemented OMElement#setText(QName) for DOOM.

Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java?rev=1308046&r1=1308045&r2=1308046&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
Sun Apr  1 09:03:41 2012
@@ -195,6 +195,23 @@ public class ElementImpl extends ParentN
         }
     }
 
+    OMNamespace handleNamespace(String namespaceURI, String prefix) {
+        if (prefix.length() == 0 && namespaceURI.length() == 0) {
+            OMNamespace namespace = getDefaultNamespace();
+            if (namespace != null) {
+                declareDefaultNamespace("");
+            }
+            return null;
+        } else {
+            OMNamespace namespace = findNamespace(namespaceURI,
+                                                  prefix);
+            if (namespace == null) {
+                namespace = declareNamespace(namespaceURI, prefix.length() > 0 ? prefix
: null);
+            }
+            return namespace;
+        }
+    }
+
     // /
     // /org.w3c.dom.Node methods
     // /

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java?rev=1308046&r1=1308045&r2=1308046&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java
Sun Apr  1 09:03:41 2012
@@ -28,6 +28,7 @@ import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMText;
 import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.impl.common.OMNamespaceImpl;
 import org.apache.axiom.util.UIDGenerator;
 import org.apache.axiom.util.base64.Base64Utils;
 import org.apache.axiom.util.stax.XMLStreamWriterUtils;
@@ -221,13 +222,9 @@ public abstract class TextNodeImpl exten
     public TextNodeImpl(OMContainer parent, QName text, int nodeType,
                         OMFactory factory) {
         this(((ElementImpl) parent).ownerDocument(), factory);
-        if (text != null) {
-            this.textNS =
-                    ((ElementImpl) parent).findNamespace(text.getNamespaceURI(), text.getPrefix());
-        } else {
-
-        }
-        this.textValue = (text == null) ? "" : text.getLocalPart();
+        this.textNS =
+                ((ElementImpl) parent).handleNamespace(text.getNamespaceURI(), text.getPrefix());
+        this.textValue = textNS == null ? text.getLocalPart() : textNS.getPrefix() + ":"
+ text.getLocalPart();
         this.done = true;
     }
 
@@ -313,9 +310,7 @@ public abstract class TextNodeImpl exten
     }
 
     public String getText() {
-        if (this.textNS != null) {
-            return getTextString();
-        } else if (this.charArray != null || this.textValue != null) {
+        if (this.charArray != null || this.textValue != null) {
             return getTextFromProperPlace();
         } else {
             try {

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java?rev=1308046&r1=1308045&r2=1308046&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
Sun Apr  1 09:03:41 2012
@@ -263,11 +263,13 @@ public class OMDOMFactory implements OMF
     }
 
     public OMText createOMText(OMContainer parent, QName text) {
-        return new TextImpl(parent, text, this);
+        return createOMText(parent, text, OMNode.TEXT_NODE);
     }
 
     public OMText createOMText(OMContainer parent, QName text, int type) {
-        return new TextImpl(parent, text, type, this);
+        TextImpl txt = new TextImpl(parent, text, type, this);
+        parent.addChild(txt);
+        return txt;
     }
 
     public OMText createOMText(OMContainer parent, String text, int type) {

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java?rev=1308046&r1=1308045&r2=1308046&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
Sun Apr  1 09:03:41 2012
@@ -29,10 +29,6 @@ import org.apache.axiom.ts.om.document.T
 import org.apache.axiom.ts.om.element.TestGetChildrenWithName4;
 import org.apache.axiom.ts.om.element.TestGetXMLStreamReaderCDATAEventFromElement;
 import org.apache.axiom.ts.om.element.TestGetXMLStreamReaderWithOMSourcedElementDescendant;
-import org.apache.axiom.ts.om.element.TestSetTextQName;
-import org.apache.axiom.ts.om.element.TestSetTextQNameWithEmptyPrefix;
-import org.apache.axiom.ts.om.element.TestSetTextQNameWithExistingChildren;
-import org.apache.axiom.ts.om.element.TestSetTextQNameWithoutNamespace;
 import org.apache.axiom.ts.om.factory.TestCreateOMElementWithGeneratedPrefix;
 import org.apache.axiom.ts.om.factory.TestCreateOMElementWithNamespaceInScope;
 import org.apache.axiom.ts.om.node.TestInsertSiblingAfterOnChild;
@@ -41,11 +37,6 @@ import org.apache.axiom.ts.om.node.TestI
 public class OMImplementationTest extends TestCase {
     public static TestSuite suite() {
         OMTestSuiteBuilder builder = new OMTestSuiteBuilder(new OMDOMMetaFactory(), false);
-        // OMElement#setText(QName) is unsupported
-        builder.exclude(TestSetTextQName.class);
-        builder.exclude(TestSetTextQNameWithEmptyPrefix.class);
-        builder.exclude(TestSetTextQNameWithExistingChildren.class);
-        builder.exclude(TestSetTextQNameWithoutNamespace.class);
         
         // TODO: doesn't work because the test trigger a call to importNode which will build
the descendant
         builder.exclude(org.apache.axiom.ts.om.document.TestSerializeAndConsumeWithIncompleteDescendant.class);



Mime
View raw message