You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by ru...@apache.org on 2006/09/18 22:37:49 UTC
svn commit: r447543 - in /webservices/commons/trunk/modules/axiom/modules:
axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/
axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/
Author: ruchithf
Date: Mon Sep 18 13:37:49 2006
New Revision: 447543
URL: http://svn.apache.org/viewvc?view=rev&rev=447543
Log:
Fixed sibling access methods of the DocumentImpl
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
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/ParentNode.java
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/DocumentImplTest.java
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java?view=diff&rev=447543&r1=447542&r2=447543
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java Mon Sep 18 13:37:49 2006
@@ -104,11 +104,11 @@
// /Overrides ChildNode specific methods.
// /
public OMNode getNextOMSibling() throws OMException {
- throw new UnsupportedOperationException("This is the document node");
+ return null;
}
public Node getNextSibling() {
- throw new UnsupportedOperationException("This is the document node");
+ return null;
}
public OMContainer getParent() throws OMException {
@@ -120,7 +120,7 @@
}
public Node getPreviousSibling() {
- throw new UnsupportedOperationException("This is the document node");
+ return null;
}
public void setNextOMSibling(OMNode node) {
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?view=diff&rev=447543&r1=447542&r2=447543
==============================================================================
--- 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 Mon Sep 18 13:37:49 2006
@@ -75,9 +75,6 @@
public ElementImpl(DocumentImpl ownerDocument, String tagName,
OMFactory factory) {
super(ownerDocument, factory);
- if (ownerDocument.firstChild == null) {
- ownerDocument.firstChild = this;
- }
this.localName = tagName;
this.attributes = new AttributeMap(this);
this.done = true;
@@ -113,8 +110,7 @@
public ElementImpl(ParentNode parentNode, String tagName, NamespaceImpl ns,
OMFactory factory) {
this((DocumentImpl) parentNode.getOwnerDocument(), tagName, ns, factory);
- this.parentNode = parentNode;
- this.parentNode.addChild(this);
+ parentNode.addChild(this);
this.done = true;
}
@@ -124,8 +120,7 @@
if (parentNode != null) {
this.ownerNode = (DocumentImpl) parentNode.getOwnerDocument();
this.isOwned(true);
- this.parentNode = parentNode;
- this.parentNode.addChild(this);
+ parentNode.addChild(this);
}
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java?view=diff&rev=447543&r1=447542&r2=447543
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java Mon Sep 18 13:37:49 2006
@@ -154,6 +154,13 @@
DOMMessageFormatter.DOM_DOMAIN,
"HIERARCHY_REQUEST_ERR", null));
}
+
+ if(newDomChild.parentNode == this) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "HIERARCHY_REQUEST_ERR", null));
+ }
if (!(this instanceof Document)
&& !(this.ownerNode == newDomChild.getOwnerDocument())) {
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/DocumentImplTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/DocumentImplTest.java?view=diff&rev=447543&r1=447542&r2=447543
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/DocumentImplTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/DocumentImplTest.java Mon Sep 18 13:37:49 2006
@@ -15,12 +15,18 @@
*/
package org.apache.axiom.om.impl.dom;
-import junit.framework.TestCase;
import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
+import org.apache.axiom.om.impl.dom.jaxp.DocumentBuilderFactoryImpl;
import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.Node;
import org.w3c.dom.Text;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import junit.framework.TestCase;
+
public class DocumentImplTest extends TestCase {
public DocumentImplTest() {
@@ -79,5 +85,25 @@
assertEquals("Text value mismatch", textValue, txt.getData());
}
+
+ public void testDocumentSiblings() {
+ try {
+ DocumentBuilderFactoryImpl.setDOOMRequired(true);
+ Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+ Element elem = doc.createElement("test");
+ doc.appendChild(elem);
+
+ Node node = doc.getNextSibling();
+ assertNull("Document's next sibling has to be null", node);
+ Node node2 = doc.getPreviousSibling();
+ assertNull("Document's previous sibling has to be null", node2);
+ Node node3 = doc.getParentNode();
+ assertNull("Document's parent has to be null", node3);
+ DocumentBuilderFactoryImpl.setDOOMRequired(false);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org