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 2014/06/28 22:13:08 UTC

svn commit: r1606390 - in /webservices/axiom/trunk/modules/axiom-dom/src: main/java/org/apache/axiom/om/impl/dom/ test/java/org/apache/axiom/om/impl/dom/

Author: veithen
Date: Sat Jun 28 20:13:08 2014
New Revision: 1606390

URL: http://svn.apache.org/r1606390
Log:
EntityReference is not a leaf node in the DOM API.

Added:
    webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java
      - copied, changed from r1605161, webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/LeafNode.java
Modified:
    webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CDATASectionImpl.java
    webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CommentImpl.java
    webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentTypeImpl.java
    webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/EntityReferenceImpl.java
    webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/LeafNode.java
    webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ProcessingInstructionImpl.java
    webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java
    webservices/axiom/trunk/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DOMImplementationTest.java

Modified: webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CDATASectionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CDATASectionImpl.java?rev=1606390&r1=1606389&r2=1606390&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CDATASectionImpl.java (original)
+++ webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CDATASectionImpl.java Sat Jun 28 20:13:08 2014
@@ -38,7 +38,7 @@ public class CDATASectionImpl extends Te
         return Node.CDATA_SECTION_NODE;
     }
 
-    LeafNode createClone() {
+    ChildNode createClone() {
         return new CDATASectionImpl(textValue, factory);
     }
 }

Copied: webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java (from r1605161, webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/LeafNode.java)
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java?p2=webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java&p1=webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/LeafNode.java&r1=1605161&r2=1606390&rev=1606390&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/LeafNode.java (original)
+++ webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java Sat Jun 28 20:13:08 2014
@@ -26,19 +26,17 @@ import org.apache.axiom.om.OMXMLParserWr
 import org.apache.axiom.om.impl.common.IChildNode;
 import org.apache.axiom.om.impl.common.IParentNode;
 import org.apache.axiom.om.impl.common.OMNodeHelper;
-import org.w3c.dom.DOMException;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
 
-public abstract class LeafNode extends NodeImpl implements IChildNode {
+public abstract class ChildNode extends NodeImpl implements IChildNode {
     private ParentNode ownerNode;
     
     private NodeImpl previousSibling;
 
     private NodeImpl nextSibling;
 
-    public LeafNode(OMFactory factory) {
+    public ChildNode(OMFactory factory) {
         super(factory);
     }
 
@@ -66,29 +64,9 @@ public abstract class LeafNode extends N
         this.nextSibling = nextSibling;
     }
     
-    public final NodeList getChildNodes() {
-        return EmptyNodeList.INSTANCE;
-    }
-
-    public final Node appendChild(Node newChild) throws DOMException {
-        throw DOMUtil.newDOMException(DOMException.HIERARCHY_REQUEST_ERR);
-    }
-
-    public final Node removeChild(Node oldChild) throws DOMException {
-        throw DOMUtil.newDOMException(DOMException.NOT_FOUND_ERR);
-    }
-
-    public final Node insertBefore(Node newChild, Node refChild) throws DOMException {
-        throw DOMUtil.newDOMException(DOMException.HIERARCHY_REQUEST_ERR);
-    }
-
-    public final Node replaceChild(Node newChild, Node oldChild) throws DOMException {
-        throw DOMUtil.newDOMException(DOMException.HIERARCHY_REQUEST_ERR);
-    }
-
     final NodeImpl clone(OMCloneOptions options, ParentNode targetParent, boolean deep, boolean namespaceRepairing) {
         beforeClone(options);
-        LeafNode clone = createClone();
+        ChildNode clone = createClone();
         if (targetParent != null) {
             targetParent.internalAppendChild(clone);
         }
@@ -99,7 +77,7 @@ public abstract class LeafNode extends N
         // By default, do nothing
     }
     
-    abstract LeafNode createClone();
+    abstract ChildNode createClone();
 
     public final OMXMLParserWrapper getBuilder() {
         return null;

Modified: webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CommentImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CommentImpl.java?rev=1606390&r1=1606389&r2=1606390&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CommentImpl.java (original)
+++ webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CommentImpl.java Sat Jun 28 20:13:08 2014
@@ -26,7 +26,6 @@ import org.apache.axiom.om.OMOutputForma
 import org.apache.axiom.om.impl.common.serializer.push.OutputException;
 import org.apache.axiom.om.impl.common.serializer.push.Serializer;
 import org.w3c.dom.Comment;
-import org.w3c.dom.DOMException;
 import org.w3c.dom.Node;
 
 public class CommentImpl extends CharacterImpl implements Comment, OMComment {
@@ -58,7 +57,7 @@ public class CommentImpl extends Charact
         serializer.writeComment(this.textValue);
     }
 
-    LeafNode createClone() {
+    ChildNode createClone() {
         return new CommentImpl(getData(), factory);
     }
 }

Modified: webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentTypeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentTypeImpl.java?rev=1606390&r1=1606389&r2=1606390&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentTypeImpl.java (original)
+++ webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentTypeImpl.java Sat Jun 28 20:13:08 2014
@@ -87,7 +87,7 @@ public class DocumentTypeImpl extends Le
         return systemId;
     }
 
-    LeafNode createClone() {
+    ChildNode createClone() {
         return new DocumentTypeImpl(rootName, publicId, systemId, internalSubset, factory);
     }
 }

Modified: webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/EntityReferenceImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/EntityReferenceImpl.java?rev=1606390&r1=1606389&r2=1606390&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/EntityReferenceImpl.java (original)
+++ webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/EntityReferenceImpl.java Sat Jun 28 20:13:08 2014
@@ -24,10 +24,12 @@ import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMOutputFormat;
 import org.apache.axiom.om.impl.common.serializer.push.OutputException;
 import org.apache.axiom.om.impl.common.serializer.push.Serializer;
+import org.w3c.dom.DOMException;
 import org.w3c.dom.EntityReference;
 import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 
-public class EntityReferenceImpl extends LeafNode implements OMEntityReference, EntityReference {
+public class EntityReferenceImpl extends ChildNode implements OMEntityReference, EntityReference {
     private final String name;
     private final String replacementText;
 
@@ -53,7 +55,7 @@ public class EntityReferenceImpl extends
         return replacementText;
     }
 
-    LeafNode createClone() {
+    ChildNode createClone() {
         return new EntityReferenceImpl(name, replacementText, factory);
     }
 
@@ -64,4 +66,24 @@ public class EntityReferenceImpl extends
     public short getNodeType() {
         return Node.ENTITY_REFERENCE_NODE;
     }
+
+    public final NodeList getChildNodes() {
+        throw new UnsupportedOperationException();
+    }
+
+    public final Node appendChild(Node newChild) throws DOMException {
+        throw DOMUtil.newDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+    }
+
+    public final Node removeChild(Node oldChild) throws DOMException {
+        throw DOMUtil.newDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+    }
+
+    public final Node insertBefore(Node newChild, Node refChild) throws DOMException {
+        throw DOMUtil.newDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+    }
+
+    public final Node replaceChild(Node newChild, Node oldChild) throws DOMException {
+        throw DOMUtil.newDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+    }
 }

Modified: webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/LeafNode.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/LeafNode.java?rev=1606390&r1=1606389&r2=1606390&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/LeafNode.java (original)
+++ webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/LeafNode.java Sat Jun 28 20:13:08 2014
@@ -18,54 +18,16 @@
  */
 package org.apache.axiom.om.impl.dom;
 
-import org.apache.axiom.om.OMCloneOptions;
-import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.OMXMLParserWrapper;
-import org.apache.axiom.om.impl.common.IChildNode;
-import org.apache.axiom.om.impl.common.IParentNode;
-import org.apache.axiom.om.impl.common.OMNodeHelper;
 import org.w3c.dom.DOMException;
-import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-public abstract class LeafNode extends NodeImpl implements IChildNode {
-    private ParentNode ownerNode;
-    
-    private NodeImpl previousSibling;
-
-    private NodeImpl nextSibling;
-
+public abstract class LeafNode extends ChildNode {
     public LeafNode(OMFactory factory) {
         super(factory);
     }
 
-    final ParentNode internalGetOwnerNode() {
-        return ownerNode;
-    }
-
-    final void internalSetOwnerNode(ParentNode ownerNode) {
-        this.ownerNode = ownerNode;
-    }
-
-    final NodeImpl internalGetPreviousSibling() {
-        return previousSibling;
-    }
-    
-    final NodeImpl internalGetNextSibling() {
-        return nextSibling;
-    }
-    
-    final void internalSetPreviousSibling(NodeImpl previousSibling) {
-        this.previousSibling = previousSibling;
-    }
-    
-    final void internalSetNextSibling(NodeImpl nextSibling) {
-        this.nextSibling = nextSibling;
-    }
-    
     public final NodeList getChildNodes() {
         return EmptyNodeList.INSTANCE;
     }
@@ -85,61 +47,4 @@ public abstract class LeafNode extends N
     public final Node replaceChild(Node newChild, Node oldChild) throws DOMException {
         throw DOMUtil.newDOMException(DOMException.HIERARCHY_REQUEST_ERR);
     }
-
-    final NodeImpl clone(OMCloneOptions options, ParentNode targetParent, boolean deep, boolean namespaceRepairing) {
-        beforeClone(options);
-        LeafNode clone = createClone();
-        if (targetParent != null) {
-            targetParent.internalAppendChild(clone);
-        }
-        return clone;
-    }
-    
-    void beforeClone(OMCloneOptions options) {
-        // By default, do nothing
-    }
-    
-    abstract LeafNode createClone();
-
-    public final OMXMLParserWrapper getBuilder() {
-        return null;
-    }
-
-    public final boolean isComplete() {
-        return true;
-    }
-
-    public final void setComplete(boolean state) {
-        if (state != true) {
-            throw new IllegalStateException();
-        }
-    }
-
-    public final void discard() throws OMException {
-        detach();
-    }
-
-    public final void build() {
-        // Do nothing; a leaf node is always complete
-    }
-
-    public final OMNode getNextOMSibling() throws OMException {
-        return OMNodeHelper.getNextOMSibling(this);
-    }
-
-    public final Node getNextSibling() {
-        return (Node)getNextOMSibling();
-    }
-
-    public final IParentNode getIParentNode() {
-        return parentNode();
-    }
-
-    public final String lookupNamespaceURI(String specifiedPrefix) {
-        ParentNode parent = parentNode();
-        // Note: according to the DOM specs, we need to delegate the lookup if the parent
-        // is an element or an entity reference. However, since we don't support entity
-        // references fully, we only check for elements.
-        return parent instanceof Element ? parent.lookupNamespaceURI(specifiedPrefix) : null;
-    }
 }

Modified: webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ProcessingInstructionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ProcessingInstructionImpl.java?rev=1606390&r1=1606389&r2=1606390&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ProcessingInstructionImpl.java (original)
+++ webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ProcessingInstructionImpl.java Sat Jun 28 20:13:08 2014
@@ -89,7 +89,7 @@ public class ProcessingInstructionImpl e
         serializer.writeProcessingInstruction(target + " ", value);
     }
 
-    LeafNode createClone() {
+    ChildNode createClone() {
         return new ProcessingInstructionImpl(target, value, factory);
     }
 }

Modified: webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java?rev=1606390&r1=1606389&r2=1606390&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java (original)
+++ webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java Sat Jun 28 20:13:08 2014
@@ -81,7 +81,7 @@ public class TextImpl extends TextNodeIm
         return isWhitespace ? OMNode.SPACE_NODE : OMNode.TEXT_NODE;
     }
 
-    LeafNode createClone() {
+    ChildNode createClone() {
         return new TextImpl(this, factory);
     }
 }

Modified: webservices/axiom/trunk/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DOMImplementationTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DOMImplementationTest.java?rev=1606390&r1=1606389&r2=1606390&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DOMImplementationTest.java (original)
+++ webservices/axiom/trunk/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DOMImplementationTest.java Sat Jun 28 20:13:08 2014
@@ -62,10 +62,8 @@ public class DOMImplementationTest exten
         builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapremovenameditemgetvalue)");
         builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeappendchilddocfragment)");
         builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeappendchildinvalidnodetype)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeappendchildnomodificationallowederrEE)");
         builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodecdatasectionnodename)");
         builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeinsertbeforeinvalidnodetype)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeinsertbeforenomodificationallowederrEE)");
         builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodereplacechildinvalidnodetype)");
         builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodereplacechildnewchildexists)");
         builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level1/core/processinginstructionsetdatanomodificationallowederr)");
@@ -471,8 +469,6 @@ public class DOMImplementationTest exten
         builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/noderemovechild19)");
         builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodereplacechild13)");
         builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodereplacechild20)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodereplacechild22)");
-        builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodereplacechild23)");
         builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodereplacechild24)");
         builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodereplacechild27)");
         builder.exclude(W3CTestCase.class, "(id=http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodereplacechild28)");