You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2009/08/31 22:43:19 UTC

svn commit: r809736 - in /xerces/java/trunk/src/org/apache: wml/dom/WMLDOMImplementationImpl.java xerces/dom/CoreDOMImplementationImpl.java xerces/dom/DOMImplementationImpl.java xerces/dom/PSVIDOMImplementationImpl.java

Author: mrglavas
Date: Mon Aug 31 20:43:19 2009
New Revision: 809736

URL: http://svn.apache.org/viewvc?rev=809736&view=rev
Log:
Reduce code duplication. The only difference in all of the overriden createDocument() method was the Document node class we create. That is all we need to override. The rest of the code can live in the base class.

Modified:
    xerces/java/trunk/src/org/apache/wml/dom/WMLDOMImplementationImpl.java
    xerces/java/trunk/src/org/apache/xerces/dom/CoreDOMImplementationImpl.java
    xerces/java/trunk/src/org/apache/xerces/dom/DOMImplementationImpl.java
    xerces/java/trunk/src/org/apache/xerces/dom/PSVIDOMImplementationImpl.java

Modified: xerces/java/trunk/src/org/apache/wml/dom/WMLDOMImplementationImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/wml/dom/WMLDOMImplementationImpl.java?rev=809736&r1=809735&r2=809736&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/wml/dom/WMLDOMImplementationImpl.java (original)
+++ xerces/java/trunk/src/org/apache/wml/dom/WMLDOMImplementationImpl.java Mon Aug 31 20:43:19 2009
@@ -18,14 +18,10 @@
 package org.apache.wml.dom;
 
 import org.apache.wml.WMLDOMImplementation;
+import org.apache.xerces.dom.CoreDocumentImpl;
 import org.apache.xerces.dom.DOMImplementationImpl;
-import org.apache.xerces.dom.DOMMessageFormatter;
-import org.apache.xerces.dom.DocumentImpl;
-import org.w3c.dom.DOMException;
 import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.Document;
 import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
 
 /**
  * @xerces.internal
@@ -39,27 +35,14 @@
     /** NON-DOM: Obtain and return the single shared object */
     public static DOMImplementation getDOMImplementation() {
         return singleton;
-    }  
+    }
+    
+    //
+    // Protected methods
+    //
     
-    /**
-     * @see org.w3c.dom.DOMImplementation
-     */
-    public Document createDocument(String namespaceURI, 
-            String qualifiedName, 
-            DocumentType doctype) throws DOMException {
-        if (doctype != null && doctype.getOwnerDocument() != null) {
-            throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, 
-                                   DOMMessageFormatter.formatMessage(
-                                   DOMMessageFormatter.XML_DOMAIN, 
-                                   "WRONG_DOCUMENT_ERR", null));
-        }
-        DocumentImpl doc = new WMLDocumentImpl(doctype);
-        // If namespaceURI and qualifiedName are null return a Document with no document element.
-        if (qualifiedName != null || namespaceURI != null) {
-            Element e = doc.createElementNS(namespaceURI, qualifiedName);
-            doc.appendChild(e);
-        }
-        return doc;
+    protected CoreDocumentImpl createDocument(DocumentType doctype) {
+        return new WMLDocumentImpl(doctype);
     }
 }
 

Modified: xerces/java/trunk/src/org/apache/xerces/dom/CoreDOMImplementationImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/dom/CoreDOMImplementationImpl.java?rev=809736&r1=809735&r2=809736&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/dom/CoreDOMImplementationImpl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/dom/CoreDOMImplementationImpl.java Mon Aug 31 20:43:19 2009
@@ -289,7 +289,7 @@
 					null);
 			throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
 		}
-		CoreDocumentImpl doc = new CoreDocumentImpl(doctype);
+		CoreDocumentImpl doc = createDocument(doctype);
 		// If namespaceURI and qualifiedName are null return a Document with no document element.
 		if (qualifiedName != null || namespaceURI != null) {
 		    Element e = doc.createElementNS(namespaceURI, qualifiedName);
@@ -297,6 +297,10 @@
 		}
 		return doc;
 	}
+	
+	protected CoreDocumentImpl createDocument(DocumentType doctype) {
+	    return new CoreDocumentImpl(doctype);
+	}
 
 	/**
 	 * DOM Level 3 WD - Experimental.

Modified: xerces/java/trunk/src/org/apache/xerces/dom/DOMImplementationImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/dom/DOMImplementationImpl.java?rev=809736&r1=809735&r2=809736&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/dom/DOMImplementationImpl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/dom/DOMImplementationImpl.java Mon Aug 31 20:43:19 2009
@@ -17,13 +17,8 @@
 
 package org.apache.xerces.dom;
 
-import org.w3c.dom.DOMException;
 import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.Document;
 import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-
-
 
 /**
  * The DOMImplementation class is description of a particular
@@ -102,46 +97,13 @@
         }
         return result;
     } // hasFeature(String,String):boolean
-
-
-
-    /**
-     * Introduced in DOM Level 2. <p>
-     *
-     * Creates an XML Document object of the specified type with its document
-     * element.
-     *
-     * @param namespaceURI     The namespace URI of the document
-     *                         element to create, or null.
-     * @param qualifiedName    The qualified name of the document
-     *                         element to create.
-     * @param doctype          The type of document to be created or null.<p>
-     *
-     *                         When doctype is not null, its
-     *                         Node.ownerDocument attribute is set to
-     *                         the document being created.
-     * @return Document        A new Document object.
-     * @throws DOMException    WRONG_DOCUMENT_ERR: Raised if doctype has
-     *                         already been used with a different document.
-     * @since WD-DOM-Level-2-19990923
-     */
-    public Document           createDocument(String namespaceURI,
-                                             String qualifiedName,
-                                             DocumentType doctype)
-                                             throws DOMException
-    {
-        if (doctype != null && doctype.getOwnerDocument() != null) {
-            String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null);
-            throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
-        }
-        DocumentImpl doc = new DocumentImpl(doctype);
-        // If namespaceURI and qualifiedName are null return a Document with no document element.
-        if (qualifiedName != null || namespaceURI != null) {
-            Element e = doc.createElementNS(namespaceURI, qualifiedName);
-            doc.appendChild(e);
-        }
-        return doc;
+    
+    //
+    // Protected methods
+    //
+    
+    protected CoreDocumentImpl createDocument(DocumentType doctype) {
+        return new DocumentImpl(doctype);
     }
 
-
 } // class DOMImplementationImpl

Modified: xerces/java/trunk/src/org/apache/xerces/dom/PSVIDOMImplementationImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/dom/PSVIDOMImplementationImpl.java?rev=809736&r1=809735&r2=809736&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/dom/PSVIDOMImplementationImpl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/dom/PSVIDOMImplementationImpl.java Mon Aug 31 20:43:19 2009
@@ -17,11 +17,8 @@
 
 package org.apache.xerces.dom;
 
-import org.w3c.dom.DOMException;
 import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.Document;
 import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
 
 /**
  * The DOMImplementation class is description of a particular
@@ -81,45 +78,12 @@
                feature.equalsIgnoreCase("psvi");
     } // hasFeature(String,String):boolean
     
-    /**
-     * Introduced in DOM Level 2. <p>
-     * 
-     * Creates an XML Document object of the specified type with its document
-     * element.
-     *
-     * @param namespaceURI     The namespace URI of the document
-     *                         element to create, or null. 
-     * @param qualifiedName    The qualified name of the document
-     *                         element to create. 
-     * @param doctype          The type of document to be created or null.<p>
-     *
-     *                         When doctype is not null, its
-     *                         Node.ownerDocument attribute is set to
-     *                         the document being created.
-     * @return Document        A new Document object.
-     * @throws DOMException    WRONG_DOCUMENT_ERR: Raised if doctype has
-     *                         already been used with a different document.
-     * @since WD-DOM-Level-2-19990923
-     */
-    public Document           createDocument(String namespaceURI, 
-                                             String qualifiedName, 
-                                             DocumentType doctype)
-                                             throws DOMException
-    {
-    	if (doctype != null && doctype.getOwnerDocument() != null) {
-            throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, 
-                                   DOMMessageFormatter.formatMessage(
-                                   DOMMessageFormatter.XML_DOMAIN, 
-					               "WRONG_DOCUMENT_ERR", null));
-        }
-        DocumentImpl doc = new PSVIDocumentImpl(doctype);
-        // If namespaceURI and qualifiedName are null return a Document with no document element.
-        if (qualifiedName != null || namespaceURI != null) {
-            Element e = doc.createElementNS(namespaceURI, qualifiedName);
-            doc.appendChild(e);
-        }
-        return doc;
-    }
+    //
+    // Protected methods
+    //
     
+    protected CoreDocumentImpl createDocument(DocumentType doctype) {
+        return new PSVIDocumentImpl(doctype);
+    }
 
-} // class DOMImplementationImpl
+} // class PSVIDOMImplementationImpl



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org