Author: veithen
Date: Sun Aug 30 23:14:17 2015
New Revision: 1700175

URL: http://svn.apache.org/r1700175
Log:
AXIOM-472: Move more OMFactory code to om-aspects.

Modified:
    
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AxiomNodeFactorySupport.aj
    
webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/OMFactoryEx.java
    
webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
    
webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java

Modified: 
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AxiomNodeFactorySupport.aj
URL: 
http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AxiomNodeFactorySupport.aj?rev=1700175&r1=1700174&r2=1700175&view=diff
==============================================================================
--- 
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AxiomNodeFactorySupport.aj
 (original)
+++ 
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AxiomNodeFactorySupport.aj
 Sun Aug 30 23:14:17 2015
@@ -35,6 +35,7 @@ import org.apache.axiom.om.OMProcessingI
 import org.apache.axiom.om.OMText;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.OMContainerEx;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.om.impl.common.AxiomAttribute;
 import org.apache.axiom.om.impl.common.AxiomCDATASection;
 import org.apache.axiom.om.impl.common.AxiomCharacterDataNode;
@@ -52,6 +53,10 @@ import org.apache.axiom.om.impl.common.T
 import org.apache.axiom.om.impl.util.OMSerializerUtil;
 
 public aspect AxiomNodeFactorySupport {
+    public final OMNamespace AxiomNodeFactory.createOMNamespace(String uri, 
String prefix) {
+        return new OMNamespaceImpl(uri, prefix);
+    }
+    
     public final OMDocument AxiomNodeFactory.createOMDocument() {
         return createNode(AxiomDocument.class);
     }
@@ -275,6 +280,19 @@ public aspect AxiomNodeFactorySupport {
         return createOMElement(qname, null);
     }
     
+    public final OMElement AxiomNodeFactory.createOMElement(String localName, 
String namespaceURI, String prefix) {
+        if (namespaceURI == null) {
+            throw new IllegalArgumentException("namespaceURI must not be 
null");
+        } else if (namespaceURI.length() == 0) {
+            if (prefix != null && prefix.length() > 0) {
+                throw new IllegalArgumentException("Cannot create a prefixed 
element with an empty namespace name");
+            }
+            return createOMElement(localName, null);
+        } else {
+            return createOMElement(localName, createOMNamespace(namespaceURI, 
prefix));
+        }
+    }
+
     public final OMAttribute AxiomNodeFactory.createOMAttribute(String 
localName, OMNamespace ns, String value) {
         if (ns != null && ns.getPrefix() == null) {
             String namespaceURI = ns.getNamespaceURI();
@@ -302,4 +320,56 @@ public aspect AxiomNodeFactorySupport {
         attr.coreSetType(OMConstants.XMLATTRTYPE_CDATA);
         return attr;
     }
+
+    // <old-and-buggy-code>
+    public final OMNode AxiomNodeFactory.importNode(OMNode child) {
+        int type = child.getType();
+        switch (type) {
+            case OMNode.ELEMENT_NODE: {
+                OMElement childElement = (OMElement) child;
+                OMElement newElement = (new StAXOMBuilder(this, childElement
+                        .getXMLStreamReader())).getDocumentElement();
+                newElement.buildWithAttachments();
+                return newElement;
+            }
+            case OMNode.TEXT_NODE: {
+                OMText importedText = (OMText) child;
+                OMText newText;
+                if (importedText.isBinary()) {
+                    boolean isOptimize = importedText.isOptimized();
+                    newText = createOMText(importedText
+                            .getDataHandler(), isOptimize);
+                } else if (importedText.isCharacters()) {
+                    newText = createOMText(null, importedText
+                            .getTextCharacters(), importedText.getType());
+                } else {
+                    newText = createOMText(null, importedText
+                            .getText()/*, importedText.getOMNodeType()*/);
+                }
+                return newText;
+            }
+
+            case OMNode.PI_NODE: {
+                OMProcessingInstruction importedPI = (OMProcessingInstruction) 
child;
+                return createOMProcessingInstruction(null,
+                                                                  
importedPI.getTarget(),
+                                                                  
importedPI.getValue());
+            }
+            case OMNode.COMMENT_NODE: {
+                OMComment importedComment = (OMComment) child;
+                return createOMComment(null, importedComment.getValue());
+            }
+            case OMNode.DTD_NODE : {
+                OMDocType importedDocType = (OMDocType) child;
+                return createOMDocType(null, importedDocType.getRootName(),
+                        importedDocType.getPublicId(), 
importedDocType.getSystemId(),
+                        importedDocType.getInternalSubset());
+            }
+            default: {
+                throw new UnsupportedOperationException(
+                        "Not Implemented Yet for the given node type");
+            }
+        }
+    }
+    // </old-and-buggy-code>
 }

Modified: 
webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/OMFactoryEx.java
URL: 
http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/OMFactoryEx.java?rev=1700175&r1=1700174&r2=1700175&view=diff
==============================================================================
--- 
webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/OMFactoryEx.java
 (original)
+++ 
webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/OMFactoryEx.java
 Sun Aug 30 23:14:17 2015
@@ -60,5 +60,11 @@ public interface OMFactoryEx extends OMF
     
     OMEntityReference createOMEntityReference(OMContainer parent, String name, 
String replacementText, boolean fromBuilder);
     
+    /**
+     * This method is intended only to be used by Axiom intenrals when merging 
nodes from different
+     * Axiom implementations.
+     *
+     * @param child
+     */
     OMNode importNode(OMNode child);
 }

Modified: 
webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
URL: 
http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java?rev=1700175&r1=1700174&r2=1700175&view=diff
==============================================================================
--- 
webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
 (original)
+++ 
webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
 Sun Aug 30 23:14:17 2015
@@ -49,19 +49,12 @@ import org.apache.axiom.dom.DOMNamespace
 import org.apache.axiom.dom.DOMNodeFactory;
 import org.apache.axiom.dom.DOMProcessingInstruction;
 import org.apache.axiom.dom.DOMText;
-import org.apache.axiom.om.OMComment;
 import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMDataSource;
-import org.apache.axiom.om.OMDocType;
-import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMHierarchyException;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.OMProcessingInstruction;
 import org.apache.axiom.om.OMSourcedElement;
-import org.apache.axiom.om.OMText;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.om.impl.common.AxiomAttribute;
 import org.apache.axiom.om.impl.common.AxiomCDATASection;
 import org.apache.axiom.om.impl.common.AxiomCharacterDataNode;
@@ -72,7 +65,6 @@ import org.apache.axiom.om.impl.common.A
 import org.apache.axiom.om.impl.common.AxiomEntityReference;
 import org.apache.axiom.om.impl.common.AxiomNamespaceDeclaration;
 import org.apache.axiom.om.impl.common.AxiomProcessingInstruction;
-import org.apache.axiom.om.impl.common.OMNamespaceImpl;
 import org.apache.axiom.om.impl.common.factory.AxiomNodeFactory;
 import org.apache.axiom.om.impl.dom.CDATASectionImpl;
 import org.apache.axiom.om.impl.dom.CommentImpl;
@@ -169,28 +161,6 @@ public class OMDOMFactory implements Axi
         throw new UnsupportedOperationException("Not supported for DOM");
     }
 
-    public OMElement createOMElement(String localName, String namespaceURI, 
String prefix) {
-        if (namespaceURI == null) {
-            throw new IllegalArgumentException("namespaceURI must not be 
null");
-        } else if (namespaceURI.length() == 0) {
-            if (prefix != null && prefix.length() > 0) {
-                throw new IllegalArgumentException("Cannot create a prefixed 
element with an empty namespace name");
-            }
-            return createOMElement(localName, null);
-        } else {
-            return createOMElement(localName, createOMNamespace(namespaceURI, 
prefix));
-        }
-    }
-
-    /**
-     * Creates a new OMNamespace.
-     *
-     * @see org.apache.axiom.om.OMFactory#createOMNamespace(String, String)
-     */
-    public OMNamespace createOMNamespace(String uri, String prefix) {
-        return new OMNamespaceImpl(uri, prefix);
-    }
-
     public final void validateOMTextParent(OMContainer parent) {
         if (parent instanceof DocumentImpl) {
             throw new OMHierarchyException(
@@ -198,62 +168,6 @@ public class OMDOMFactory implements Axi
         }
     }
     
-    /**
-     * This method is intended only to be used by Axiom intenals when merging 
Objects from different
-     * Axiom implementations to the DOOM implementation.
-     *
-     * @param child
-     */
-    public OMNode importNode(OMNode child) {
-        int type = child.getType();
-        switch (type) {
-            case (OMNode.ELEMENT_NODE): {
-                OMElement childElement = (OMElement) child;
-                OMElement newElement = (new StAXOMBuilder(this,
-                                                          
childElement.getXMLStreamReader()))
-                        .getDocumentElement();
-                newElement.build();
-                return newElement;
-            }
-            case (OMNode.TEXT_NODE): {
-                OMText importedText = (OMText) child;
-                OMText newText;
-                if (importedText.isBinary()) {
-                    boolean isOptimize = importedText.isOptimized();
-                    newText = createOMText(importedText
-                            .getDataHandler(), isOptimize);
-                } else if (importedText.isCharacters()) {
-                    newText = createOMText(null, 
importedText.getTextCharacters(), OMNode.TEXT_NODE);
-                } else {
-                    newText = createOMText(importedText.getText());
-                }
-                return newText;
-            }
-
-            case (OMNode.PI_NODE): {
-                OMProcessingInstruction importedPI = (OMProcessingInstruction) 
child;
-                OMProcessingInstruction newPI =
-                        createOMProcessingInstruction(null, 
importedPI.getTarget(),
-                                                       importedPI.getValue());
-                return newPI;
-            }
-            case (OMNode.COMMENT_NODE): {
-                OMComment importedComment = (OMComment) child;
-                return createOMComment(null, importedComment.getValue());
-            }
-            case (OMNode.DTD_NODE): {
-                OMDocType importedDocType = (OMDocType) child;
-                return createOMDocType(null, importedDocType.getRootName(),
-                        importedDocType.getPublicId(), 
importedDocType.getSystemId(),
-                        importedDocType.getInternalSubset());
-            }
-            default: {
-                throw new UnsupportedOperationException(
-                        "Not Implemented Yet for the given node type");
-            }
-        }
-    }
-
     public final <T extends CoreNode> T createNode(Class<T> type) {
         CoreNode node;
         if (type == CoreCDATASection.class || type == AxiomCDATASection.class 
|| type == DOMCDATASection.class) {

Modified: 
webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java
URL: 
http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java?rev=1700175&r1=1700174&r2=1700175&view=diff
==============================================================================
--- 
webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java
 (original)
+++ 
webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java
 Sun Aug 30 23:14:17 2015
@@ -33,17 +33,10 @@ import org.apache.axiom.core.CoreNamespa
 import org.apache.axiom.core.CoreNode;
 import org.apache.axiom.core.CoreProcessingInstruction;
 import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMComment;
 import org.apache.axiom.om.OMDataSource;
-import org.apache.axiom.om.OMDocType;
-import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.OMProcessingInstruction;
 import org.apache.axiom.om.OMSourcedElement;
-import org.apache.axiom.om.OMText;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.om.impl.common.AxiomAttribute;
 import org.apache.axiom.om.impl.common.AxiomCDATASection;
 import org.apache.axiom.om.impl.common.AxiomCharacterDataNode;
@@ -54,7 +47,6 @@ import org.apache.axiom.om.impl.common.A
 import org.apache.axiom.om.impl.common.AxiomEntityReference;
 import org.apache.axiom.om.impl.common.AxiomNamespaceDeclaration;
 import org.apache.axiom.om.impl.common.AxiomProcessingInstruction;
-import org.apache.axiom.om.impl.common.OMNamespaceImpl;
 import org.apache.axiom.om.impl.common.factory.AxiomNodeFactory;
 import org.apache.axiom.om.impl.llom.CDATASectionImpl;
 import org.apache.axiom.om.impl.llom.CharacterDataImpl;
@@ -137,19 +129,6 @@ public class OMLinkedListImplFactory imp
         return metaFactory;
     }
 
-    public OMElement createOMElement(String localName, String namespaceURI, 
String prefix) {
-        if (namespaceURI == null) {
-            throw new IllegalArgumentException("namespaceURI must not be 
null");
-        } else if (namespaceURI.length() == 0) {
-            if (prefix != null && prefix.length() > 0) {
-                throw new IllegalArgumentException("Cannot create a prefixed 
element with an empty namespace name");
-            }
-            return createOMElement(localName, null);
-        } else {
-            return createOMElement(localName, createOMNamespace(namespaceURI, 
prefix));
-        }
-    }
-
     public OMSourcedElement createOMElement(OMDataSource source) {
         return new OMSourcedElementImpl(this, source);
     }
@@ -175,73 +154,6 @@ public class OMLinkedListImplFactory imp
         return new OMSourcedElementImpl(qname, this, source);
     }
 
-    /**
-     * Method createOMNamespace.
-     *
-     * @param uri
-     * @param prefix
-     * @return Returns OMNamespace.
-     */
-    public OMNamespace createOMNamespace(String uri, String prefix) {
-        return new OMNamespaceImpl(uri, prefix);
-    }
-
-    /**
-     * This method is intended only to be used by Axiom intenals when merging 
Objects from different
-     * Axiom implementations to the LLOM implementation.
-     *
-     * @param child
-     */
-    public OMNode importNode(OMNode child) {
-        int type = child.getType();
-        switch (type) {
-            case (OMNode.ELEMENT_NODE): {
-                OMElement childElement = (OMElement) child;
-                OMElement newElement = (new StAXOMBuilder(this, childElement
-                        .getXMLStreamReader())).getDocumentElement();
-                newElement.buildWithAttachments();
-                return newElement;
-            }
-            case (OMNode.TEXT_NODE): {
-                OMText importedText = (OMText) child;
-                OMText newText;
-                if (importedText.isBinary()) {
-                    boolean isOptimize = importedText.isOptimized();
-                    newText = createOMText(importedText
-                            .getDataHandler(), isOptimize);
-                } else if (importedText.isCharacters()) {
-                    newText = createOMText(null, importedText
-                            .getTextCharacters(), importedText.getType());
-                } else {
-                    newText = createOMText(null, importedText
-                            .getText()/*, importedText.getOMNodeType()*/);
-                }
-                return newText;
-            }
-
-            case (OMNode.PI_NODE): {
-                OMProcessingInstruction importedPI = (OMProcessingInstruction) 
child;
-                return createOMProcessingInstruction(null,
-                                                                  
importedPI.getTarget(),
-                                                                  
importedPI.getValue());
-            }
-            case (OMNode.COMMENT_NODE): {
-                OMComment importedComment = (OMComment) child;
-                return createOMComment(null, importedComment.getValue());
-            }
-            case (OMNode.DTD_NODE) : {
-                OMDocType importedDocType = (OMDocType) child;
-                return createOMDocType(null, importedDocType.getRootName(),
-                        importedDocType.getPublicId(), 
importedDocType.getSystemId(),
-                        importedDocType.getInternalSubset());
-            }
-            default: {
-                throw new UnsupportedOperationException(
-                        "Not Implemented Yet for the given node type");
-            }
-        }
-    }
-
     public <T extends CoreNode> T createNode(Class<T> type) {
         CoreNode node;
         if (type == CoreCDATASection.class || type == AxiomCDATASection.class) 
{


Reply via email to