This is an automated email from the ASF dual-hosted git repository.

veithen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ws-axiom.git


The following commit(s) were added to refs/heads/master by this push:
     new e032851  Move remaining DOM code into mixins
e032851 is described below

commit e032851c054c05b88b53635749f41f3fe17950dd
Author: Andreas Veithen <[email protected]>
AuthorDate: Wed May 20 21:24:05 2020 +0100

    Move remaining DOM code into mixins
---
 aspects/dom-aspects/pom.xml                        |   6 +
 .../org/apache/axiom/dom/DOMNSAwareElement.java    |   3 +-
 .../axiom/dom/impl/mixin/DOMDocumentSupport.aj     |  89 +++++++
 .../dom/impl/mixin/DOMNSAwareElementSupport.aj     |  11 +-
 .../apache/axiom/dom/impl/mixin/DOMNodeSupport.aj  | 257 ++++++++++++++++++++
 .../axiom/dom/impl/mixin/DOMTextNodeSupport.aj     |   5 +
 .../org/apache/axiom/om/impl/dom/DocumentImpl.java |  96 --------
 .../apache/axiom/om/impl/dom/NSAwareElement.java   |  18 --
 .../org/apache/axiom/om/impl/dom/NodeImpl.java     | 259 ---------------------
 .../org/apache/axiom/om/impl/dom/TextNodeImpl.java |   4 -
 .../axiom/soap/impl/dom/SOAPEnvelopeImpl.java      |  16 --
 11 files changed, 363 insertions(+), 401 deletions(-)

diff --git a/aspects/dom-aspects/pom.xml b/aspects/dom-aspects/pom.xml
index 3de4525..bbd866a 100644
--- a/aspects/dom-aspects/pom.xml
+++ b/aspects/dom-aspects/pom.xml
@@ -43,6 +43,12 @@
             <version>${project.version}</version>
         </dependency>
         <dependency>
+            <!-- TODO: decouple this from the Axiom API -->
+            <groupId>${project.groupId}</groupId>
+            <artifactId>om-aspects</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>xml-utils</artifactId>
             <version>${project.version}</version>
diff --git 
a/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSAwareElement.java 
b/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSAwareElement.java
index f79be74..d83f8b4 100644
--- 
a/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSAwareElement.java
+++ 
b/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSAwareElement.java
@@ -19,7 +19,8 @@
 package org.apache.axiom.dom;
 
 import org.apache.axiom.core.CoreNSAwareElement;
+import org.apache.axiom.om.impl.intf.AxiomElement;
 
-public interface DOMNSAwareElement extends DOMElement, DOMNSAwareNamedNode, 
CoreNSAwareElement {
+public interface DOMNSAwareElement extends DOMElement, DOMNSAwareNamedNode, 
CoreNSAwareElement, AxiomElement {
 
 }
diff --git 
a/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/impl/mixin/DOMDocumentSupport.aj
 
b/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/impl/mixin/DOMDocumentSupport.aj
index aecd6f1..116c65d 100644
--- 
a/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/impl/mixin/DOMDocumentSupport.aj
+++ 
b/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/impl/mixin/DOMDocumentSupport.aj
@@ -430,4 +430,93 @@ public aspect DOMDocumentSupport {
 
     public final void DOMDocument.normalize(DOMConfigurationImpl config) {
     }
+
+    public final Node DOMDocument.importNode(Node importedNode, boolean deep) 
throws DOMException {
+
+        short type = importedNode.getNodeType();
+        Node newNode = null;
+        switch (type) {
+            case Node.ELEMENT_NODE: {
+                Element newElement;
+                if (importedNode.getLocalName() == null) {
+                    newElement = 
this.createElement(importedNode.getNodeName());
+                } else {
+                    
+                    String ns = importedNode.getNamespaceURI();
+                    ns = (ns != null) ? ns.intern() : null;
+                    newElement = createElementNS(ns, 
importedNode.getNodeName());
+                }
+
+                // Copy element's attributes, if any.
+                NamedNodeMap sourceAttrs = importedNode.getAttributes();
+                if (sourceAttrs != null) {
+                    int length = sourceAttrs.getLength();
+                    for (int index = 0; index < length; index++) {
+                        
((DOMElement)newElement).coreAppendAttribute((DOMAttribute)importNode(sourceAttrs.item(index),
 true));
+                    }
+                }
+                newNode = newElement;
+                break;
+            }
+
+            case Node.ATTRIBUTE_NODE: {
+                if (importedNode.getLocalName() == null) {
+                    newNode = createAttribute(importedNode.getNodeName());
+                } else {
+                    String ns = importedNode.getNamespaceURI();
+                    ns = (ns != null) ? ns.intern() : null;
+                    newNode = createAttributeNS(ns ,
+                                                importedNode.getNodeName());
+                }
+                ((Attr) newNode).setValue(importedNode.getNodeValue());
+                break;
+            }
+
+            case Node.TEXT_NODE: {
+                newNode = createTextNode(importedNode.getNodeValue());
+                break;
+            }
+
+            case Node.COMMENT_NODE: {
+                newNode = createComment(importedNode.getNodeValue());
+                break;
+            }
+                
+            case Node.DOCUMENT_FRAGMENT_NODE: {
+                newNode = createDocumentFragment();
+                // No name, kids carry value
+                break;
+            }
+
+            case Node.CDATA_SECTION_NODE:
+                newNode = createCDATASection(importedNode.getNodeValue());
+                break;
+            
+            case Node.PROCESSING_INSTRUCTION_NODE: {
+                ProcessingInstruction pi = (ProcessingInstruction)importedNode;
+                newNode = createProcessingInstruction(pi.getTarget(), 
pi.getData());
+                break;
+            }
+            case Node.ENTITY_REFERENCE_NODE:
+            case Node.ENTITY_NODE:
+            case Node.NOTATION_NODE:
+                throw new UnsupportedOperationException("TODO : Implement 
handling of org.w3c.dom.Node type == " + type );
+
+            case Node.DOCUMENT_NODE: // Can't import document nodes
+            case Node.DOCUMENT_TYPE_NODE:
+            default:
+                throw newDOMException(DOMException.NOT_SUPPORTED_ERR);
+        }
+
+        // If deep, replicate and attach the kids.
+        if (deep && !(importedNode instanceof Attr)) {
+            for (Node srckid = importedNode.getFirstChild(); srckid != null;
+                 srckid = srckid.getNextSibling()) {
+                newNode.appendChild(importNode(srckid, true));
+            }
+        }
+
+        return newNode;
+
+    }
 }
diff --git 
a/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareElement.java
 
b/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/impl/mixin/DOMNSAwareElementSupport.aj
similarity index 81%
copy from 
implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareElement.java
copy to 
aspects/dom-aspects/src/main/java/org/apache/axiom/dom/impl/mixin/DOMNSAwareElementSupport.aj
index 30fd181..e7df57b 100644
--- 
a/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareElement.java
+++ 
b/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/impl/mixin/DOMNSAwareElementSupport.aj
@@ -16,18 +16,15 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
-package org.apache.axiom.om.impl.dom;
+package org.apache.axiom.dom.impl.mixin;
 
 import org.apache.axiom.dom.DOMConfigurationImpl;
 import org.apache.axiom.dom.DOMNSAwareElement;
 import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.impl.intf.AxiomElement;
 
-/** Implementation of the org.w3c.dom.Element and org.apache.axiom.om.Element 
interfaces. */
-public class NSAwareElement extends ElementImpl implements DOMNSAwareElement, 
AxiomElement {
-    
-    public final void normalize(DOMConfigurationImpl config) {
+public aspect DOMNSAwareElementSupport {
+    public final void DOMNSAwareElement.normalize(DOMConfigurationImpl config) 
{
+        // TODO: this should not rely on the Axiom API
         if (config.isEnabled(DOMConfigurationImpl.NAMESPACES)) {
             OMNamespace namespace = getNamespace();
             if (namespace == null) {
diff --git 
a/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/impl/mixin/DOMNodeSupport.aj
 
b/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/impl/mixin/DOMNodeSupport.aj
index 089dbd3..f0d1919 100644
--- 
a/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/impl/mixin/DOMNodeSupport.aj
+++ 
b/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/impl/mixin/DOMNodeSupport.aj
@@ -18,6 +18,10 @@
  */
 package org.apache.axiom.dom.impl.mixin;
 
+import static org.apache.axiom.dom.DOMExceptionUtil.newDOMException;
+
+import java.util.Hashtable;
+
 import org.apache.axiom.core.CoreElement;
 import org.apache.axiom.core.CoreModelException;
 import org.apache.axiom.dom.DOMDocument;
@@ -25,9 +29,16 @@ import org.apache.axiom.dom.DOMExceptionUtil;
 import org.apache.axiom.dom.DOMNode;
 import org.apache.axiom.dom.DOMNodeFactory;
 import org.apache.axiom.dom.DOMSemantics;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
+import org.w3c.dom.UserDataHandler;
 
 public aspect DOMNodeSupport {
+    /** Holds the user data objects */
+    private Hashtable DOMNode.userData; // Will be initialized in setUserData()
+
     public final boolean DOMNode.isSupported(String feature, String version) {
         return 
((DOMNodeFactory)coreGetNodeFactory()).getDOMImplementation().hasFeature(feature,
 version);
     }
@@ -93,4 +104,250 @@ public aspect DOMNodeSupport {
             throw DOMExceptionUtil.toUncheckedException(ex);
         }
     }
+
+    public void DOMNode.normalize() {
+        //Parent node should override this 
+    }
+
+    /*
+     * DOM-Level 3 methods
+     */
+
+    public String DOMNode.getBaseURI() {
+        // TODO TODO
+        throw new UnsupportedOperationException("TODO");
+    }
+
+    public short DOMNode.compareDocumentPosition(Node other) throws 
DOMException {
+        // This is not yet implemented. In the meantime, we throw a 
DOMException
+        // and not an UnsupportedOperationException, since this works better 
with
+        // some other libraries (such as Saxon 8.9).
+        throw newDOMException(DOMException.NOT_SUPPORTED_ERR);
+    }
+
+    public boolean DOMNode.isSameNode(Node node) {
+        // TODO : check
+        return this == node;
+    }
+
+    /**
+     * Tests whether two nodes are equal. <br>This method tests for equality 
of nodes, not sameness
+     * (i.e., whether the two nodes are references to the same object) which 
can be tested with
+     * <code>Node.isSameNode()</code>. All nodes that are the same will also 
be equal, though the
+     * reverse may not be true. <br>Two nodes are equal if and only if the 
following conditions are
+     * satisfied: <ul> <li>The two nodes are of the same type. </li> <li>The 
following string
+     * attributes are equal: <code>nodeName</code>, <code>localName</code>,
+     * <code>namespaceURI</code>, <code>prefix</code>, <code>nodeValue</code> 
. This is: they are
+     * both <code>null</code>, or they have the same length and are character 
for character
+     * identical. </li> <li>The <code>attributes</code> 
<code>NamedNodeMaps</code> are equal. This
+     * is: they are both <code>null</code>, or they have the same length and 
for each node that
+     * exists in one map there is a node that exists in the other map and is 
equal, although not
+     * necessarily at the same index. </li> <li>The <code>childNodes</code> 
<code>NodeLists</code>
+     * are equal. This is: they are both <code>null</code>, or they have the 
same length and contain
+     * equal nodes at the same index. Note that normalization can affect 
equality; to avoid this,
+     * nodes should be normalized before being compared. </li> </ul> <br>For 
two
+     * <code>DocumentType</code> nodes to be equal, the following conditions 
must also be satisfied:
+     * <ul> <li>The following string attributes are equal: 
<code>publicId</code>,
+     * <code>systemId</code>, <code>internalSubset</code>. </li> <li>The 
<code>entities</code>
+     * <code>NamedNodeMaps</code> are equal. </li> <li>The 
<code>notations</code>
+     * <code>NamedNodeMaps</code> are equal. </li> </ul> <br>On the other 
hand, the following do not
+     * affect equality: the <code>ownerDocument</code>, <code>baseURI</code>, 
and
+     * <code>parentNode</code> attributes, the <code>specified</code> 
attribute for
+     * <code>Attr</code> nodes, the <code>schemaTypeInfo</code> attribute for 
<code>Attr</code> and
+     * <code>Element</code> nodes, the 
<code>Text.isElementContentWhitespace</code> attribute for
+     * <code>Text</code> nodes, as well as any user data or event listeners 
registered on the nodes.
+     * <p ><b>Note:</b>  As a general rule, anything not mentioned in the 
description above is not
+     * significant in consideration of equality checking. Note that future 
versions of this
+     * specification may take into account more attributes and implementations 
conform to this
+     * specification are expected to be updated accordingly.
+     *
+     * @param node The node to compare equality with.
+     * @return Returns <code>true</code> if the nodes are equal, 
<code>false</code> otherwise.
+     * @since DOM Level 3
+     */
+
+    //TODO : sumedha, complete
+    public boolean DOMNode.isEqualNode(Node node) {
+        final boolean equal = true;
+        final boolean notEqual = false;
+        if (this.getNodeType() != node.getNodeType()) {
+            return notEqual;
+        }
+        if (checkStringAttributeEquality(node)) {
+            if (checkNamedNodeMapEquality(node)) {
+
+            } else {
+                return notEqual;
+            }
+        } else {
+            return notEqual;
+        }
+        return equal;
+    }
+
+    private boolean DOMNode.checkStringAttributeEquality(Node node) {
+        final boolean equal = true;
+        final boolean notEqual = false;
+
+        // null     not-null  -> true
+        // not-null null      -> true
+        // null     null      -> false
+        // not-null not-null  -> false
+
+        //NodeName
+        if (node.getNodeName() == null ^ this.getNodeName() == null) {
+            return notEqual;
+        } else {
+            if (node.getNodeName() == null) {
+                //This means both are null.do nothing
+            } else {
+                if (!(node.getNodeName().equals(this.getNodeName()))) {
+                    return notEqual;
+                }
+            }
+        }
+
+        //localName
+        if (node.getLocalName() == null ^ this.getLocalName() == null) {
+            return notEqual;
+        } else {
+            if (node.getLocalName() == null) {
+                //This means both are null.do nothing
+            } else {
+                if (!(node.getLocalName().equals(this.getLocalName()))) {
+                    return notEqual;
+                }
+            }
+        }
+
+        //namespaceURI
+        if (node.getNamespaceURI() == null ^ this.getNamespaceURI() == null) {
+            return notEqual;
+        } else {
+            if (node.getNamespaceURI() == null) {
+                //This means both are null.do nothing
+            } else {
+                if (!(node.getNamespaceURI().equals(this.getNamespaceURI()))) {
+                    return notEqual;
+                }
+            }
+        }
+
+        //prefix
+        if (node.getPrefix() == null ^ this.getPrefix() == null) {
+            return notEqual;
+        } else {
+            if (node.getPrefix() == null) {
+                //This means both are null.do nothing
+            } else {
+                if (!(node.getPrefix().equals(this.getPrefix()))) {
+                    return notEqual;
+                }
+            }
+        }
+
+        //nodeValue
+        if (node.getNodeValue() == null ^ this.getNodeValue() == null) {
+            return notEqual;
+        } else {
+            if (node.getNodeValue() == null) {
+                //This means both are null.do nothing
+            } else {
+                if (!(node.getNodeValue().equals(this.getNodeValue()))) {
+                    return notEqual;
+                }
+            }
+        }
+        return equal;
+    }
+
+    private boolean DOMNode.checkNamedNodeMapEquality(Node node) {
+        final boolean equal = true;
+        final boolean notEqual = false;
+        if (node.getAttributes() == null ^ this.getAttributes() == null) {
+            return notEqual;
+        }
+        NamedNodeMap thisNamedNodeMap = this.getAttributes();
+        NamedNodeMap nodeNamedNodeMap = node.getAttributes();
+
+        // null     not-null  -> true
+        // not-null null      -> true
+        // null     null      -> false
+        // not-null not-null  -> false
+
+        if (thisNamedNodeMap == null ^ nodeNamedNodeMap == null) {
+            return notEqual;
+        } else {
+            if (thisNamedNodeMap == null) {
+                //This means both are null.do nothing
+            } else {
+                if (thisNamedNodeMap.getLength() != 
nodeNamedNodeMap.getLength()) {
+                    return notEqual;
+                } else {
+                    //they have the same length and for each node that exists 
in one map
+                    //there is a node that exists in the other map and is 
equal, although
+                    //not necessarily at the same index.
+                    int itemCount = thisNamedNodeMap.getLength();
+                    for (int a = 0; a < itemCount; a++) {
+                        DOMNode thisNode = (DOMNode) thisNamedNodeMap.item(a);
+                        DOMNode tmpNode =
+                                (DOMNode) 
nodeNamedNodeMap.getNamedItem(thisNode.getNodeName());
+                        if (tmpNode == null) {
+                            //i.e. no corresponding node
+                            return notEqual;
+                        } else {
+                            if (!(thisNode.isEqualNode(tmpNode))) {
+                                return notEqual;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return equal;
+    }
+
+    public Object DOMNode.getFeature(String feature, String version) {
+        // TODO TODO
+        throw new UnsupportedOperationException("TODO");
+    }
+
+    /* *
+     * userData storage/hashtable will be called only when the user needs to 
set user data. Previously, it was done as,
+     * for every node a new Hashtable created making the excution very 
inefficient. According to profiles, no. of method
+     * invocations to setUserData() method is very low, so this implementation 
is better.
+     * Another option:
+     * TODO do a profile and check the times for hashtable initialization. If 
it's still higher, we have to go to second option
+     * Create a separate class(UserData) to store key and value pairs. Then 
put those objects to a array with a reasonable size.
+     * then grow it accordingly.  @ Kasun Gajasinghe 
+     * @param key userData key
+     * @param value userData value
+     * @param userDataHandler it seems all invocations sends null for this 
parameter.
+     *          Kept it for the moment just for being on the safe side.
+     * @return previous Object if one is set before.
+     */
+    
+    public Object DOMNode.setUserData(String key, Object value, 
UserDataHandler userDataHandler) {
+        if (userData == null) {
+            userData = new Hashtable();
+        }
+        return userData.put(key, value);
+    }
+
+    public Object DOMNode.getUserData(String key) {
+        if (userData != null) {
+            return userData.get(key);
+        }
+        return null;
+    }
+
+    /**
+     * Get the owner document of this node. In contrast to {@link 
Node#getOwnerDocument()}, this
+     * method returns a non null value when invoked on a {@link Document} 
instance.
+     * 
+     * @return the owner document
+     */
+    final DOMDocument DOMNode.ownerDocument() {
+        return (DOMDocument)coreGetOwnerDocument(true);
+    }
 }
diff --git 
a/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/impl/mixin/DOMTextNodeSupport.aj
 
b/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/impl/mixin/DOMTextNodeSupport.aj
index c88d271..bae4033 100644
--- 
a/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/impl/mixin/DOMTextNodeSupport.aj
+++ 
b/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/impl/mixin/DOMTextNodeSupport.aj
@@ -133,4 +133,9 @@ public aspect DOMTextNodeSupport {
             throw DOMExceptionUtil.toUncheckedException(ex);
         }
     }
+
+    public String DOMTextNode.toString() {
+        String value = getData();
+        return value != null ? value : "";
+    }
 }
diff --git 
a/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
 
b/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
index 4085811..de53bee 100644
--- 
a/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
+++ 
b/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
@@ -19,104 +19,8 @@
 
 package org.apache.axiom.om.impl.dom;
 
-import static org.apache.axiom.dom.DOMExceptionUtil.newDOMException;
-
 import org.apache.axiom.dom.DOMDocument;
 import org.apache.axiom.om.impl.intf.AxiomDocument;
-import org.w3c.dom.Attr;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.ProcessingInstruction;
 
 public class DocumentImpl extends ParentNode implements DOMDocument, 
AxiomDocument {
-    public Node importNode(Node importedNode, boolean deep) throws 
DOMException {
-
-        short type = importedNode.getNodeType();
-        Node newNode = null;
-        switch (type) {
-            case Node.ELEMENT_NODE: {
-                Element newElement;
-                if (importedNode.getLocalName() == null) {
-                    newElement = 
this.createElement(importedNode.getNodeName());
-                } else {
-                    
-                    String ns = importedNode.getNamespaceURI();
-                    ns = (ns != null) ? ns.intern() : null;
-                    newElement = createElementNS(ns, 
importedNode.getNodeName());
-                }
-
-                // Copy element's attributes, if any.
-                NamedNodeMap sourceAttrs = importedNode.getAttributes();
-                if (sourceAttrs != null) {
-                    int length = sourceAttrs.getLength();
-                    for (int index = 0; index < length; index++) {
-                        
((ElementImpl)newElement).coreAppendAttribute((AttrImpl)importNode(sourceAttrs.item(index),
 true));
-                    }
-                }
-                newNode = newElement;
-                break;
-            }
-
-            case Node.ATTRIBUTE_NODE: {
-                if (importedNode.getLocalName() == null) {
-                    newNode = createAttribute(importedNode.getNodeName());
-                } else {
-                    String ns = importedNode.getNamespaceURI();
-                    ns = (ns != null) ? ns.intern() : null;
-                    newNode = createAttributeNS(ns ,
-                                                importedNode.getNodeName());
-                }
-                ((Attr) newNode).setValue(importedNode.getNodeValue());
-                break;
-            }
-
-            case Node.TEXT_NODE: {
-                newNode = createTextNode(importedNode.getNodeValue());
-                break;
-            }
-
-            case Node.COMMENT_NODE: {
-                newNode = createComment(importedNode.getNodeValue());
-                break;
-            }
-                
-            case Node.DOCUMENT_FRAGMENT_NODE: {
-                newNode = createDocumentFragment();
-                // No name, kids carry value
-                break;
-            }
-
-            case Node.CDATA_SECTION_NODE:
-                newNode = createCDATASection(importedNode.getNodeValue());
-                break;
-            
-            case Node.PROCESSING_INSTRUCTION_NODE: {
-                ProcessingInstruction pi = (ProcessingInstruction)importedNode;
-                newNode = createProcessingInstruction(pi.getTarget(), 
pi.getData());
-                break;
-            }
-            case Node.ENTITY_REFERENCE_NODE:
-            case Node.ENTITY_NODE:
-            case Node.NOTATION_NODE:
-                throw new UnsupportedOperationException("TODO : Implement 
handling of org.w3c.dom.Node type == " + type );
-
-            case Node.DOCUMENT_NODE: // Can't import document nodes
-            case Node.DOCUMENT_TYPE_NODE:
-            default:
-                throw newDOMException(DOMException.NOT_SUPPORTED_ERR);
-        }
-
-        // If deep, replicate and attach the kids.
-        if (deep && !(importedNode instanceof Attr)) {
-            for (Node srckid = importedNode.getFirstChild(); srckid != null;
-                 srckid = srckid.getNextSibling()) {
-                newNode.appendChild(importNode(srckid, true));
-            }
-        }
-
-        return newNode;
-
-    }
 }
diff --git 
a/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareElement.java
 
b/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareElement.java
index 30fd181..c473b8e 100644
--- 
a/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareElement.java
+++ 
b/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareElement.java
@@ -19,27 +19,9 @@
 
 package org.apache.axiom.om.impl.dom;
 
-import org.apache.axiom.dom.DOMConfigurationImpl;
 import org.apache.axiom.dom.DOMNSAwareElement;
-import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.impl.intf.AxiomElement;
 
 /** Implementation of the org.w3c.dom.Element and org.apache.axiom.om.Element 
interfaces. */
 public class NSAwareElement extends ElementImpl implements DOMNSAwareElement, 
AxiomElement {
-    
-    public final void normalize(DOMConfigurationImpl config) {
-        if (config.isEnabled(DOMConfigurationImpl.NAMESPACES)) {
-            OMNamespace namespace = getNamespace();
-            if (namespace == null) {
-                if (getDefaultNamespace() != null) {
-                    declareDefaultNamespace("");
-                }
-            } else {
-                OMNamespace namespaceForPrefix = 
findNamespaceURI(namespace.getPrefix());
-                if (namespaceForPrefix == null || 
!namespaceForPrefix.getNamespaceURI().equals(namespace.getNamespaceURI())) {
-                    declareNamespace(namespace);
-                }
-            }
-        }
-    }
 }
diff --git 
a/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
 
b/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
index 8f0ac6b..2f642ce 100644
--- 
a/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
+++ 
b/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
@@ -19,26 +19,13 @@
 
 package org.apache.axiom.om.impl.dom;
 
-import static org.apache.axiom.dom.DOMExceptionUtil.newDOMException;
-
 import org.apache.axiom.core.NodeFactory;
 import org.apache.axiom.dom.DOMNode;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.impl.dom.factory.DOOMNodeFactory;
 import org.apache.axiom.om.impl.dom.factory.OMDOMMetaFactory;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.UserDataHandler;
-
-import java.util.Hashtable;
 
 public abstract class NodeImpl implements DOMNode {
-
-    /** Holds the user data objects */
-    private Hashtable userData; // Will be initialized in setUserData()
-
     public final NodeFactory coreGetNodeFactory() {
         return DOOMNodeFactory.INSTANCE;
     }
@@ -46,250 +33,4 @@ public abstract class NodeImpl implements DOMNode {
     public final OMMetaFactory getMetaFactory() {
         return OMDOMMetaFactory.INSTANCE;
     }
-
-    public void normalize() {
-        //Parent node should override this 
-    }
-
-    /*
-     * DOM-Level 3 methods
-     */
-
-    public String getBaseURI() {
-        // TODO TODO
-        throw new UnsupportedOperationException("TODO");
-    }
-
-    public short compareDocumentPosition(Node other) throws DOMException {
-        // This is not yet implemented. In the meantime, we throw a 
DOMException
-        // and not an UnsupportedOperationException, since this works better 
with
-        // some other libraries (such as Saxon 8.9).
-        throw newDOMException(DOMException.NOT_SUPPORTED_ERR);
-    }
-
-    public boolean isSameNode(Node node) {
-        // TODO : check
-        return this == node;
-    }
-
-    /**
-     * Tests whether two nodes are equal. <br>This method tests for equality 
of nodes, not sameness
-     * (i.e., whether the two nodes are references to the same object) which 
can be tested with
-     * <code>Node.isSameNode()</code>. All nodes that are the same will also 
be equal, though the
-     * reverse may not be true. <br>Two nodes are equal if and only if the 
following conditions are
-     * satisfied: <ul> <li>The two nodes are of the same type. </li> <li>The 
following string
-     * attributes are equal: <code>nodeName</code>, <code>localName</code>,
-     * <code>namespaceURI</code>, <code>prefix</code>, <code>nodeValue</code> 
. This is: they are
-     * both <code>null</code>, or they have the same length and are character 
for character
-     * identical. </li> <li>The <code>attributes</code> 
<code>NamedNodeMaps</code> are equal. This
-     * is: they are both <code>null</code>, or they have the same length and 
for each node that
-     * exists in one map there is a node that exists in the other map and is 
equal, although not
-     * necessarily at the same index. </li> <li>The <code>childNodes</code> 
<code>NodeLists</code>
-     * are equal. This is: they are both <code>null</code>, or they have the 
same length and contain
-     * equal nodes at the same index. Note that normalization can affect 
equality; to avoid this,
-     * nodes should be normalized before being compared. </li> </ul> <br>For 
two
-     * <code>DocumentType</code> nodes to be equal, the following conditions 
must also be satisfied:
-     * <ul> <li>The following string attributes are equal: 
<code>publicId</code>,
-     * <code>systemId</code>, <code>internalSubset</code>. </li> <li>The 
<code>entities</code>
-     * <code>NamedNodeMaps</code> are equal. </li> <li>The 
<code>notations</code>
-     * <code>NamedNodeMaps</code> are equal. </li> </ul> <br>On the other 
hand, the following do not
-     * affect equality: the <code>ownerDocument</code>, <code>baseURI</code>, 
and
-     * <code>parentNode</code> attributes, the <code>specified</code> 
attribute for
-     * <code>Attr</code> nodes, the <code>schemaTypeInfo</code> attribute for 
<code>Attr</code> and
-     * <code>Element</code> nodes, the 
<code>Text.isElementContentWhitespace</code> attribute for
-     * <code>Text</code> nodes, as well as any user data or event listeners 
registered on the nodes.
-     * <p ><b>Note:</b>  As a general rule, anything not mentioned in the 
description above is not
-     * significant in consideration of equality checking. Note that future 
versions of this
-     * specification may take into account more attributes and implementations 
conform to this
-     * specification are expected to be updated accordingly.
-     *
-     * @param node The node to compare equality with.
-     * @return Returns <code>true</code> if the nodes are equal, 
<code>false</code> otherwise.
-     * @since DOM Level 3
-     */
-
-    //TODO : sumedha, complete
-    public boolean isEqualNode(Node node) {
-        final boolean equal = true;
-        final boolean notEqual = false;
-        if (this.getNodeType() != node.getNodeType()) {
-            return notEqual;
-        }
-        if (checkStringAttributeEquality(node)) {
-            if (checkNamedNodeMapEquality(node)) {
-
-            } else {
-                return notEqual;
-            }
-        } else {
-            return notEqual;
-        }
-        return equal;
-    }
-
-    private boolean checkStringAttributeEquality(Node node) {
-        final boolean equal = true;
-        final boolean notEqual = false;
-
-        // null     not-null  -> true
-        // not-null null      -> true
-        // null     null      -> false
-        // not-null not-null  -> false
-
-        //NodeName
-        if (node.getNodeName() == null ^ this.getNodeName() == null) {
-            return notEqual;
-        } else {
-            if (node.getNodeName() == null) {
-                //This means both are null.do nothing
-            } else {
-                if (!(node.getNodeName().equals(this.getNodeName()))) {
-                    return notEqual;
-                }
-            }
-        }
-
-        //localName
-        if (node.getLocalName() == null ^ this.getLocalName() == null) {
-            return notEqual;
-        } else {
-            if (node.getLocalName() == null) {
-                //This means both are null.do nothing
-            } else {
-                if (!(node.getLocalName().equals(this.getLocalName()))) {
-                    return notEqual;
-                }
-            }
-        }
-
-        //namespaceURI
-        if (node.getNamespaceURI() == null ^ this.getNamespaceURI() == null) {
-            return notEqual;
-        } else {
-            if (node.getNamespaceURI() == null) {
-                //This means both are null.do nothing
-            } else {
-                if (!(node.getNamespaceURI().equals(this.getNamespaceURI()))) {
-                    return notEqual;
-                }
-            }
-        }
-
-        //prefix
-        if (node.getPrefix() == null ^ this.getPrefix() == null) {
-            return notEqual;
-        } else {
-            if (node.getPrefix() == null) {
-                //This means both are null.do nothing
-            } else {
-                if (!(node.getPrefix().equals(this.getPrefix()))) {
-                    return notEqual;
-                }
-            }
-        }
-
-        //nodeValue
-        if (node.getNodeValue() == null ^ this.getNodeValue() == null) {
-            return notEqual;
-        } else {
-            if (node.getNodeValue() == null) {
-                //This means both are null.do nothing
-            } else {
-                if (!(node.getNodeValue().equals(this.getNodeValue()))) {
-                    return notEqual;
-                }
-            }
-        }
-        return equal;
-    }
-
-    private boolean checkNamedNodeMapEquality(Node node) {
-        final boolean equal = true;
-        final boolean notEqual = false;
-        if (node.getAttributes() == null ^ this.getAttributes() == null) {
-            return notEqual;
-        }
-        NamedNodeMap thisNamedNodeMap = this.getAttributes();
-        NamedNodeMap nodeNamedNodeMap = node.getAttributes();
-
-        // null     not-null  -> true
-        // not-null null      -> true
-        // null     null      -> false
-        // not-null not-null  -> false
-
-        if (thisNamedNodeMap == null ^ nodeNamedNodeMap == null) {
-            return notEqual;
-        } else {
-            if (thisNamedNodeMap == null) {
-                //This means both are null.do nothing
-            } else {
-                if (thisNamedNodeMap.getLength() != 
nodeNamedNodeMap.getLength()) {
-                    return notEqual;
-                } else {
-                    //they have the same length and for each node that exists 
in one map
-                    //there is a node that exists in the other map and is 
equal, although
-                    //not necessarily at the same index.
-                    int itemCount = thisNamedNodeMap.getLength();
-                    for (int a = 0; a < itemCount; a++) {
-                        NodeImpl thisNode = (NodeImpl) 
thisNamedNodeMap.item(a);
-                        NodeImpl tmpNode =
-                                (NodeImpl) 
nodeNamedNodeMap.getNamedItem(thisNode.getNodeName());
-                        if (tmpNode == null) {
-                            //i.e. no corresponding node
-                            return notEqual;
-                        } else {
-                            if (!(thisNode.isEqualNode(tmpNode))) {
-                                return notEqual;
-                            }
-                        }
-                    }
-                }
-            }
-        }
-        return equal;
-    }
-
-    public Object getFeature(String feature, String version) {
-        // TODO TODO
-        throw new UnsupportedOperationException("TODO");
-    }
-
-    /* *
-     * userData storage/hashtable will be called only when the user needs to 
set user data. Previously, it was done as,
-     * for every node a new Hashtable created making the excution very 
inefficient. According to profiles, no. of method
-     * invocations to setUserData() method is very low, so this implementation 
is better.
-     * Another option:
-     * TODO do a profile and check the times for hashtable initialization. If 
it's still higher, we have to go to second option
-     * Create a separate class(UserData) to store key and value pairs. Then 
put those objects to a array with a reasonable size.
-     * then grow it accordingly.  @ Kasun Gajasinghe 
-     * @param key userData key
-     * @param value userData value
-     * @param userDataHandler it seems all invocations sends null for this 
parameter.
-     *          Kept it for the moment just for being on the safe side.
-     * @return previous Object if one is set before.
-     */
-    
-    public Object setUserData(String key, Object value, UserDataHandler 
userDataHandler) {
-        if (userData == null) {
-            userData = new Hashtable();
-        }
-        return userData.put(key, value);
-    }
-
-    public Object getUserData(String key) {
-        if (userData != null) {
-            return userData.get(key);
-        }
-        return null;
-    }
-
-    /**
-     * Get the owner document of this node. In contrast to {@link 
Node#getOwnerDocument()}, this
-     * method returns a non null value when invoked on a {@link Document} 
instance.
-     * 
-     * @return the owner document
-     */
-    final DocumentImpl ownerDocument() {
-        return (DocumentImpl)coreGetOwnerDocument(true);
-    }
 }
diff --git 
a/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java
 
b/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java
index d296c83..b3689b8 100644
--- 
a/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java
+++ 
b/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java
@@ -23,8 +23,4 @@ import org.apache.axiom.dom.DOMTextNode;
 import org.apache.axiom.om.impl.intf.AxiomText;
 
 public abstract class TextNodeImpl extends LeafNode implements DOMTextNode, 
AxiomText {
-    public String toString() {
-        String value = getData();
-        return value != null ? value : "";
-    }
 }
diff --git 
a/implementations/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java
 
b/implementations/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java
index 968e328..0ec8088 100644
--- 
a/implementations/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java
+++ 
b/implementations/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java
@@ -19,23 +19,7 @@
 
 package org.apache.axiom.soap.impl.dom;
 
-import org.apache.axiom.om.OMNode;
-import org.apache.axiom.soap.SOAP11Version;
 import org.apache.axiom.soap.impl.intf.AxiomSOAPEnvelope;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Node;
 
 public abstract class SOAPEnvelopeImpl extends SOAPElement implements 
AxiomSOAPEnvelope {
-    public Node insertBefore(Node newChild, Node refChild) throws DOMException 
{
-        // Check that the child to be added is valid in the context of a SOAP 
envelope.
-        // Note that this also covers the appendChild case, since that method
-        // calls insertBefore with refChild == null.
-        
-        // SOAP 1.1 allows for arbitrary elements after SOAPBody so do NOT 
check for
-        // allowed node types when appending to SOAP 1.1 envelope.
-        if (!(getVersion() instanceof SOAP11Version && refChild == null)) {
-            checkChild((OMNode)newChild);
-        }
-        return super.insertBefore(newChild, refChild);
-    }
 }

Reply via email to