ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1700036 - in /webservices/axiom/trunk: aspects/core-aspects/src/main/java/org/apache/axiom/core/ aspects/dom-aspects/src/main/java/org/apache/axiom/dom/ aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/ implementations/axio...
Date Sat, 29 Aug 2015 14:20:25 GMT
Author: veithen
Date: Sat Aug 29 14:20:25 2015
New Revision: 1700036

URL: http://svn.apache.org/r1700036
Log:
Partial implementation of Document#renameNode.

Modified:
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSAwareNamedNode.java
    webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMDocumentSupport.aj
    webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/NSUtil.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItemSupport.aj
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
    webservices/axiom/trunk/implementations/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DOMImplementationTest.java

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSAwareNamedNode.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSAwareNamedNode.java?rev=1700036&r1=1700035&r2=1700036&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSAwareNamedNode.java
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSAwareNamedNode.java
Sat Aug 29 14:20:25 2015
@@ -26,4 +26,5 @@ public interface CoreNSAwareNamedNode {
     String coreGetPrefix();
     void coreSetPrefix(String prefix);
     String coreGetLocalName();
+    void coreSetName(String namespaceURI, String localName, String prefix);
 }

Modified: webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMDocumentSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMDocumentSupport.aj?rev=1700036&r1=1700035&r2=1700036&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMDocumentSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMDocumentSupport.aj
Sat Aug 29 14:20:25 2015
@@ -203,4 +203,45 @@ public aspect DOMDocumentSupport {
     public final NodeList DOMDocument.getElementsByTagNameNS(String namespaceURI, String
localName) {
         return new ElementsByTagNameNS(this, namespaceURI, localName);
     }
+    
+    // TODO: need unit test to check that this method works as expected on an OMSourcedElement
+    public final Node DOMDocument.renameNode(Node node, String namespaceURI, String qualifiedName)
{
+        if (!(node instanceof DOMNode && ((DOMNode)node).coreHasSameOwnerDocument(this)))
{
+            throw DOMExceptionTranslator.newDOMException(DOMException.WRONG_DOCUMENT_ERR);
+        }
+        // TODO: what about an attempt to rename a namespace unaware node?
+        if (!(node instanceof DOMNSAwareNamedNode)) {
+            throw DOMExceptionTranslator.newDOMException(DOMException.NOT_SUPPORTED_ERR);
+        }
+        int i = NSUtil.validateQualifiedName(qualifiedName);
+        String prefix;
+        String localName;
+        if (i == -1) {
+            prefix = "";
+            localName = qualifiedName;
+        } else {
+            prefix = qualifiedName.substring(0, i);
+            localName = qualifiedName.substring(i+1);
+        }
+        namespaceURI = NSUtil.normalizeNamespaceURI(namespaceURI);
+        switch (((DOMNode)node).coreGetNodeType()) {
+            case NS_AWARE_ELEMENT_NODE:
+                NSUtil.validateNamespace(namespaceURI, prefix);
+                ((DOMNSAwareElement)node).coreSetName(namespaceURI, localName, prefix);
+                return node;
+            case NS_AWARE_ATTRIBUTE_NODE:
+                if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI)) {
+                    return (DOMAttribute)coreGetNodeFactory().createNamespaceDeclaration(this,
NSUtil.getDeclaredPrefix(localName, prefix), ((DOMNSAwareAttribute)node).getValue());
+                } else {
+                    NSUtil.validateAttributeName(namespaceURI, localName, prefix);
+                    ((DOMNSAwareAttribute)node).coreSetName(namespaceURI, localName, prefix);
+                    return node;
+                }
+            case NAMESPACE_DECLARATION_NODE:
+                // TODO
+                throw new UnsupportedOperationException();
+            default:
+                throw new IllegalStateException();
+        }
+    }
 }

Modified: webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/NSUtil.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/NSUtil.java?rev=1700036&r1=1700035&r2=1700036&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/NSUtil.java
(original)
+++ webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/NSUtil.java
Sat Aug 29 14:20:25 2015
@@ -80,10 +80,13 @@ public final class NSUtil {
                 } else {
                     throw DOMExceptionTranslator.newDOMException(DOMException.NAMESPACE_ERR);
                 }
-            } else if (checkNameStart && !isNameStartChar(c) || i > 0 &&
!isNameChar(c)) {
-                throw DOMExceptionTranslator.newDOMException(DOMException.INVALID_CHARACTER_ERR);
-            } else {
+            } else if (checkNameStart) {
+                if (!isNameStartChar(c)) {
+                    throw DOMExceptionTranslator.newDOMException(isNameChar(c) ? DOMException.NAMESPACE_ERR
: DOMException.INVALID_CHARACTER_ERR);
+                }
                 checkNameStart = false;
+            } else if (!isNameChar(c)) {
+                throw DOMExceptionTranslator.newDOMException(DOMException.INVALID_CHARACTER_ERR);
             }
         }
         if (checkNameStart) {

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItemSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItemSupport.aj?rev=1700036&r1=1700035&r2=1700036&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItemSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItemSupport.aj
Sat Aug 29 14:20:25 2015
@@ -157,6 +157,13 @@ public aspect AxiomNamedInformationItemS
         OMNamespace namespace = getNamespace();
         return namespace == null ? "" : namespace.getPrefix();
     }
+    
+    public final void AxiomNamedInformationItem.coreSetName(String namespaceURI, String localName,
String prefix) {
+        this.localName = localName;
+        namespace = namespaceURI.length() == 0 && prefix.length() == 0 ? null : new
OMNamespaceImpl(namespaceURI, prefix);
+        // TODO: need unit test to assert this
+        qName = null;
+    }
 
     public void AxiomNamedInformationItem.updateLocalName() {
         throw new IllegalStateException();

Modified: webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java?rev=1700036&r1=1700035&r2=1700036&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
(original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
Sat Aug 29 14:20:25 2015
@@ -260,12 +260,6 @@ public class DocumentImpl extends Parent
         throw new UnsupportedOperationException("TODO");
     }
 
-    public Node renameNode(Node node, String namespaceURI, String qualifiedName)
-            throws DOMException {
-        // TODO TODO
-        throw new UnsupportedOperationException("TODO");
-    }
-
     public void setDocumentURI(String documentURI) {
         // TODO TODO
         throw new UnsupportedOperationException("TODO");

Modified: webservices/axiom/trunk/implementations/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DOMImplementationTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DOMImplementationTest.java?rev=1700036&r1=1700035&r2=1700036&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DOMImplementationTest.java
(original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DOMImplementationTest.java
Sat Aug 29 14:20:25 2015
@@ -167,34 +167,6 @@ public class DOMImplementationTest exten
         builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentnormalizedocument11)");
         builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentnormalizedocument12)");
         builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentnormalizedocument13)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode01)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode02)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode03)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode04)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode05)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode06)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode07)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode08)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode09)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode10)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode11)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode12)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode13)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode14)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode15)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode16)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode17)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode18)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode19)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode20)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode21)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode22)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode23)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode24)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode25)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode26)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode27)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentrenamenode29)");
         builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentsetdocumenturi01)");
         builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentsetdocumenturi02)");
         builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentsetdocumenturi03)");



Mime
View raw message