axis-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1377526 [2/3] - in /axis/axis2/java/core/branches/1_6: ./ modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/ modules/saaj/ modules/saaj/src/org/apache/axis2/saaj/ modules/saaj/src/org/apache/axis2/saaj/util/ modules/saaj/test/org/...
Date Sun, 26 Aug 2012 21:42:36 GMT
Modified: axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java?rev=1377526&r1=1377525&r2=1377526&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java (original)
+++ axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java Sun Aug 26 21:42:35 2012
@@ -21,20 +21,17 @@ package org.apache.axis2.saaj;
 
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.impl.OMNamespaceImpl;
-import org.apache.axiom.om.impl.dom.ElementImpl;
-import org.apache.axiom.om.impl.dom.NodeImpl;
-import org.apache.axiom.om.impl.dom.TextImpl;
-import org.apache.axiom.soap.SOAP11Constants;
-import org.apache.axiom.soap.SOAP12Constants;
-import org.apache.axiom.soap.impl.dom.soap11.SOAP11Factory;
-import org.apache.axiom.soap.impl.dom.soap12.SOAP12Factory;
+import org.apache.axiom.om.OMText;
+import org.apache.axiom.om.impl.OMElementEx;
+import org.apache.axiom.soap.SOAP11Version;
+import org.apache.axiom.soap.SOAP12Version;
+import org.apache.axiom.soap.SOAPFactory;
 import org.w3c.dom.Attr;
 import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
@@ -59,30 +56,23 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
 
-public class SOAPElementImpl extends NodeImplEx implements SOAPElement {
-
-    /**
-     * Using a delegate because we can't extend from org.apache.axiom.om.impl.dom.ElementImpl since
-     * this class must extend SNodeImpl
-     */
-    protected ElementImpl element;
+public class SOAPElementImpl<T extends OMElement> extends SAAJNode<Element,T> implements SOAPElement {
     private String encodingStyle;
 
-    public SOAPElementImpl(ElementImpl element) {
-        super(element.getOMFactory());
-        this.element = element;
+    public SOAPElementImpl(T element) {
+        super((Element)element, element);
     }
 
     /* (non-Javadoc)
       * @see org.apache.axiom.om.OMNode#discard()
       */
     public void discard() throws OMException {
-        element.discard();
+        omTarget.discard();
     }
 
     public void internalSerialize(javax.xml.stream.XMLStreamWriter writer, boolean cache)
             throws XMLStreamException {
-        element.internalSerialize(writer, cache);
+        ((OMElementEx)omTarget).internalSerialize(writer, cache);
     }
 
     /**
@@ -96,9 +86,9 @@ public class SOAPElementImpl extends Nod
      */
     public SOAPElement addAttribute(Name name, String value) throws SOAPException {
         if (name.getURI() == null || name.getURI().trim().length() == 0) {
-            element.setAttribute(name.getLocalName(), value);
+            target.setAttribute(name.getLocalName(), value);
         } else {
-            element.setAttributeNS(name.getURI(), name.getPrefix() + ":" + name.getLocalName(),
+            target.setAttributeNS(name.getURI(), name.getPrefix() + ":" + name.getLocalName(),
                                    value);
         }
         return this;
@@ -121,13 +111,13 @@ public class SOAPElementImpl extends Nod
         String prefix = soapElement.getPrefix();
         String localName = soapElement.getLocalName();
 
-        SOAPElementImpl childEle;        
+        SOAPElementImpl<OMElement> childEle;        
         if (namespaceURI == null || namespaceURI.trim().length() == 0) {
-            childEle =  new SOAPElementImpl((ElementImpl)getOwnerDocument().createElement(localName));
+            childEle =  new SOAPElementImpl<OMElement>((OMElement)getOwnerDocument().createElement(localName));
         } else {
-            element.declareNamespace(namespaceURI, prefix);
+            omTarget.declareNamespace(namespaceURI, prefix);
             childEle =
-                new SOAPElementImpl((ElementImpl)getOwnerDocument().createElementNS(namespaceURI,
+                new SOAPElementImpl<OMElement>((OMElement)getOwnerDocument().createElementNS(namespaceURI,
                                                                                     localName));
         }
         
@@ -145,31 +135,16 @@ public class SOAPElementImpl extends Nod
             }
         }
 
-        childEle.element.setUserData(SAAJ_NODE, childEle, null);
+        childEle.target.setUserData(SAAJ_NODE, childEle, null);
         if (namespaceURI != null && namespaceURI.trim().length() > 0) {
-            childEle.element.setNamespace(childEle.element.declareNamespace(namespaceURI, prefix));
+            childEle.omTarget.setNamespace(childEle.omTarget.declareNamespace(namespaceURI, prefix));
         }
-        element.appendChild(childEle.element);
-        ((NodeImpl)childEle.element.getParentNode()).setUserData(SAAJ_NODE, this, null);
+        target.appendChild(childEle.target);
+        childEle.target.getParentNode().setUserData(SAAJ_NODE, this, null);
         childEle.setParentElement(this);
         return childEle;
     }
 
-    public String getLocalName() {
-        return element.getLocalName();
-    }
-
-    public String getNamespaceURI() {
-        return element.getNamespaceURI();
-    }
-
-    /*
-    * Overidden in ElementImpl and AttrImpl.
-    */
-    public String getPrefix() {
-        return element.getPrefix();
-    }
-
     /* (non-Javadoc)
     * @see javax.xml.soap.SOAPElement#addChildElement(java.lang.String, java.lang.String, java.lang.String)
     */
@@ -178,16 +153,16 @@ public class SOAPElementImpl extends Nod
         if (prefix == null) {
             prefix = "";
         }
-        SOAPElementImpl childEle =
-                new SOAPElementImpl((ElementImpl)getOwnerDocument().
+        SOAPElementImpl<OMElement> childEle =
+                new SOAPElementImpl<OMElement>((OMElement)getOwnerDocument().
                         createElementNS(namespaceURI, prefix.length() == 0 ? localName : prefix + ":" + localName));
     
-        childEle.element.setUserData(SAAJ_NODE, childEle, null);
-        childEle.element.setNamespace(prefix.length() == 0
-                ? childEle.element.declareDefaultNamespace(namespaceURI)
-                : childEle.element.declareNamespace(namespaceURI, prefix));
-        element.appendChild(childEle.element);
-        ((NodeImpl)childEle.element.getParentNode()).setUserData(SAAJ_NODE, this, null);
+        childEle.target.setUserData(SAAJ_NODE, childEle, null);
+        childEle.omTarget.setNamespace(prefix.length() == 0
+                ? childEle.omTarget.declareDefaultNamespace(namespaceURI)
+                : childEle.omTarget.declareNamespace(namespaceURI, prefix));
+        target.appendChild(childEle.target);
+        childEle.target.getParentNode().setUserData(SAAJ_NODE, this, null);
         childEle.setParentElement(this);
         return childEle;
     }
@@ -209,11 +184,11 @@ public class SOAPElementImpl extends Nod
       * @see javax.xml.soap.SOAPElement#addChildElement(java.lang.String)
       */
     public SOAPElement addChildElement(String localName) throws SOAPException {
-        SOAPElementImpl childEle =
-                new SOAPElementImpl((ElementImpl)getOwnerDocument().createElement(localName));
-        childEle.element.setUserData(SAAJ_NODE, childEle, null);
-        element.appendChild(childEle.element);
-        ((NodeImpl)childEle.element.getParentNode()).setUserData(SAAJ_NODE, this, null);
+        SOAPElementImpl<OMElement> childEle =
+                new SOAPElementImpl<OMElement>((OMElement)getOwnerDocument().createElement(localName));
+        childEle.target.setUserData(SAAJ_NODE, childEle, null);
+        target.appendChild(childEle.target);
+        childEle.target.getParentNode().setUserData(SAAJ_NODE, this, null);
         childEle.setParentElement(this);
         return childEle;
     }
@@ -223,9 +198,9 @@ public class SOAPElementImpl extends Nod
       */
     public SOAPElement addNamespaceDeclaration(String prefix, String uri) throws SOAPException {
         if (prefix == null || prefix.length() == 0) {
-            element.declareDefaultNamespace(uri);
+            omTarget.declareDefaultNamespace(uri);
         } else {
-            element.declareNamespace(uri, prefix);
+            omTarget.declareNamespace(uri, prefix);
         }
         return this;
     }
@@ -244,9 +219,9 @@ public class SOAPElementImpl extends Nod
         //Therefore create a text node and add it
         //TODO: May need to address the situation where the prev sibling of the textnode itself is a textnode
         Text textNode = getOwnerDocument().createTextNode(text);
-        NodeImpl node = ((NodeImpl)element.appendChild(textNode));
-        TextImplEx saajTextNode = new TextImplEx((TextImpl)textNode, this);
-        node.setUserData(SAAJ_NODE, saajTextNode, null);
+        target.appendChild(textNode);
+        TextImplEx saajTextNode = new TextImplEx((OMText)textNode, this);
+        textNode.setUserData(SAAJ_NODE, saajTextNode, null);
         return this;
     }
 
@@ -258,7 +233,7 @@ public class SOAPElementImpl extends Nod
      * @return an iterator over the names of the attributes
      */
     public Iterator getAllAttributes() {
-        final Iterator attribIter = element.getAllAttributes();
+        final Iterator attribIter = omTarget.getAllAttributes();
         Collection attribName = new ArrayList();
         Attr attr;
         while (attribIter.hasNext()) {
@@ -284,7 +259,7 @@ public class SOAPElementImpl extends Nod
     public String getAttributeValue(Name name) {
         //This method is waiting on the finalization of the name for a method
         //in OMElement that returns a OMAttribute from an input QName
-        final OMAttribute attribute = element.getAttribute(new QName(name.getURI(),
+        final OMAttribute attribute = omTarget.getAttribute(new QName(name.getURI(),
                                                                      name.getLocalName(),
                                                                      name.getPrefix()));
         if (attribute == null) {
@@ -301,7 +276,7 @@ public class SOAPElementImpl extends Nod
      *         <CODE>SOAPElement</CODE> object
      */
     public Iterator getChildElements() {
-        Iterator childIter = element.getChildren();
+        Iterator childIter = omTarget.getChildren();
         Collection childElements = new ArrayList();
         while (childIter.hasNext()) {
             childElements.add(toSAAJNode((org.w3c.dom.Node)childIter.next()));
@@ -314,7 +289,7 @@ public class SOAPElementImpl extends Nod
       */
     public Iterator getChildElements(Name name) {
         QName qName = new QName(name.getURI(), name.getLocalName());
-        Iterator childIter = element.getChildrenWithName(qName);
+        Iterator childIter = omTarget.getChildrenWithName(qName);
         Collection childElements = new ArrayList();
         while (childIter.hasNext()) {
             childElements.add(toSAAJNode((org.w3c.dom.Node)childIter.next()));
@@ -326,7 +301,7 @@ public class SOAPElementImpl extends Nod
       * @see javax.xml.soap.SOAPElement#getElementName()
       */
     public Name getElementName() {
-        QName qName = element.getQName();
+        QName qName = omTarget.getQName();
         return new PrefixedQName(qName.getNamespaceURI(),
                                  qName.getLocalPart(),
                                  qName.getPrefix());
@@ -345,7 +320,7 @@ public class SOAPElementImpl extends Nod
     public Iterator getNamespacePrefixes() {
         //Get all declared namespace, make a list of their prefixes and return an iterator over that list
         ArrayList prefixList = new ArrayList();
-        Iterator nsIter = element.getAllDeclaredNamespaces();
+        Iterator nsIter = omTarget.getAllDeclaredNamespaces();
         while (nsIter.hasNext()) {
             Object o = nsIter.next();
             if (o instanceof org.apache.axiom.om.OMNamespace) {
@@ -360,7 +335,8 @@ public class SOAPElementImpl extends Nod
       * @see javax.xml.soap.SOAPElement#getNamespaceURI(java.lang.String)
       */
     public String getNamespaceURI(String prefix) {
-        return element.getNamespaceURI(prefix);
+        OMNamespace ns = omTarget.findNamespaceURI(prefix);
+        return ns != null ? ns.getNamespaceURI() : null;
     }
 
     /* (non-Javadoc)
@@ -368,7 +344,7 @@ public class SOAPElementImpl extends Nod
       */
     public Iterator getVisibleNamespacePrefixes() {
         //I'll recursively return all the declared namespaces till this node, including its parents etc.
-        Iterator namespacesIter = element.getAllDeclaredNamespaces();
+        Iterator namespacesIter = omTarget.getAllDeclaredNamespaces();
         ArrayList returnList = new ArrayList();
         while (namespacesIter.hasNext()) {
             Object o = namespacesIter.next();
@@ -382,7 +358,7 @@ public class SOAPElementImpl extends Nod
         //taken care of adding namespaces of this node.
         //now we have to take care of adding the namespaces that are in the scope till the level of
         //this nodes' parent.
-        org.apache.axiom.om.OMContainer parent = element.getParent();
+        org.apache.axiom.om.OMContainer parent = omTarget.getParent();
         if (parent != null && parent instanceof org.apache.axiom.om.OMElement) {
             Iterator parentScopeNamespacesIter =
                     ((org.apache.axiom.om.OMElement)parent).getAllDeclaredNamespaces();
@@ -402,9 +378,9 @@ public class SOAPElementImpl extends Nod
 
     public SOAPElement addAttribute(QName qname, String value) throws SOAPException {
         if (qname.getNamespaceURI() == null || qname.getNamespaceURI().trim().length() == 0) {
-            element.setAttribute(qname.getLocalPart(), value);
+            target.setAttribute(qname.getLocalPart(), value);
         } else {
-            element.setAttributeNS(qname.getNamespaceURI(), qname.getPrefix() + ":" +
+            target.setAttributeNS(qname.getNamespaceURI(), qname.getPrefix() + ":" +
                     qname.getLocalPart(), value);
         }
         return this;
@@ -431,7 +407,7 @@ public class SOAPElementImpl extends Nod
      * @since SAAJ 1.3
      */
     public QName createQName(String localName, String prefix) throws SOAPException {
-        String namespaceURI = element.getNamespaceURI(prefix);
+        String namespaceURI = getNamespaceURI(prefix);
         if (namespaceURI == null) {
             throw new SOAPException("Invalid prefix");
         } else {
@@ -440,7 +416,7 @@ public class SOAPElementImpl extends Nod
     }
 
     public Iterator getAllAttributesAsQNames() {
-        final Iterator attribIter = element.getAllAttributes();
+        final Iterator attribIter = omTarget.getAllAttributes();
         Collection attributesAsQNames = new ArrayList();
         Attr attr;
         QName qname;
@@ -454,7 +430,7 @@ public class SOAPElementImpl extends Nod
     }
 
     public String getAttributeValue(QName qname) {
-        final OMAttribute attribute = element.getAttribute(qname);
+        final OMAttribute attribute = omTarget.getAttribute(qname);
         if (attribute == null) {
             return null;
         }
@@ -462,7 +438,7 @@ public class SOAPElementImpl extends Nod
     }
 
     public Iterator getChildElements(QName qname) {
-        Iterator childIter = element.getChildrenWithName(qname);
+        Iterator childIter = omTarget.getChildrenWithName(qname);
         Collection childElements = new ArrayList();
         while (childIter.hasNext()) {
             childElements.add(toSAAJNode((org.w3c.dom.Node)childIter.next()));
@@ -471,29 +447,29 @@ public class SOAPElementImpl extends Nod
     }
 
     public QName getElementQName() {
-        return element.getQName();
+        return omTarget.getQName();
     }
 
     public boolean removeAttribute(QName qname) {
-        org.apache.axiom.om.OMAttribute attr = element.getAttribute(qname);
+        org.apache.axiom.om.OMAttribute attr = omTarget.getAttribute(qname);
         if (attr != null) {
-            element.removeAttribute(attr);
+            omTarget.removeAttribute(attr);
             return true;
         }
         return false;
     }
 
     public SOAPElement setElementQName(QName newName) throws SOAPException {
-        String localName = this.element.getLocalName();
+        String localName = this.target.getLocalName();
         if (org.apache.axiom.soap.SOAPConstants.BODY_LOCAL_NAME.equals(localName)
                 || org.apache.axiom.soap.SOAPConstants.HEADER_LOCAL_NAME.equals(localName)
                 || org.apache.axiom.soap.SOAPConstants.SOAPENVELOPE_LOCAL_NAME .equals(localName)) {
             throw new SOAPException("changing this element name is not allowed");
         }
         OMNamespace omNamespace =
-                new OMNamespaceImpl(newName.getNamespaceURI(), newName.getPrefix());
-        this.element.setNamespace(omNamespace);
-        this.element.setLocalName(newName.getLocalPart());
+                omTarget.getOMFactory().createOMNamespace(newName.getNamespaceURI(), newName.getPrefix());
+        this.omTarget.setNamespace(omNamespace);
+        this.omTarget.setLocalName(newName.getLocalPart());
         return this;
     }
 
@@ -501,11 +477,11 @@ public class SOAPElementImpl extends Nod
       * @see javax.xml.soap.SOAPElement#removeAttribute(javax.xml.soap.Name)
       */
     public boolean removeAttribute(Name name) {
-        org.apache.axiom.om.OMAttribute attr = element.getAttribute(new QName(name.getURI(),
+        org.apache.axiom.om.OMAttribute attr = omTarget.getAttribute(new QName(name.getURI(),
                                                                               name.getLocalName(),
                                                                               name.getPrefix()));
         if (attr != null) {
-            element.removeAttribute(attr);
+            omTarget.removeAttribute(attr);
             return true;
         }
         return false;
@@ -516,7 +492,7 @@ public class SOAPElementImpl extends Nod
       */
     public void removeContents() {
         //We will get all the children and iteratively call the detach() on all of 'em.
-        Iterator childIter = element.getChildElements();
+        Iterator childIter = omTarget.getChildElements();
         while (childIter.hasNext()) {
             childIter.next();
             childIter.remove();
@@ -527,7 +503,13 @@ public class SOAPElementImpl extends Nod
       * @see javax.xml.soap.SOAPElement#removeNamespaceDeclaration(java.lang.String)
       */
     public boolean removeNamespaceDeclaration(String prefix) {
-        return element.removeNamespace(prefix);
+        for (Iterator<OMNamespace> it = omTarget.getAllDeclaredNamespaces(); it.hasNext(); ) {
+            if (it.next().getPrefix().equals(prefix)) {
+                it.remove();
+                return true;
+            }
+        }
+        return false;
     }
 
 
@@ -540,7 +522,7 @@ public class SOAPElementImpl extends Nod
      *          the encodingStyle is invalid for this SOAPElement.
      */
     public void setEncodingStyle(String encodingStyle) throws SOAPException {
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
+        if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton()) {
             try {
                 URI uri = new URI(encodingStyle);
                 if (!(this instanceof SOAPEnvelope)) {
@@ -554,7 +536,7 @@ public class SOAPElementImpl extends Nod
                 throw new IllegalArgumentException("Invalid Encoding style : "
                         + encodingStyle + ":" + e);
             }
-        } else if (this.element.getOMFactory() instanceof SOAP12Factory) {
+        } else if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP12Version.getSingleton()) {
             if (this instanceof SOAPHeader || this instanceof SOAPBody ||
                     this instanceof SOAPFault ||
                     this instanceof SOAPFaultElement || this instanceof SOAPEnvelope ||
@@ -568,112 +550,112 @@ public class SOAPElementImpl extends Nod
       * @see org.apache.axiom.om.impl.OMNodeEx#setParent(org.apache.axiom.om.OMContainer)
       */
     public void setParent(OMContainer parentElement) {
-        element.setParent(parentElement);
+        ((OMElementEx)omTarget).setParent(parentElement);
     }
 
     /* (non-Javadoc)
       * @see org.w3c.dom.Element#getAttribute(java.lang.String)
       */
     public String getAttribute(String name) {
-        return element.getAttribute(name);
+        return target.getAttribute(name);
     }
 
     /* (non-Javadoc)
       * @see org.w3c.dom.Element#getAttributeNode(java.lang.String)
       */
     public Attr getAttributeNode(String name) {
-        return element.getAttributeNode(name);
+        return target.getAttributeNode(name);
     }
 
     /* (non-Javadoc)
       * @see org.w3c.dom.Element#getAttributeNodeNS(java.lang.String, java.lang.String)
       */
     public Attr getAttributeNodeNS(String namespaceURI, String localName) {
-        return element.getAttributeNodeNS(namespaceURI, localName);
+        return target.getAttributeNodeNS(namespaceURI, localName);
     }
 
     /* (non-Javadoc)
       * @see org.w3c.dom.Element#getAttributeNS(java.lang.String, java.lang.String)
       */
     public String getAttributeNS(String namespaceURI, String localName) {
-        return element.getAttributeNS(namespaceURI, localName);
+        return target.getAttributeNS(namespaceURI, localName);
     }
 
     /* (non-Javadoc)
       * @see org.w3c.dom.Element#getElementsByTagName(java.lang.String)
       */
     public NodeList getElementsByTagName(String name) {
-        return toSAAJNodeList(element.getElementsByTagName(name));
+        return toSAAJNodeList(target.getElementsByTagName(name));
     }
 
     /* (non-Javadoc)
       * @see org.w3c.dom.Element#getElementsByTagNameNS(java.lang.String, java.lang.String)
       */
     public NodeList getElementsByTagNameNS(String namespaceURI, String localName) {
-        return toSAAJNodeList(element.getElementsByTagNameNS(namespaceURI, localName));
+        return toSAAJNodeList(target.getElementsByTagNameNS(namespaceURI, localName));
     }
 
     /* (non-Javadoc)
       * @see org.w3c.dom.Element#getTagName()
       */
     public String getTagName() {
-        return element.getTagName();
+        return target.getTagName();
     }
 
     /* (non-Javadoc)
       * @see org.w3c.dom.Element#hasAttribute(java.lang.String)
       */
     public boolean hasAttribute(String name) {
-        return element.hasAttribute(name);
+        return target.hasAttribute(name);
     }
 
     /* (non-Javadoc)
       * @see org.w3c.dom.Element#hasAttributeNS(java.lang.String, java.lang.String)
       */
     public boolean hasAttributeNS(String namespaceURI, String localName) {
-        return element.hasAttributeNS(namespaceURI, localName);
+        return target.hasAttributeNS(namespaceURI, localName);
     }
 
     /* (non-Javadoc)
       * @see org.w3c.dom.Element#removeAttribute(java.lang.String)
       */
     public void removeAttribute(String name) throws DOMException {
-        element.removeAttribute(name);
+        target.removeAttribute(name);
     }
 
     /* (non-Javadoc)
       * @see org.w3c.dom.Element#removeAttributeNode(org.w3c.dom.Attr)
       */
     public Attr removeAttributeNode(Attr attr) throws DOMException {
-        return element.removeAttributeNode(attr);
+        return target.removeAttributeNode(attr);
     }
 
     /* (non-Javadoc)
       * @see org.w3c.dom.Element#removeAttributeNS(java.lang.String, java.lang.String)
       */
     public void removeAttributeNS(String namespaceURI, String localName) throws DOMException {
-        element.removeAttributeNS(namespaceURI, localName);
+        target.removeAttributeNS(namespaceURI, localName);
     }
 
     /* (non-Javadoc)
       * @see org.w3c.dom.Element#setAttribute(java.lang.String, java.lang.String)
       */
     public void setAttribute(String name, String value) throws DOMException {
-        element.setAttribute(name, value);
+        target.setAttribute(name, value);
     }
 
     /* (non-Javadoc)
       * @see org.w3c.dom.Element#setAttributeNode(org.w3c.dom.Attr)
       */
     public Attr setAttributeNode(Attr attr) throws DOMException {
-        return element.setAttributeNode(attr);
+        return target.setAttributeNode(attr);
     }
 
     /* (non-Javadoc)
       * @see org.w3c.dom.Element#setAttributeNodeNS(org.w3c.dom.Attr)
       */
     public Attr setAttributeNodeNS(Attr attr) throws DOMException {
-        return element.setAttributeNodeNS(attr);
+        return target.setAttributeNodeNS(attr);
     }
 
     /* (non-Javadoc)
@@ -681,25 +663,7 @@ public class SOAPElementImpl extends Nod
       */
     public void setAttributeNS(String namespaceURI,
                                String qualifiedName, String value) throws DOMException {
-        element.setAttributeNS(namespaceURI, qualifiedName, value);
-    }
-
-    /* (non-Javadoc)
-      * @see org.w3c.dom.Node#getNodeName()
-      */
-    public String getNodeName() {
-        return element.getNodeName();
-    }
-
-    /* (non-Javadoc)
-      * @see org.w3c.dom.Node#getNodeType()
-      */
-    public short getNodeType() {
-        return Node.ELEMENT_NODE;
-    }
-
-    public ElementImpl getElement() {
-        return element;
+        target.setAttributeNS(namespaceURI, qualifiedName, value);
     }
 
     /**
@@ -713,7 +677,7 @@ public class SOAPElementImpl extends Nod
      */
     public SOAPElement getParentElement() {
         if (this.parentElement == null) {
-            javax.xml.soap.Node parentNode = toSAAJNode(element.getParentNode());
+            javax.xml.soap.Node parentNode = toSAAJNode(target.getParentNode());
             if (parentNode instanceof SOAPElement) {
                 this.parentElement = (SOAPElement) parentNode;
             }
@@ -723,15 +687,7 @@ public class SOAPElementImpl extends Nod
 
     public void setParentElement(SOAPElement parent) throws SOAPException {
         this.parentElement = parent;
-        this.element.setParent(((SOAPElementImpl)parent).element);
-    }
-
-    /**
-     * Find the Document that this Node belongs to (the document in whose context the Node was
-     * created). The Node may or may not
-     */
-    public Document getOwnerDocument() {
-        return element.getOwnerDocument();
+        ((OMElementEx)this.omTarget).setParent(((SOAPElementImpl<? extends OMElement>)parent).omTarget);
     }
 
     /**
@@ -743,46 +699,29 @@ public class SOAPElementImpl extends Nod
      *         <code>null</code> otherwise
      */
     public String getValue() {
-        if (element.getType() == OMNode.TEXT_NODE) {
-            return element.getText();
-        } else if (element.getType() == OMNode.ELEMENT_NODE) {
-            final OMNode firstOMChild = element.getFirstOMChild();
-            if (firstOMChild instanceof TextImpl) {
-                return ((TextImpl)firstOMChild).getData();
+        if (omTarget.getType() == OMNode.TEXT_NODE) {
+            return omTarget.getText();
+        } else if (omTarget.getType() == OMNode.ELEMENT_NODE) {
+            final OMNode firstOMChild = omTarget.getFirstOMChild();
+            if (firstOMChild instanceof Text) {
+                return ((Text)firstOMChild).getData();
             } else if (firstOMChild instanceof SOAPElementImpl) {
-                return ((SOAPElementImpl)firstOMChild).getValue();
+                return ((SOAPElement)firstOMChild).getValue();
             }
         }
         return null;
     }
 
-    public String getTextContent() throws DOMException {
-        return element.getTextContent();
-    }
-
     @Override
     protected Object clone() throws CloneNotSupportedException {
         // TODO Auto-generated method stub
         return super.clone();
     }
 
-    public org.w3c.dom.Node getFirstChild() {
-        return toSAAJNode(element.getFirstChild());
-    }
-
-    /**
-     * Method getLastChild
-     *
-     * @see org.w3c.dom.Node#getLastChild()
-     */
-    public org.w3c.dom.Node getLastChild() {
-        return toSAAJNode(element.getLastChild());
-    }
-
     public Node getParentNode() {
         Node parentNode = null;
         if (this.parentElement == null) {
-            parentNode = toSAAJNode(element.getParentNode());
+            parentNode = toSAAJNode(target.getParentNode());
             if (parentNode instanceof SOAPElement) {
                 this.parentElement = (SOAPElement) parentNode;
             }
@@ -794,27 +733,11 @@ public class SOAPElementImpl extends Nod
 
     /** dom Node method */
     public org.w3c.dom.Node getNextSibling() {
-        return toSAAJNode(element.getNextSibling());
+        return toSAAJNode(target.getNextSibling());
     }
 
     public Node getPreviousSibling() {
-        return toSAAJNode(element.getPreviousSibling());
-    }
-
-    private NodeList toSAAJNodeList(NodeList nodes) {
-        NodeListImpl result = new NodeListImpl();
-        for (int i = 0; i < nodes.getLength(); i++) {
-            result.addNode(toSAAJNode(nodes.item(i)));
-        }
-        return result;
-    }
-
-    public NodeList getChildNodes() {
-        return toSAAJNodeList(element.getChildNodes());
-    }
-
-    public boolean hasChildNodes() {
-        return element.hasChildNodes();
+        return toSAAJNode(target.getPreviousSibling());
     }
 
     /**
@@ -828,7 +751,7 @@ public class SOAPElementImpl extends Nod
      *                               child node or has a child node that is not a Text node
      */
     public void setValue(String value) {
-        OMNode firstChild = element.getFirstOMChild();
+        OMNode firstChild = omTarget.getFirstOMChild();
         if (firstChild == null) {
             try {
                 this.addTextNode(value);
@@ -850,79 +773,15 @@ public class SOAPElementImpl extends Nod
     }
 
     public OMNode detach() {
-        OMNode omNode = this.element.detach();
+        OMNode omNode = this.omTarget.detach();
         this.parentElement = null;
         return omNode;
     }
 
-    /**
-     * Returns the collection of attributes associated with this node, or null if none. At this
-     * writing, Element is the only type of node which will ever have attributes.
-     *
-     * @see org.apache.axiom.om.impl.dom.ElementImpl
-     */
-    public NamedNodeMap getAttributes() {
-        return element.getAttributes();
-    }
-    
     public String toString() {
-        return element.toString();
+        return target.toString();
     }
         
-    public Node removeChild(Node oldChild) throws DOMException {
-        if (oldChild instanceof SOAPElementImpl) {
-            oldChild = ((SOAPElementImpl)oldChild).getElement();
-        } else if (oldChild instanceof TextImplEx) {
-            oldChild = ((TextImplEx)oldChild).getTextNode();
-        }
-        return element.removeChild(oldChild);
-    }
-    
-    public Node appendChild(Node child) throws DOMException {        
-        if (getOwnerDocument() != child.getOwnerDocument()) {
-            throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, "Wrong document");
-        }
-        try {
-            if (child instanceof Text) {
-                return appendText((Text)child);
-            } else if (child instanceof ElementImpl) {
-                return appendElement((ElementImpl)child);
-            }
-        } catch (SOAPException e) {
-            DOMException ex = 
-                new DOMException(DOMException.HIERARCHY_REQUEST_ERR, e.getMessage());
-            ex.initCause(e);
-            throw ex;
-        }
-        
-        return super.appendChild(child);        
-    }
-    
-    protected Text appendText(Text child) throws SOAPException {
-        String text = child.getData();
-        Text textNode = getOwnerDocument().createTextNode(text);
-        NodeImpl node = ((NodeImpl)element.appendChild(textNode));
-        TextImplEx saajTextNode = new TextImplEx(text, this);
-        node.setUserData(SAAJ_NODE, saajTextNode, null);
-        return saajTextNode;
-    }
-    
-    protected Element appendElement(ElementImpl child) throws SOAPException {
-        String namespaceURI = child.getNamespaceURI();
-        String prefix = child.getPrefix();
-
-        SOAPElementImpl childEle = new SOAPElementImpl(child);
-        
-        childEle.element.setUserData(SAAJ_NODE, childEle, null);
-        if (namespaceURI != null && namespaceURI.trim().length() > 0) {
-            childEle.element.setNamespace(childEle.element.declareNamespace(namespaceURI, prefix));
-        }
-        element.appendChild(childEle.element);
-        ((NodeImpl)childEle.element.getParentNode()).setUserData(SAAJ_NODE, this, null);
-        childEle.setParentElement(this);
-        return childEle;
-    }
-    
     protected void copyContents(SOAPElementImpl childEle, Node child) throws SOAPException {
         NamedNodeMap attributes = child.getAttributes();
         for (int i = 0; i < attributes.getLength(); i++) {

Modified: axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPEnvelopeImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPEnvelopeImpl.java?rev=1377526&r1=1377525&r2=1377526&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPEnvelopeImpl.java (original)
+++ axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPEnvelopeImpl.java Sun Aug 26 21:42:35 2012
@@ -20,15 +20,11 @@
 package org.apache.axis2.saaj;
 
 import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.impl.dom.ChildNode;
-import org.apache.axiom.om.impl.dom.NodeImpl;
-import org.apache.axiom.om.impl.dom.TextImpl;
+import org.apache.axiom.soap.SOAP11Version;
+import org.apache.axiom.soap.SOAP12Version;
+import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.soap.SOAPFactory;
-import org.apache.axiom.soap.impl.dom.soap11.SOAP11BodyImpl;
-import org.apache.axiom.soap.impl.dom.soap11.SOAP11Factory;
-import org.apache.axiom.soap.impl.dom.soap11.SOAP11HeaderImpl;
-import org.apache.axiom.soap.impl.dom.soap12.SOAP12Factory;
-import org.apache.axiom.soap.impl.dom.soap12.SOAP12HeaderImpl;
+import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
 import javax.xml.soap.Name;
@@ -40,18 +36,12 @@ import javax.xml.soap.SOAPHeader;
 /**
  *
  */
-public class SOAPEnvelopeImpl extends SOAPElementImpl implements javax.xml.soap.SOAPEnvelope {
+public class SOAPEnvelopeImpl extends SOAPElementImpl<SOAPEnvelope> implements javax.xml.soap.SOAPEnvelope {
 
-    private org.apache.axiom.soap.impl.dom.SOAPEnvelopeImpl omSOAPEnvelope;
     private SOAPPartImpl soapPart;
 
-    public SOAPEnvelopeImpl(final org.apache.axiom.soap.impl.dom.SOAPEnvelopeImpl envelope) {
+    public SOAPEnvelopeImpl(SOAPEnvelope envelope) {
         super(envelope);
-        omSOAPEnvelope = envelope;
-    }
-
-    public org.apache.axiom.soap.SOAPEnvelope getOMEnvelope() {
-        return omSOAPEnvelope;
     }
 
     /**
@@ -105,7 +95,7 @@ public class SOAPEnvelopeImpl extends SO
      *                                      object
      */
     public SOAPHeader getHeader() throws SOAPException {
-        return (SOAPHeader)toSAAJNode((org.w3c.dom.Node)omSOAPEnvelope.getHeader());
+        return (SOAPHeader)toSAAJNode((org.w3c.dom.Node)omTarget.getHeader());
     }
 
     /**
@@ -123,7 +113,7 @@ public class SOAPEnvelopeImpl extends SO
      *                                      object
      */
     public SOAPBody getBody() throws SOAPException {
-        return (SOAPBody)toSAAJNode((org.w3c.dom.Node)omSOAPEnvelope.getBody());
+        return (SOAPBody)toSAAJNode((org.w3c.dom.Node)omTarget.getBody());
     }
 
     /**
@@ -138,21 +128,13 @@ public class SOAPEnvelopeImpl extends SO
      *                                      contains a valid <CODE>SOAPHeader</CODE> object
      */
     public SOAPHeader addHeader() throws SOAPException {
-        org.apache.axiom.soap.SOAPHeader header = omSOAPEnvelope.getHeader();
+        org.apache.axiom.soap.SOAPHeader header = omTarget.getHeader();
         if (header == null) {
             SOAPHeaderImpl saajSOAPHeader;
-            if (this.element.getOMFactory() instanceof SOAP11Factory) {
-                header = new SOAP11HeaderImpl(omSOAPEnvelope,
-                                              (SOAPFactory)this.element.getOMFactory());
-                saajSOAPHeader = new SOAPHeaderImpl(header);
-                saajSOAPHeader.setParentElement(this);
-            } else {
-                header = new SOAP12HeaderImpl(omSOAPEnvelope,
-                                              (SOAPFactory)this.element.getOMFactory());
-                saajSOAPHeader = new SOAPHeaderImpl(header);
-                saajSOAPHeader.setParentElement(this);
-            }
-            ((NodeImpl)omSOAPEnvelope.getHeader()).setUserData(SAAJ_NODE, saajSOAPHeader, null);
+            header = ((SOAPFactory)this.omTarget.getOMFactory()).createSOAPHeader(omTarget);
+            saajSOAPHeader = new SOAPHeaderImpl(header);
+            saajSOAPHeader.setParentElement(this);
+            ((Element)omTarget.getHeader()).setUserData(SAAJ_NODE, saajSOAPHeader, null);
             return saajSOAPHeader;
         } else {
             throw new SOAPException("Header already present, can't set header again without " +
@@ -173,12 +155,12 @@ public class SOAPEnvelopeImpl extends SO
      *                                      contains a valid <CODE>SOAPBody</CODE> object
      */
     public SOAPBody addBody() throws SOAPException {
-        org.apache.axiom.soap.SOAPBody body = omSOAPEnvelope.getBody();
+        org.apache.axiom.soap.SOAPBody body = omTarget.getBody();
         if (body == null) {
-            body = new SOAP11BodyImpl(omSOAPEnvelope, (SOAPFactory)this.element.getOMFactory());
+            body = ((SOAPFactory)this.omTarget.getOMFactory()).createSOAPBody(omTarget);
             SOAPBodyImpl saajSOAPBody = new SOAPBodyImpl(body);
             saajSOAPBody.setParentElement(this);
-            ((NodeImpl)omSOAPEnvelope.getBody()).setUserData(SAAJ_NODE, saajSOAPBody, null);
+            ((Element)omTarget.getBody()).setUserData(SAAJ_NODE, saajSOAPBody, null);
             return saajSOAPBody;
         } else {
             throw new SOAPException("Body already present, can't set body again without " +
@@ -187,16 +169,12 @@ public class SOAPEnvelopeImpl extends SO
     }
 
     public SOAPElement addTextNode(String text) throws SOAPException {
-        Node firstChild = element.getFirstChild();
+        Node firstChild = target.getFirstChild();
         if (firstChild instanceof org.w3c.dom.Text) {
             ((org.w3c.dom.Text)firstChild).setData(text);
         } else {
             // Else this is a header
-            TextImpl doomText = new TextImpl(text, this.element.getOMFactory());
-            doomText.setNextOMSibling((OMNode)firstChild);
-            doomText.setPreviousOMSibling(null);
-            element.setFirstChild(doomText);
-            ((ChildNode)firstChild).setPreviousOMSibling(doomText);
+            ((OMNode)firstChild).insertSiblingBefore(this.omTarget.getOMFactory().createOMText(text));
         }
         return this;
     }
@@ -206,7 +184,7 @@ public class SOAPEnvelopeImpl extends SO
      * on Envelop
      */
     public SOAPElement addAttribute(Name name, String value) throws SOAPException {
-        if (this.element.getOMFactory() instanceof SOAP12Factory) {
+        if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP12Version.getSingleton()) {
             if ("encodingStyle".equals(name.getLocalName())) {
                 throw new SOAPException(
                         "SOAP1.2 does not allow encodingStyle attribute to be set " +
@@ -221,9 +199,9 @@ public class SOAPEnvelopeImpl extends SO
      * element
      */
     public SOAPElement addChildElement(Name name) throws SOAPException {
-        if (this.element.getOMFactory() instanceof SOAP12Factory) {
+        if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP12Version.getSingleton()) {
             throw new SOAPException("Cannot add elements after body element");
-        } else if (this.element.getOMFactory() instanceof SOAP11Factory) {
+        } else if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton()) {
             //Let elements to be added any where.
             return super.addChildElement(name);
         }

Modified: axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPFactoryImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPFactoryImpl.java?rev=1377526&r1=1377525&r2=1377526&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPFactoryImpl.java (original)
+++ axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPFactoryImpl.java Sun Aug 26 21:42:35 2012
@@ -19,11 +19,11 @@
 
 package org.apache.axis2.saaj;
 
+import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.impl.dom.DOOMAbstractFactory;
-import org.apache.axiom.om.impl.dom.ElementImpl;
-import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
+import org.apache.axiom.om.dom.DOMMetaFactory;
 import org.w3c.dom.Element;
 
 import javax.xml.namespace.QName;
@@ -40,6 +40,7 @@ import java.util.Locale;
  * 
  */
 public class SOAPFactoryImpl extends SOAPFactory {
+    private final DOMMetaFactory metaFactory = (DOMMetaFactory)OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM);
 
     protected String soapVersion = SOAPConstants.SOAP_1_1_PROTOCOL;
 
@@ -58,14 +59,14 @@ public class SOAPFactoryImpl extends SOA
         String uri = name.getURI();
         OMElement omElement = null;
         if (soapVersion.equals(SOAPConstants.SOAP_1_2_PROTOCOL)) {
-            omElement = DOOMAbstractFactory.getSOAP12Factory().createOMElement(localName
+            omElement = metaFactory.getSOAP12Factory().createOMElement(localName
                     , uri, prefix);
         } else {
-            omElement = DOOMAbstractFactory.getSOAP11Factory().createOMElement(localName
+            omElement = metaFactory.getSOAP11Factory().createOMElement(localName
                     , uri, prefix);
         }
-        DOOMAbstractFactory.getOMFactory().createOMElement(localName, uri, prefix);
-        return new SOAPElementImpl((ElementImpl)omElement);
+        metaFactory.getOMFactory().createOMElement(localName, uri, prefix);
+        return new SOAPElementImpl<OMElement>(omElement);
     }
 
     /**
@@ -77,14 +78,14 @@ public class SOAPFactoryImpl extends SOA
      *                                      object
      */
     public SOAPElement createElement(String localName) throws SOAPException {
-        OMDOMFactory omdomFactory = null;
+        OMFactory omFactory = null;
         if (soapVersion.equals(SOAPConstants.SOAP_1_2_PROTOCOL)) {
-            omdomFactory = (OMDOMFactory)DOOMAbstractFactory.getSOAP12Factory();
+            omFactory = metaFactory.getSOAP12Factory();
         } else {
-            omdomFactory = (OMDOMFactory)DOOMAbstractFactory.getSOAP11Factory();
+            omFactory = metaFactory.getSOAP11Factory();
         }
-        OMElement omElement = omdomFactory.createOMElement(new QName(localName));
-        return new SOAPElementImpl((ElementImpl)omElement);
+        OMElement omElement = omFactory.createOMElement(new QName(localName));
+        return new SOAPElementImpl<OMElement>(omElement);
     }
 
     /**
@@ -102,13 +103,13 @@ public class SOAPFactoryImpl extends SOA
             throws SOAPException {
         OMElement omElement = null;
         if (soapVersion.equals(SOAPConstants.SOAP_1_2_PROTOCOL)) {
-            omElement = DOOMAbstractFactory.getSOAP12Factory().createOMElement(localName
+            omElement = metaFactory.getSOAP12Factory().createOMElement(localName
                     , uri, prefix);
         } else {
-            omElement = DOOMAbstractFactory.getSOAP11Factory().createOMElement(localName
+            omElement = metaFactory.getSOAP11Factory().createOMElement(localName
                     , uri, prefix);
         }
-        return new SOAPElementImpl((ElementImpl)omElement);
+        return new SOAPElementImpl<OMElement>(omElement);
     }
 
     /**
@@ -123,9 +124,9 @@ public class SOAPFactoryImpl extends SOA
      */
     public Detail createDetail() throws SOAPException {
         if (soapVersion.equals(SOAPConstants.SOAP_1_2_PROTOCOL)) {
-            return new DetailImpl(DOOMAbstractFactory.getSOAP12Factory().createSOAPFaultDetail());
+            return new DetailImpl(metaFactory.getSOAP12Factory().createSOAPFaultDetail());
         } else {
-            return new DetailImpl(DOOMAbstractFactory.getSOAP11Factory().createSOAPFaultDetail());
+            return new DetailImpl(metaFactory.getSOAP11Factory().createSOAPFaultDetail());
         }
     }
 
@@ -170,10 +171,10 @@ public class SOAPFactoryImpl extends SOA
     public SOAPFault createFault() throws SOAPException {
         org.apache.axiom.soap.SOAPFactory soapFactory;
         if (soapVersion.equals(SOAPConstants.SOAP_1_2_PROTOCOL)) {
-            soapFactory = DOOMAbstractFactory.getSOAP12Factory();
+            soapFactory = metaFactory.getSOAP12Factory();
             return new SOAPFaultImpl(soapFactory.createSOAPFault());
         } else {
-            soapFactory = DOOMAbstractFactory.getSOAP11Factory();
+            soapFactory = metaFactory.getSOAP11Factory();
             return new SOAPFaultImpl(soapFactory.createSOAPFault());
         }
     }
@@ -189,10 +190,10 @@ public class SOAPFactoryImpl extends SOA
     public SOAPFault createFault(String reasonText, QName faultCode) throws SOAPException {
         SOAPFault soapFault;
         if (soapVersion.equals(SOAPConstants.SOAP_1_2_PROTOCOL)) {
-            soapFault = new SOAPFaultImpl(DOOMAbstractFactory.getSOAP12Factory()
+            soapFault = new SOAPFaultImpl(metaFactory.getSOAP12Factory()
                     .createSOAPFault());
         } else {
-            soapFault = new SOAPFaultImpl(DOOMAbstractFactory.getSOAP11Factory()
+            soapFault = new SOAPFaultImpl(metaFactory.getSOAP11Factory()
                     .createSOAPFault());
         }
         soapFault.setFaultCode(faultCode);
@@ -214,25 +215,25 @@ public class SOAPFactoryImpl extends SOA
         String localName = qname.getLocalPart();
         String prefix = qname.getPrefix();
         String uri = qname.getNamespaceURI();
-        OMElement omElement = DOOMAbstractFactory.getOMFactory().createOMElement(localName
+        OMElement omElement = metaFactory.getOMFactory().createOMElement(localName
                 , uri, prefix);
-        return new SOAPElementImpl((ElementImpl)omElement);
+        return new SOAPElementImpl<OMElement>(omElement);
     }
 
     public SOAPElement createElement(Element element) throws SOAPException {
-        OMDOMFactory omdomFactory = null;
+        OMFactory omFactory = null;
         if (soapVersion.equals(SOAPConstants.SOAP_1_2_PROTOCOL)) {
-            omdomFactory = (OMDOMFactory)DOOMAbstractFactory.getSOAP12Factory();
+            omFactory = metaFactory.getSOAP12Factory();
         } else {
-            omdomFactory = (OMDOMFactory)DOOMAbstractFactory.getSOAP11Factory();
+            omFactory = metaFactory.getSOAP11Factory();
         }
         String prefix = element.getPrefix();
         if (prefix == null) {
             prefix = "";
         }
-        OMNamespace ns = omdomFactory.createOMNamespace(element.getNamespaceURI(), prefix);
-        OMElement omElement = omdomFactory.createOMElement(element.getLocalName(), ns);
-        return new SOAPElementImpl((ElementImpl)omElement);
+        OMNamespace ns = omFactory.createOMNamespace(element.getNamespaceURI(), prefix);
+        OMElement omElement = omFactory.createOMElement(element.getLocalName(), ns);
+        return new SOAPElementImpl<OMElement>(omElement);
     }
 
 }

Modified: axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultElementImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultElementImpl.java?rev=1377526&r1=1377525&r2=1377526&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultElementImpl.java (original)
+++ axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultElementImpl.java Sun Aug 26 21:42:35 2012
@@ -19,15 +19,15 @@
 
 package org.apache.axis2.saaj;
 
-import org.apache.axiom.om.impl.dom.ElementImpl;
+import org.apache.axiom.om.OMElement;
 
 import javax.xml.soap.SOAPFaultElement;
 
-public class SOAPFaultElementImpl extends SOAPElementImpl implements
+public class SOAPFaultElementImpl<T extends OMElement> extends SOAPElementImpl<T> implements
         SOAPFaultElement {
 
     /** @param element  */
-    public SOAPFaultElementImpl(ElementImpl element) {
+    public SOAPFaultElementImpl(T element) {
         super(element);
     }
 

Modified: axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultImpl.java?rev=1377526&r1=1377525&r2=1377526&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultImpl.java (original)
+++ axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultImpl.java Sun Aug 26 21:42:35 2012
@@ -19,13 +19,13 @@
 
 package org.apache.axis2.saaj;
 
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.impl.OMNamespaceImpl;
-import org.apache.axiom.om.impl.dom.DOOMAbstractFactory;
-import org.apache.axiom.om.impl.dom.ElementImpl;
-import org.apache.axiom.om.impl.dom.NodeImpl;
 import org.apache.axiom.soap.SOAP11Constants;
+import org.apache.axiom.soap.SOAP11Version;
 import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axiom.soap.SOAP12Version;
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.SOAPFaultCode;
 import org.apache.axiom.soap.SOAPFaultDetail;
@@ -35,15 +35,7 @@ import org.apache.axiom.soap.SOAPFaultRo
 import org.apache.axiom.soap.SOAPFaultSubCode;
 import org.apache.axiom.soap.SOAPFaultText;
 import org.apache.axiom.soap.SOAPFaultValue;
-import org.apache.axiom.soap.impl.dom.SOAPFaultValueImpl;
-import org.apache.axiom.soap.impl.dom.soap11.SOAP11Factory;
-import org.apache.axiom.soap.impl.dom.soap11.SOAP11FaultDetailImpl;
-import org.apache.axiom.soap.impl.dom.soap11.SOAP11FaultReasonImpl;
-import org.apache.axiom.soap.impl.dom.soap11.SOAP11FaultRoleImpl;
-import org.apache.axiom.soap.impl.dom.soap12.SOAP12Factory;
-import org.apache.axiom.soap.impl.dom.soap12.SOAP12FaultDetailImpl;
-import org.apache.axiom.soap.impl.dom.soap12.SOAP12FaultRoleImpl;
-import org.apache.axiom.soap.impl.dom.soap12.SOAP12FaultValueImpl;
+import org.w3c.dom.Element;
 
 import javax.xml.namespace.QName;
 import javax.xml.soap.Detail;
@@ -59,21 +51,19 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
 
-public class SOAPFaultImpl extends SOAPBodyElementImpl implements SOAPFault {
+public class SOAPFaultImpl extends SOAPBodyElementImpl<org.apache.axiom.soap.SOAPFault> implements SOAPFault {
 
-    protected org.apache.axiom.soap.SOAPFault fault;
     private boolean isDetailAdded;
     private Locale faultReasonLocale;
     private boolean defaultsSet;
 
     /** @param fault  */
     public SOAPFaultImpl(org.apache.axiom.soap.SOAPFault fault) {
-        super((ElementImpl)fault);
-        this.fault = fault;
+        super(fault);
     }
 
     void setDefaults() throws SOAPException {
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
+        if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton()) {
             setFaultCode(SOAP11Constants.QNAME_SENDER_FAULTCODE);
         } else {
             setFaultCode(SOAP12Constants.QNAME_SENDER_FAULTCODE);
@@ -84,7 +74,7 @@ public class SOAPFaultImpl extends SOAPB
     
     void removeDefaults() {
         if (defaultsSet) {
-            SOAPFaultReason reason = this.fault.getReason();
+            SOAPFaultReason reason = this.omTarget.getReason();
             if (reason != null) {
                 reason.detach();
             }
@@ -121,19 +111,19 @@ public class SOAPFaultImpl extends SOAPB
 //        		localName = faultCode.substring(faultCode.indexOf(":")+1);
 //        	}
 
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
-            soapFactory = (SOAP11Factory)this.element.getOMFactory();
-            soapFaultCode = soapFactory.createSOAPFaultCode(fault);
+        if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton()) {
+            soapFactory = (SOAPFactory)this.omTarget.getOMFactory();
+            soapFaultCode = soapFactory.createSOAPFaultCode(omTarget);
             soapFaultCode.setText(faultCode);
-        } else if (this.element.getOMFactory() instanceof SOAP12Factory) {
-            soapFactory = (SOAP12Factory)this.element.getOMFactory();
-            soapFaultCode = soapFactory.createSOAPFaultCode(fault);
+        } else if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP12Version.getSingleton()) {
+            soapFactory = (SOAPFactory)this.omTarget.getOMFactory();
+            soapFaultCode = soapFactory.createSOAPFaultCode(omTarget);
             SOAPFaultValue soapFaultValue = soapFactory.createSOAPFaultValue(soapFaultCode);
             soapFaultCode.setValue(soapFaultValue);
             soapFaultValue.setText(faultCode);
         }
 
-        this.fault.setCode(soapFaultCode);
+        this.omTarget.setCode(soapFaultCode);
     }
 
     /**
@@ -143,11 +133,11 @@ public class SOAPFaultImpl extends SOAPB
      * @see #setFaultCode(String) setFaultCode(java.lang.String)
      */
     public String getFaultCode() {
-        if (fault != null && fault.getCode() != null) {
-            if (this.element.getOMFactory() instanceof SOAP11Factory) {
-                return fault.getCode().getText();
-            } else if (this.element.getOMFactory() instanceof SOAP12Factory) {
-                return fault.getCode().getValue().getText();
+        if (omTarget != null && omTarget.getCode() != null) {
+            if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton()) {
+                return omTarget.getCode().getText();
+            } else if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP12Version.getSingleton()) {
+                return omTarget.getCode().getValue().getText();
             } else {
                 return null;
             }
@@ -167,29 +157,15 @@ public class SOAPFaultImpl extends SOAPB
      *                       tree.
      */
     public void setFaultActor(String faultActor) throws SOAPException {
+        if (this.omTarget.getRole() == null) {
+            SOAPFaultRole faultRoleImpl = ((SOAPFactory)this.omTarget.getOMFactory()).createSOAPFaultRole(
+                    this.omTarget);
 
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
-            if (this.fault.getRole() == null) {
-                SOAP11FaultRoleImpl faultRoleImpl = new SOAP11FaultRoleImpl(
-                        this.fault, (SOAPFactory)this.element.getOMFactory());
-
-                faultRoleImpl.setRoleValue(faultActor);
-                this.fault.setRole(faultRoleImpl);
-            } else {
-                SOAPFaultRole role = this.fault.getRole();
-                role.setRoleValue(faultActor);
-            }
-        } else if (this.element.getOMFactory() instanceof SOAP12Factory) {
-            if (this.fault.getRole() == null) {
-                SOAP12FaultRoleImpl faultRoleImpl = new SOAP12FaultRoleImpl(
-                        this.fault, (SOAPFactory)this.element.getOMFactory());
-
-                faultRoleImpl.setRoleValue(faultActor);
-                this.fault.setRole(faultRoleImpl);
-            } else {
-                SOAPFaultRole role = this.fault.getRole();
-                role.setRoleValue(faultActor);
-            }
+            faultRoleImpl.setRoleValue(faultActor);
+            this.omTarget.setRole(faultRoleImpl);
+        } else {
+            SOAPFaultRole role = this.omTarget.getRole();
+            role.setRoleValue(faultActor);
         }
     }
 
@@ -197,8 +173,8 @@ public class SOAPFaultImpl extends SOAPB
       * @see javax.xml.soap.SOAPFault#getFaultActor()
       */
     public String getFaultActor() {
-        if (this.fault.getRole() != null) {
-            return this.fault.getRole().getRoleValue();
+        if (this.omTarget.getRole() != null) {
+            return this.omTarget.getRole().getRoleValue();
         }
         return null;
     }
@@ -212,9 +188,9 @@ public class SOAPFaultImpl extends SOAPB
      * @see #getFaultString() getFaultString()
      */
     public void setFaultString(String faultString) throws SOAPException {
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
+        if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton()) {
             setFaultString(faultString, null);
-        } else if (this.element.getOMFactory() instanceof SOAP12Factory) {
+        } else if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP12Version.getSingleton()) {
             setFaultString(faultString, Locale.getDefault());
         }
     }
@@ -224,13 +200,13 @@ public class SOAPFaultImpl extends SOAPB
       */
     public String getFaultString() {
 
-        if (this.fault.getNamespace().getNamespaceURI().equals(
+        if (this.omTarget.getNamespace().getNamespaceURI().equals(
                 SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
-            return this.fault.getReason().getText();
+            return this.omTarget.getReason().getText();
         } else {
-            if (this.fault.getReason() != null && this.fault.getReason().getFirstSOAPText() != null)
+            if (this.omTarget.getReason() != null && this.omTarget.getReason().getFirstSOAPText() != null)
             {
-                return this.fault.getReason().getFirstSOAPText().getText();
+                return this.omTarget.getReason().getFirstSOAPText().getText();
             }
         }
         return null;
@@ -240,7 +216,7 @@ public class SOAPFaultImpl extends SOAPB
       * @see javax.xml.soap.SOAPFault#getDetail()
       */
     public Detail getDetail() {
-        return (Detail)toSAAJNode((org.w3c.dom.Node)fault.getDetail());
+        return (Detail)toSAAJNode((org.w3c.dom.Node)omTarget.getDetail());
     }
 
 
@@ -282,16 +258,10 @@ public class SOAPFaultImpl extends SOAPB
         }
 
         SOAPFaultDetail omDetail;
-        SOAPFactory factory = (SOAPFactory)this.element.getOMFactory();
-        if (factory instanceof SOAP11Factory) {
-            omDetail = new SOAP11FaultDetailImpl(this.fault,
-                                                 factory);
-        } else {
-            omDetail = new SOAP12FaultDetailImpl(this.fault,
-                                                 factory);
-        }
+        SOAPFactory factory = (SOAPFactory)this.omTarget.getOMFactory();
+        omDetail = factory.createSOAPFaultDetail(this.omTarget);
         Detail saajDetail = new DetailImpl(omDetail);
-        ((NodeImpl)fault.getDetail()).setUserData(SAAJ_NODE, saajDetail, null);
+        ((Element)omTarget.getDetail()).setUserData(SAAJ_NODE, saajDetail, null);
         isDetailAdded = true;
         return saajDetail;
     }
@@ -316,20 +286,19 @@ public class SOAPFaultImpl extends SOAPB
      */
 
     public void setFaultString(String faultString, Locale locale) throws SOAPException {
-        if (this.fault.getReason() != null) {
-            SOAPFaultReason reason = this.fault.getReason();
-            if (this.element.getOMFactory() instanceof SOAP11Factory) {
+        if (this.omTarget.getReason() != null) {
+            SOAPFaultReason reason = this.omTarget.getReason();
+            if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton()) {
                 reason.setText(faultString);
-            } else if (this.element.getOMFactory() instanceof SOAP12Factory) {
+            } else if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP12Version.getSingleton()) {
                 addFaultReasonText(faultString, locale);
             }
         } else {
-            if (this.element.getOMFactory() instanceof SOAP11Factory) {
-                SOAPFaultReason reason = new SOAP11FaultReasonImpl(this.fault,
-                                                                   (SOAPFactory)this.element
-                                                                           .getOMFactory());
+            if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton()) {
+                SOAPFaultReason reason = ((SOAPFactory)this.omTarget
+                        .getOMFactory()).createSOAPFaultReason(this.omTarget);
                 reason.setText(faultString);
-            } else if (this.element.getOMFactory() instanceof SOAP12Factory) {
+            } else if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP12Version.getSingleton()) {
                 addFaultReasonText(faultString, locale);
             }
         }
@@ -349,9 +318,9 @@ public class SOAPFaultImpl extends SOAPB
      * @since SAAJ 1.2
      */
     public Locale getFaultStringLocale() {
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
+        if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton()) {
             return this.faultReasonLocale;
-        } else if (this.element.getOMFactory() instanceof SOAP12Factory) {
+        } else if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP12Version.getSingleton()) {
             Locale locale = null;
             try {
                 if (getFaultReasonLocales().hasNext()) {
@@ -384,26 +353,26 @@ public class SOAPFaultImpl extends SOAPB
         if (locale == null) {
             throw new SOAPException("Received null for locale");
         }
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
+        if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton()) {
             throw new UnsupportedOperationException("Not supported in SOAP 1.1");
-        } else if (this.element.getOMFactory() instanceof SOAP12Factory) {
+        } else if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP12Version.getSingleton()) {
             removeDefaults();
             
             String existingReasonText = getFaultReasonText(locale);
             if (existingReasonText == null) {
                 org.apache.axiom.soap.SOAPFactory soapFactory = null;
-                soapFactory = (SOAP12Factory)this.element.getOMFactory();
-                if (this.fault.getReason() == null) {
-                    SOAPFaultReason soapFaultReason = soapFactory.createSOAPFaultReason(this.fault);
-                    this.fault.setReason(soapFaultReason);
+                soapFactory = (SOAPFactory)this.omTarget.getOMFactory();
+                if (this.omTarget.getReason() == null) {
+                    SOAPFaultReason soapFaultReason = soapFactory.createSOAPFaultReason(this.omTarget);
+                    this.omTarget.setReason(soapFaultReason);
                 }
                 SOAPFaultText soapFaultText =
-                        soapFactory.createSOAPFaultText(this.fault.getReason());
+                        soapFactory.createSOAPFaultText(this.omTarget.getReason());
                 soapFaultText.setText(text);
                 soapFaultText.setLang(locale.toString());
             } else {
                 //update the text
-                Iterator soapTextsItr = this.fault.getReason().getAllSoapTexts().iterator();
+                Iterator soapTextsItr = this.omTarget.getReason().getAllSoapTexts().iterator();
                 while (soapTextsItr.hasNext()) {
                     SOAPFaultText soapFaultText = (SOAPFaultText)soapTextsItr.next();
                     if (soapFaultText.getLang().equals(locale.toString())) {
@@ -430,36 +399,34 @@ public class SOAPFaultImpl extends SOAPB
      */
 
     public void appendFaultSubcode(QName subcode) throws SOAPException {
-        org.apache.axiom.soap.SOAPFactory soapFactory = null;
+        SOAPFactory soapFactory = (SOAPFactory)this.omTarget.getOMFactory();
         SOAPFaultSubCode soapFaultSubCode = null;
 
         if (subcode.getNamespaceURI() == null || subcode.getNamespaceURI().trim().length() == 0) {
             throw new SOAPException("Unqualified QName object : " + subcode);
         }
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
+        if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton()) {
             throw new UnsupportedOperationException();
-        } else if (this.element.getOMFactory() instanceof SOAP12Factory) {
-            soapFactory = DOOMAbstractFactory.getSOAP12Factory();
         }
 
-        if (this.fault.getCode() == null) {
-            soapFactory.createSOAPFaultCode(this.fault);
+        if (this.omTarget.getCode() == null) {
+            soapFactory.createSOAPFaultCode(this.omTarget);
             //if SOAPFault is null, there cannot be a subcode.
             //Hence should create one
-            soapFaultSubCode = soapFactory.createSOAPFaultSubCode(this.fault.getCode());
-        } else if (this.fault.getCode().getSubCode() != null) {
+            soapFaultSubCode = soapFactory.createSOAPFaultSubCode(this.omTarget.getCode());
+        } else if (this.omTarget.getCode().getSubCode() != null) {
             //find the last subcode.parent of the new subcode should be the this last subcode
             soapFaultSubCode = soapFactory.createSOAPFaultSubCode(
-                    getLastSubCode(this.fault.getCode().getSubCode()));
+                    getLastSubCode(this.omTarget.getCode().getSubCode()));
         } else {
             //FaultCode is there, but no FaultSubCode
-            soapFaultSubCode = soapFactory.createSOAPFaultSubCode(this.fault.getCode());
+            soapFaultSubCode = soapFactory.createSOAPFaultSubCode(this.omTarget.getCode());
         }
 
 
         if (soapFaultSubCode != null) {
-            SOAPFaultValueImpl soapFaultValueimpl =
-                    new SOAP12FaultValueImpl(soapFaultSubCode, soapFactory);
+            SOAPFaultValue soapFaultValueimpl =
+                    soapFactory.createSOAPFaultValue(soapFaultSubCode);
             soapFaultValueimpl.setText(subcode.getPrefix() + ":" + subcode.getLocalPart());
             soapFaultValueimpl.declareNamespace(subcode.getNamespaceURI(), subcode.getPrefix());
         }
@@ -478,9 +445,9 @@ public class SOAPFaultImpl extends SOAPB
      * <p/>
      */
     public QName getFaultCodeAsQName() {
-        SOAPFaultCode soapFaultCode = this.fault.getCode();
+        SOAPFaultCode soapFaultCode = this.omTarget.getCode();
         if (soapFaultCode != null) {
-            if (this.element.getOMFactory() instanceof SOAP11Factory) {
+            if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton()) {
                 return soapFaultCode.getTextAsQName();
             } else {
                 return soapFaultCode.getValue().getTextAsQName();
@@ -498,12 +465,12 @@ public class SOAPFaultImpl extends SOAPB
      *          - if this message does not support the SOAP 1.2 concept of Fault Node.
      */
     public String getFaultNode() {
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
+        if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton()) {
             throw new UnsupportedOperationException("Message does not support the " +
                     "SOAP 1.2 concept of Fault Node");
         } else {
-            if (fault != null && fault.getNode() != null && fault.getNode().getText() != null) {
-                return fault.getNode().getText();
+            if (omTarget != null && omTarget.getNode() != null && omTarget.getNode().getText() != null) {
+                return omTarget.getNode().getText();
             }
         }
         return null;
@@ -523,12 +490,12 @@ public class SOAPFaultImpl extends SOAPB
      * @since SAAJ 1.3
      */
     public Iterator getFaultReasonLocales() throws SOAPException {
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
+        if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton()) {
             throw new UnsupportedOperationException("Message does not support the " +
                     "SOAP 1.2 concept of Fault Reason");
         } else {
             ArrayList faultReasonLocales = new ArrayList();
-            List soapTextList = this.fault.getReason().getAllSoapTexts();
+            List soapTextList = this.omTarget.getReason().getAllSoapTexts();
             if (soapTextList != null) {
                 Iterator faultReasons = soapTextList.iterator();
                 while (faultReasons.hasNext()) {
@@ -563,12 +530,12 @@ public class SOAPFaultImpl extends SOAPB
      * @since SAAJ 1.3
      */
     public String getFaultReasonText(Locale locale) throws SOAPException {
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
+        if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton()) {
             throw new UnsupportedOperationException("Message does not support the " +
                     "SOAP 1.2 concept of Fault Reason");
         } else {
             Iterator soapTextsItr = null;
-            SOAPFaultReason soapFaultReason = this.fault.getReason();
+            SOAPFaultReason soapFaultReason = this.omTarget.getReason();
             if (soapFaultReason != null) {
                 List soapTexts = soapFaultReason.getAllSoapTexts();
                 if (soapTexts != null) {
@@ -595,11 +562,11 @@ public class SOAPFaultImpl extends SOAPB
      */
 
     public Iterator getFaultReasonTexts() throws SOAPException {
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
+        if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton()) {
             throw new UnsupportedOperationException();
         }
 
-        Iterator soapTextsItr = this.fault.getReason().getAllSoapTexts().iterator();
+        Iterator soapTextsItr = this.omTarget.getReason().getAllSoapTexts().iterator();
         ArrayList reasonTexts = new ArrayList();
         while (soapTextsItr.hasNext()) {
             SOAPFaultText soapFaultText = (SOAPFaultText)soapTextsItr.next();
@@ -618,12 +585,12 @@ public class SOAPFaultImpl extends SOAPB
      * @since SAAJ 1.3
      */
     public String getFaultRole() {
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
+        if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton()) {
             throw new UnsupportedOperationException("Message does not support the " +
                     "SOAP 1.2 concept of Fault Reason");
         } else {
-            if (this.fault.getRole() != null) {
-                return this.fault.getRole().getText();
+            if (this.omTarget.getRole() != null) {
+                return this.omTarget.getRole().getText();
             } else {
                 return null;
             }
@@ -640,11 +607,11 @@ public class SOAPFaultImpl extends SOAPB
      *          - if this message does not support the SOAP 1.2 concept of Subcode.
      */
     public Iterator getFaultSubcodes() {
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
+        if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton()) {
             throw new UnsupportedOperationException();
         }
         ArrayList faultSubcodes = new ArrayList();
-        SOAPFaultSubCode subCodeElement = this.fault.getCode().getSubCode();
+        SOAPFaultSubCode subCodeElement = this.omTarget.getCode().getSubCode();
         while (subCodeElement != null) {
             QName qname = subCodeElement.getValue().getTextAsQName();
             faultSubcodes.add(qname);
@@ -655,7 +622,7 @@ public class SOAPFaultImpl extends SOAPB
 
     /** Returns true if this SOAPFault has a Detail subelement and false otherwise. */
     public boolean hasDetail() {
-        if (this.fault.getDetail() != null) {
+        if (this.omTarget.getDetail() != null) {
             return true;
         } else {
             return false;
@@ -671,10 +638,10 @@ public class SOAPFaultImpl extends SOAPB
      *          - if this message does not support the SOAP 1.2 concept of Subcode.
      */
     public void removeAllFaultSubcodes() {
-        if (factory instanceof SOAP11Factory) {
+        if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton()) {
             throw new UnsupportedOperationException();
         } else {
-            fault.getCode().getSubCode().detach();
+            omTarget.getCode().getSubCode().detach();
         }
     }
 
@@ -697,40 +664,41 @@ public class SOAPFaultImpl extends SOAPB
         }
 
         org.apache.axiom.soap.SOAPFactory soapFactory = null;
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
-            soapFactory = (SOAPFactory)this.element.getOMFactory();
-        } else if (this.element.getOMFactory() instanceof SOAP12Factory) {
+        if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton()) {
+            soapFactory = (SOAPFactory)this.omTarget.getOMFactory();
+        } else if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP12Version.getSingleton()) {
             if (!(qname.getNamespaceURI()
                     .equals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE))) {
                 throw new SOAPException("Incorrect URI"
                         + qname.getNamespaceURI());
             }
-            soapFactory = (SOAPFactory)this.element.getOMFactory();
+            soapFactory = (SOAPFactory)this.omTarget.getOMFactory();
         } else {
             throw new SOAPException("Invalid SOAP version");
         }
-        SOAPFaultCode soapFaultCode = soapFactory.createSOAPFaultCode(this.fault);
+        SOAPFaultCode soapFaultCode = soapFactory.createSOAPFaultCode(this.omTarget);
 
         String prefix = ((qname.getPrefix() != null) && !qname.getPrefix()
-                .equals("")) ? qname.getPrefix() : this.fault.getQName()
+                .equals("")) ? qname.getPrefix() : this.omTarget.getQName()
                 .getPrefix();
 
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
+        OMFactory factory = omTarget.getOMFactory();
+        if (((SOAPFactory)factory).getSOAPVersion() == SOAP11Version.getSingleton()) {
             soapFaultCode.setText(prefix + ":" + qname.getLocalPart());
-            OMNamespace omNamespace = new OMNamespaceImpl(qname.getNamespaceURI(),
+            OMNamespace omNamespace = factory.createOMNamespace(qname.getNamespaceURI(),
                                                           qname.getPrefix());
             soapFaultCode.declareNamespace(omNamespace);
-        } else if (this.element.getOMFactory() instanceof SOAP12Factory) {
+        } else if (((SOAPFactory)factory).getSOAPVersion() == SOAP12Version.getSingleton()) {
             SOAPFaultValue soapFaultValue = soapFactory.createSOAPFaultValue(soapFaultCode);
             // don't just use the default prefix, use the passed one or the parent's
             soapFaultValue.setText(prefix + ":" + qname.getLocalPart());
-            OMNamespace omNamespace = new OMNamespaceImpl(qname.getNamespaceURI(),
+            OMNamespace omNamespace = factory.createOMNamespace(qname.getNamespaceURI(),
                                                           qname.getPrefix());
             soapFaultValue.declareNamespace(omNamespace);
             soapFaultCode.setValue(soapFaultValue);
         }
         
-        this.fault.setCode(soapFaultCode);
+        this.omTarget.setCode(soapFaultCode);
     }
 
     /**
@@ -744,16 +712,14 @@ public class SOAPFaultImpl extends SOAPB
      */
 
     public void setFaultNode(String s) throws SOAPException {
-        org.apache.axiom.soap.SOAPFactory soapFactory = null;
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
+        SOAPFactory soapFactory = (SOAPFactory)this.omTarget.getOMFactory();
+        if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton()) {
             throw new UnsupportedOperationException("message does not support " +
                     "the SOAP 1.2 concept of Fault Node");
-        } else if (this.element.getOMFactory() instanceof SOAP12Factory) {
-            soapFactory = DOOMAbstractFactory.getSOAP12Factory();
         }
-        SOAPFaultNode soapFaultNode = soapFactory.createSOAPFaultNode(this.fault);
+        SOAPFaultNode soapFaultNode = soapFactory.createSOAPFaultNode(this.omTarget);
         soapFaultNode.setText(s);
-        this.fault.setNode(soapFaultNode);
+        this.omTarget.setNode(soapFaultNode);
     }
 
     /**
@@ -766,25 +732,23 @@ public class SOAPFaultImpl extends SOAPB
      *                       support the SOAP 1.2 concept of Fault Role.
      */
     public void setFaultRole(String uri) throws SOAPException {
-        org.apache.axiom.soap.SOAPFactory soapFactory = null;
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
+        SOAPFactory soapFactory = (SOAPFactory)this.omTarget.getOMFactory();
+        if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton()) {
             throw new UnsupportedOperationException("message does not support the " +
                     "SOAP 1.2 concept of Fault Role");
-        } else if (this.element.getOMFactory() instanceof SOAP12Factory) {
-            soapFactory = DOOMAbstractFactory.getSOAP12Factory();
         }
-        SOAPFaultRole soapFaultRole = soapFactory.createSOAPFaultRole(this.fault);
+        SOAPFaultRole soapFaultRole = soapFactory.createSOAPFaultRole(this.omTarget);
         soapFaultRole.setRoleValue(uri);
-        this.fault.setRole(soapFaultRole);
+        this.omTarget.setRole(soapFaultRole);
     }
 
     public Iterator getChildElements(Name name) {
         QName qName = new QName(name.getURI(), name.getLocalName());
-        return getChildren(element.getChildrenWithName(qName));
+        return getChildren(omTarget.getChildrenWithName(qName));
     }
 
     public Iterator getChildElements() {
-        return getChildren(element.getChildren());
+        return getChildren(omTarget.getChildren());
     }
 
     private Iterator getChildren(Iterator childIter) {
@@ -794,8 +758,8 @@ public class SOAPFaultImpl extends SOAPB
             Node saajNode = toSAAJNode(domNode);
             if (!(saajNode instanceof SOAPFaultElement)) {
                 // silently replace node, as per saaj 1.2 spec
-                SOAPFaultElement bodyEle = new SOAPFaultElementImpl((ElementImpl)domNode);
-                ((NodeImpl)domNode).setUserData(SAAJ_NODE, bodyEle, null);
+                SOAPFaultElement bodyEle = new SOAPFaultElementImpl<OMElement>((OMElement)domNode);
+                domNode.setUserData(SAAJ_NODE, bodyEle, null);
                 childElements.add(bodyEle);
             } else {
                 childElements.add(saajNode);

Modified: axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPHeaderElementImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPHeaderElementImpl.java?rev=1377526&r1=1377525&r2=1377526&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPHeaderElementImpl.java (original)
+++ axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPHeaderElementImpl.java Sun Aug 26 21:42:35 2012
@@ -19,23 +19,20 @@
 
 package org.apache.axis2.saaj;
 
-import org.apache.axiom.om.impl.dom.ElementImpl;
+import org.apache.axiom.soap.SOAP11Version;
+import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.SOAPHeaderBlock;
-import org.apache.axiom.soap.impl.dom.soap11.SOAP11Factory;
 
 import javax.xml.soap.SOAPElement;
 import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPHeader;
 import javax.xml.soap.SOAPHeaderElement;
 
-public class SOAPHeaderElementImpl extends SOAPElementImpl implements SOAPHeaderElement {
-
-    private SOAPHeaderBlock headerElem;
+public class SOAPHeaderElementImpl extends SOAPElementImpl<SOAPHeaderBlock> implements SOAPHeaderElement {
 
     /** @param element  */
     public SOAPHeaderElementImpl(SOAPHeaderBlock element) {
-        super((ElementImpl)element);
-        this.headerElem = element;
+        super(element);
     }
 
     /**
@@ -48,7 +45,7 @@ public class SOAPHeaderElementImpl exten
      * @see #getActor() getActor()
      */
     public void setActor(String actorURI) {
-        this.headerElem.setRole(actorURI);
+        this.omTarget.setRole(actorURI);
     }
 
     /**
@@ -58,7 +55,7 @@ public class SOAPHeaderElementImpl exten
      * @see #setActor(String) setActor(java.lang.String)
      */
     public String getActor() {
-        return this.headerElem.getRole();
+        return this.omTarget.getRole();
     }
 
     /**
@@ -77,7 +74,7 @@ public class SOAPHeaderElementImpl exten
      * @see #getMustUnderstand() getMustUnderstand()
      */
     public void setMustUnderstand(boolean mustUnderstand) {
-        this.headerElem.setMustUnderstand(mustUnderstand);
+        this.omTarget.setMustUnderstand(mustUnderstand);
     }
 
     /**
@@ -88,7 +85,7 @@ public class SOAPHeaderElementImpl exten
      *         <CODE>SOAPHeaderElement</CODE> object is turned on; <CODE>false</CODE> otherwise
      */
     public boolean getMustUnderstand() {
-        return this.headerElem.getMustUnderstand();
+        return this.omTarget.getMustUnderstand();
     }
 
     /**
@@ -99,18 +96,18 @@ public class SOAPHeaderElementImpl exten
      *                       - if this message does not support the SOAP 1.2 concept of Fault Role.
      */
     public void setRole(String uri) throws SOAPException {
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
+        if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton()) {
             throw new UnsupportedOperationException();
         } else {
-            this.headerElem.setRole(uri);
+            this.omTarget.setRole(uri);
         }
     }
 
     public String getRole() {
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
+        if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton()) {
             throw new UnsupportedOperationException();
         } else {
-            return this.headerElem.getRole();
+            return this.omTarget.getRole();
         }
     }
 
@@ -128,18 +125,18 @@ public class SOAPHeaderElementImpl exten
      *                       support the SOAP 1.2 concept of Relay attribute.
      */
     public void setRelay(boolean flag) throws SOAPException {
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
+        if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton()) {
             throw new UnsupportedOperationException();
         } else {
-            this.headerElem.setRelay(flag);
+            this.omTarget.setRelay(flag);
         }
     }
 
     public boolean getRelay() {
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
+        if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton()) {
             throw new UnsupportedOperationException();
         } else {
-            return this.headerElem.getRelay();
+            return this.omTarget.getRelay();
         }
     }
 



Mime
View raw message