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 2012/07/26 20:41:20 UTC

svn commit: r1366142 - in /webservices/axiom/branches/AXIOM-435/modules: axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/ axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/ axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/

Author: veithen
Date: Thu Jul 26 18:41:19 2012
New Revision: 1366142

URL: http://svn.apache.org/viewvc?rev=1366142&view=rev
Log:
Implemented DOM's EntityReference API.

Added:
    webservices/axiom/branches/AXIOM-435/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCreateEntityReference.java   (with props)
Modified:
    webservices/axiom/branches/AXIOM-435/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
    webservices/axiom/branches/AXIOM-435/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
    webservices/axiom/branches/AXIOM-435/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/EntityReferenceImpl.java

Modified: webservices/axiom/branches/AXIOM-435/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-435/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java?rev=1366142&r1=1366141&r2=1366142&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-435/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java (original)
+++ webservices/axiom/branches/AXIOM-435/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java Thu Jul 26 18:41:19 2012
@@ -57,6 +57,7 @@ public class DOMTestSuiteBuilder extends
         addTest(new org.apache.axiom.ts.dom.document.TestCreateElementNS(dbf));
         addTest(new org.apache.axiom.ts.dom.document.TestCreateElementNSWithInvalidName(dbf));
         addTest(new org.apache.axiom.ts.dom.document.TestCreateElementNSWithoutNamespace(dbf));
+        addTest(new org.apache.axiom.ts.dom.document.TestCreateEntityReference(dbf));
         addTest(new org.apache.axiom.ts.dom.document.TestCreateText(dbf));
         addTest(new org.apache.axiom.ts.dom.document.TestDocumentSiblings(dbf));
         addTest(new org.apache.axiom.ts.dom.document.TestGetDomConfigDefaults(dbf));

Added: webservices/axiom/branches/AXIOM-435/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCreateEntityReference.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-435/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCreateEntityReference.java?rev=1366142&view=auto
==============================================================================
--- webservices/axiom/branches/AXIOM-435/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCreateEntityReference.java (added)
+++ webservices/axiom/branches/AXIOM-435/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCreateEntityReference.java Thu Jul 26 18:41:19 2012
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.ts.dom.document;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.axiom.ts.dom.DOMTestCase;
+import org.w3c.dom.Document;
+import org.w3c.dom.EntityReference;
+import org.w3c.dom.Node;
+
+public class TestCreateEntityReference extends DOMTestCase {
+    public TestCreateEntityReference(DocumentBuilderFactory dbf) {
+        super(dbf);
+    }
+
+    protected void runTest() throws Throwable {
+        Document document = dbf.newDocumentBuilder().newDocument();
+        EntityReference entref = document.createEntityReference("myentity");
+        assertEquals(Node.ENTITY_REFERENCE_NODE, entref.getNodeType());
+        assertEquals("myentity", entref.getNodeName());
+        assertNull(entref.getNodeValue());
+        assertSame(document, entref.getOwnerDocument());
+    }
+}

Propchange: webservices/axiom/branches/AXIOM-435/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/document/TestCreateEntityReference.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axiom/branches/AXIOM-435/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-435/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java?rev=1366142&r1=1366141&r2=1366142&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-435/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java (original)
+++ webservices/axiom/branches/AXIOM-435/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java Thu Jul 26 18:41:19 2012
@@ -198,10 +198,10 @@ public class DocumentImpl extends RootNo
         return element;
     }
 
-    public EntityReference createEntityReference(String name)
-            throws DOMException {
-        // TODO
-        throw new UnsupportedOperationException("TODO");
+    public EntityReference createEntityReference(String name) throws DOMException {
+        EntityReferenceImpl node = new EntityReferenceImpl(name, null, factory);
+        node.setOwnerDocument(this);
+        return node;
     }
 
     public ProcessingInstruction createProcessingInstruction(String target,

Modified: webservices/axiom/branches/AXIOM-435/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/EntityReferenceImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-435/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/EntityReferenceImpl.java?rev=1366142&r1=1366141&r2=1366142&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-435/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/EntityReferenceImpl.java (original)
+++ webservices/axiom/branches/AXIOM-435/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/EntityReferenceImpl.java Thu Jul 26 18:41:19 2012
@@ -24,8 +24,10 @@ import javax.xml.stream.XMLStreamWriter;
 import org.apache.axiom.om.OMEntityReference;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNode;
+import org.w3c.dom.EntityReference;
+import org.w3c.dom.Node;
 
-public class EntityReferenceImpl extends LeafNode implements OMEntityReference {
+public class EntityReferenceImpl extends LeafNode implements OMEntityReference, EntityReference {
     private final String name;
     private final String replacementText;
 
@@ -56,12 +58,10 @@ public class EntityReferenceImpl extends
     }
 
     public String getNodeName() {
-        // TODO Auto-generated method stub
-        throw new UnsupportedOperationException();
+        return name;
     }
 
     public short getNodeType() {
-        // TODO Auto-generated method stub
-        throw new UnsupportedOperationException();
+        return Node.ENTITY_REFERENCE_NODE;
     }
 }