You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ru...@apache.org on 2005/12/23 10:40:56 UTC

svn commit: r358784 [2/4] - in /webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2: src/org/apache/axis2/saaj2/ test-resources/ test/org/apache/axis2/saaj2/

Modified: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPElementImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPElementImpl.java?rev=358784&r1=358783&r2=358784&view=diff
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPElementImpl.java (original)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPElementImpl.java Fri Dec 23 01:40:17 2005
@@ -15,179 +15,226 @@
  */
 package org.apache.axis2.saaj2;
 
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import javax.xml.namespace.QName;
-import javax.xml.soap.Name;
-import javax.xml.soap.SOAPElement;
-import javax.xml.soap.SOAPException;
-import javax.xml.stream.XMLStreamException;
-
+import org.apache.axis2.om.OMAttribute;
 import org.apache.axis2.om.OMContainer;
 import org.apache.axis2.om.OMException;
 import org.apache.axis2.om.OMNamespace;
+import org.apache.axis2.om.OMNode;
 import org.apache.axis2.om.impl.OMOutputImpl;
 import org.apache.axis2.om.impl.dom.DocumentImpl;
 import org.apache.axis2.om.impl.dom.ElementImpl;
+import org.apache.axis2.om.impl.dom.TextImpl;
 import org.w3c.dom.Attr;
 import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 import org.w3c.dom.Text;
 
+import javax.xml.namespace.QName;
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.stream.XMLStreamException;
+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.axis2.om.impl.dom.ElementImpl since this class
-	 * must extend SNodeImpl
-	 */
-	protected ElementImpl element;
-	
-	public SOAPElementImpl(ElementImpl element) {
-		this.element = element;
-	}
-
-	/* (non-Javadoc)
-	 * @see org.apache.axis2.om.OMNode#discard()
-	 */
-	public void discard() throws OMException {
-		this.element.discard();
-	}
-
-	/* (non-Javadoc)
-	 * @see org.apache.axis2.om.OMNode#serialize(org.apache.axis2.om.impl.OMOutputImpl)
-	 */
-	public void serialize(OMOutputImpl omOutput) throws XMLStreamException {
-		this.element.serialize(omOutput);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.apache.axis2.om.OMNode#serializeAndConsume(org.apache.axis2.om.impl.OMOutputImpl)
-	 */
-	public void serializeAndConsume(OMOutputImpl omOutput) throws XMLStreamException {
-		this.element.serializeAndConsume(omOutput);
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPElement#addAttribute(javax.xml.soap.Name, java.lang.String)
-	 */
-	public SOAPElement addAttribute(Name name, String value) throws SOAPException {
-		this.element.setAttributeNS(name.getURI(), name.getPrefix() + ":" + name.getLocalName(), value);
-		return this;
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPElement#addChildElement(javax.xml.soap.Name)
-	 */
-	public SOAPElement addChildElement(Name name) throws SOAPException {
-		return this.addChildElement(name.getLocalName(),name.getPrefix(), name.getURI());
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPElement#addChildElement(javax.xml.soap.SOAPElement)
-	 */
-	public SOAPElement addChildElement(SOAPElement soapElement) throws SOAPException {
-		this.element.appendChild(soapElement);
-		return soapElement;
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPElement#addChildElement(java.lang.String, java.lang.String, java.lang.String)
-	 */
-	public SOAPElement addChildElement(String localName, String prefix, String uri) throws SOAPException {
-		this.element.declareNamespace(uri, prefix);
-		return this.addChildElement(localName, prefix);
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPElement#addChildElement(java.lang.String, java.lang.String)
-	 */
-	public SOAPElement addChildElement(String localName, String prefix) throws SOAPException {
-		String namespaceURI = this.getNamespaceURI(prefix);
-		if(namespaceURI == null) {
-			throw new SOAPException("Namespace not declared for the give prefix: " + prefix);
-		}
-		SOAPElementImpl elem = new SOAPElementImpl((ElementImpl)this.getOwnerDocument().createElementNS(namespaceURI, localName));
-		this.element.appendChild(elem);
-		return elem;
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPElement#addChildElement(java.lang.String)
-	 */
-	public SOAPElement addChildElement(String localName) throws SOAPException {
-		SOAPElementImpl elem = new SOAPElementImpl((ElementImpl)this.getOwnerDocument().createElement(localName));
-		this.element.appendChild(elem);
-		return elem;
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPElement#addNamespaceDeclaration(java.lang.String, java.lang.String)
-	 */
-	public SOAPElement addNamespaceDeclaration(String prefix, String uri) throws SOAPException {
-		this.element.declareNamespace(prefix, uri);
-		return this;
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPElement#addTextNode(java.lang.String)
-	 */
-	public SOAPElement addTextNode(String text) throws SOAPException {
-		//OmElement.setText() will remove all the other text nodes that it contains
-		//Therefore create a text node and add it
-		Text textNode = this.getOwnerDocument().createTextNode(text);
-		this.element.appendChild(textNode);
-		return this;
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPElement#getAllAttributes()
-	 */
-	public Iterator getAllAttributes() {
-		return this.element.getAllAttributes();
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPElement#getAttributeValue(javax.xml.soap.Name)
-	 */
-	public String getAttributeValue(Name name) {
+
+    /**
+     * Using a delegate because we can't extend from
+     * org.apache.axis2.om.impl.dom.ElementImpl since this class
+     * must extend SNodeImpl
+     */
+    protected ElementImpl element;
+
+    public SOAPElementImpl(ElementImpl element) {
+        this.element = element;
+    }
+
+    /* (non-Javadoc)
+      * @see org.apache.axis2.om.OMNode#discard()
+      */
+    public void discard() throws OMException {
+        this.element.discard();
+    }
+
+    /* (non-Javadoc)
+      * @see org.apache.axis2.om.OMNode#serialize(org.apache.axis2.om.impl.OMOutputImpl)
+      */
+    public void serialize(OMOutputImpl omOutput) throws XMLStreamException {
+        this.element.serialize(omOutput);
+    }
+
+    /* (non-Javadoc)
+      * @see org.apache.axis2.om.OMNode#serializeAndConsume(org.apache.axis2.om.impl.OMOutputImpl)
+      */
+    public void serializeAndConsume(OMOutputImpl omOutput) throws XMLStreamException {
+        this.element.serializeAndConsume(omOutput);
+    }
+
+    /**
+     * Adds an attribute with the specified name and value to this
+     * <code>SOAPElement</code> object.
+     * <p/>
+     *
+     * @param name  a <code>Name</code> object with the name of the attribute
+     * @param value a <code>String</code> giving the value of the attribute
+     * @return the <code>SOAPElement</code> object into which the attribute was
+     *         inserted
+     * @throws SOAPException if there is an error in creating the
+     *                       Attribute
+     */
+    public SOAPElement addAttribute(Name name, String value) throws SOAPException {
+        if (name.getURI() == null || name.getURI().trim().length() == 0) {
+            this.element.setAttribute(name.getLocalName(), value);
+        } else {
+            this.element.setAttributeNS(name.getURI(), name.getPrefix() + ":" + name.getLocalName(), value);
+        }
+        return this;
+    }
+
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#addChildElement(javax.xml.soap.Name)
+      */
+    public SOAPElement addChildElement(Name name) throws SOAPException {
+        return this.addChildElement(name.getLocalName(), name.getPrefix(), name.getURI());
+    }
+
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#addChildElement(javax.xml.soap.SOAPElement)
+      */
+    public SOAPElement addChildElement(SOAPElement soapElement) throws SOAPException {
+        this.element.appendChild(soapElement);
+        return soapElement;
+    }
+
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#addChildElement(java.lang.String, java.lang.String, java.lang.String)
+      */
+    public SOAPElement addChildElement(String localName, String prefix, String uri) throws SOAPException {
+        this.element.declareNamespace(uri, prefix);
+        return this.addChildElement(localName, prefix);
+    }
+
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#addChildElement(java.lang.String, java.lang.String)
+      */
+    public SOAPElement addChildElement(String localName, String prefix) throws SOAPException {
+        String namespaceURI = this.getNamespaceURI(prefix);
+
+        if (namespaceURI == null) {
+            throw new SOAPException("Namespace not declared for the give prefix: " + prefix);
+        }
+        SOAPElementImpl elem =
+                new SOAPElementImpl((ElementImpl) this.getOwnerDocument().createElementNS(namespaceURI,
+                                                                                          localName));
+        this.element.appendChild(elem.element);
+        return elem;
+    }
+
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#addChildElement(java.lang.String)
+      */
+    public SOAPElement addChildElement(String localName) throws SOAPException {
+        SOAPElementImpl elem = new SOAPElementImpl((ElementImpl) this.getOwnerDocument().createElement(localName));
+        this.element.appendChild(elem.element);
+        return elem;
+    }
+
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#addNamespaceDeclaration(java.lang.String, java.lang.String)
+      */
+    public SOAPElement addNamespaceDeclaration(String prefix, String uri) throws SOAPException {
+        this.element.declareNamespace(prefix, uri);
+        return this;
+    }
+
+    /**
+     * Creates a new <code>Text</code> object initialized with the given
+     * <code>String</code> and adds it to this <code>SOAPElement</code> object.
+     *
+     * @param text a <code>String</code> object with the textual content to be added
+     * @return the <code>SOAPElement</code> object into which
+     *         the new <code>Text</code> object was inserted
+     * @throws SOAPException if there is an error in creating the
+     *                       new <code>Text</code> object
+     */
+    public SOAPElement addTextNode(String text) throws SOAPException {
+        //OmElement.setText() will remove all the other text nodes that it contains
+        //Therefore create a text node and add it
+        Text textNode = this.getOwnerDocument().createTextNode(text);
+        this.element.appendChild(textNode);
+        return this;
+    }
+
+    /**
+     * Returns an iterator over all of the attribute names in
+     * this <CODE>SOAPElement</CODE> object. The iterator can be
+     * used to get the attribute names, which can then be passed to
+     * the method <CODE>getAttributeValue</CODE> to retrieve the
+     * value of each attribute.
+     *
+     * @return an iterator over the names of the attributes
+     */
+    public Iterator getAllAttributes() {
+        final Iterator attribIter = this.element.getAllAttributes();
+        Collection attribName = new ArrayList();
+        Attr attr;
+        while (attribIter.hasNext()) {
+            attr = (Attr) attribIter.next();
+            PrefixedQName qname;
+            if (attr.getNamespaceURI() == null || attr.getNamespaceURI().trim().length() == 0) {
+                qname = new PrefixedQName(attr.getNamespaceURI(),
+                                          attr.getName(),
+                                          attr.getPrefix());
+            } else {
+                qname = new PrefixedQName(attr.getNamespaceURI(),
+                                          attr.getLocalName(),
+                                          attr.getPrefix());
+            }
+            attribName.add(qname);
+        }
+        return attribName.iterator();
+    }
+
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#getAttributeValue(javax.xml.soap.Name)
+      */
+    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
-		return this.element.getFirstAttribute(
-                new QName(name.getURI(),
-                        name.getLocalName(),
-                        name.getPrefix()))
-                .getAttributeValue();
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPElement#getChildElements()
-	 */
-	public Iterator getChildElements() {
+        final OMAttribute attribute = this.element.getAttribute(new QName(name.getURI(),
+                                                                          name.getLocalName(),
+                                                                          name.getPrefix()));
+        return attribute.getAttributeValue();
+    }
+
+    public Iterator getChildElements() {
         //Actually all the children are being treated as OMNodes and are being
         //wrapped accordingly to a single type (SOAPElement) and being returned in an iterator.
         //Text nodes and element nodes are all being treated alike here. Is that a serious issue???
+
         Iterator childIter = this.element.getChildren();
-        ArrayList arrayList = new ArrayList();
+        Collection childElements = new ArrayList();
         while (childIter.hasNext()) {
             Object o = childIter.next();
-            if (o instanceof javax.xml.soap.Node) {
-            	arrayList.add(o);
-                //javax.xml.soap.Node childElement = new NodeImpl((org.apache.axis2.om.OMNode)o);
-
+            if (o instanceof Text) {
+                childElements.add(new TextImplEx(((Text) o).getData()));
+            } else {
+                childElements.add(new SOAPElementImpl((ElementImpl) o));
             }
         }
-        return arrayList.iterator();
-	}
+        return childElements.iterator();
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPElement#getChildElements(javax.xml.soap.Name)
-	 */
-	public Iterator getChildElements(Name name) {
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#getChildElements(javax.xml.soap.Name)
+      */
+    public Iterator getChildElements(Name name) {
         QName qName = new QName(name.getURI(), name.getLocalName());
         Iterator childIter = this.element.getChildrenWithName(qName);
         ArrayList arrayList = new ArrayList();
@@ -198,29 +245,29 @@
             }
         }
         return arrayList.iterator();
-	}
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPElement#getElementName()
-	 */
-	public Name getElementName() {
-		QName qName = this.element.getQName();
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#getElementName()
+      */
+    public Name getElementName() {
+        QName qName = this.element.getQName();
         return new PrefixedQName(qName.getNamespaceURI(),
-                qName.getLocalPart(),
-                qName.getPrefix());
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPElement#getEncodingStyle()
-	 */
-	public String getEncodingStyle() {
-		return ((DocumentImpl)this.getOwnerDocument()).getCharsetEncoding();
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPElement#getNamespacePrefixes()
-	 */
-	public Iterator getNamespacePrefixes() {
+                                 qName.getLocalPart(),
+                                 qName.getPrefix());
+    }
+
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#getEncodingStyle()
+      */
+    public String getEncodingStyle() {
+        return ((DocumentImpl) this.getOwnerDocument()).getCharsetEncoding();
+    }
+
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#getNamespacePrefixes()
+      */
+    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 = this.element.getAllDeclaredNamespaces();
@@ -232,29 +279,29 @@
             }
         }
         return prefixList.iterator();
-	}
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPElement#getNamespaceURI(java.lang.String)
-	 */
-	public String getNamespaceURI(String prefix) {
-		return this.element.getNamespaceURI(prefix);
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPElement#getVisibleNamespacePrefixes()
-	 */
-	public Iterator getVisibleNamespacePrefixes() {
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#getNamespaceURI(java.lang.String)
+      */
+    public String getNamespaceURI(String prefix) {
+        return this.element.getNamespaceURI(prefix);
+    }
+
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#getVisibleNamespacePrefixes()
+      */
+    public Iterator getVisibleNamespacePrefixes() {
         //I'll recursively return all the declared namespaces till this node, including its parents etc.
         Iterator namespacesIter = this.element.getAllDeclaredNamespaces();
         ArrayList returnList = new ArrayList();
         while (namespacesIter.hasNext()) {
             Object o = namespacesIter.next();
             if (o instanceof OMNamespace) {
-            	OMNamespace ns = (OMNamespace)o;
-            	if(ns.getPrefix() != null) {
-            		returnList.add(ns.getPrefix());
-            	}
+                OMNamespace ns = (OMNamespace) o;
+                if (ns.getPrefix() != null) {
+                    returnList.add(ns.getPrefix());
+                }
             }
         }
         //taken care of adding namespaces of this node.
@@ -266,35 +313,34 @@
             while (parentScopeNamespacesIter.hasNext()) {
                 Object o = parentScopeNamespacesIter.next();
                 if (o instanceof OMNamespace) {
-                	OMNamespace ns = (OMNamespace)o;
-                	if(ns.getPrefix() != null) {
-                		returnList.add(ns.getPrefix());
-                	}
+                    OMNamespace ns = (OMNamespace) o;
+                    if (ns.getPrefix() != null) {
+                        returnList.add(ns.getPrefix());
+                    }
                 }
             }
         }
         return returnList.iterator();
-	}
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPElement#removeAttribute(javax.xml.soap.Name)
-	 */
-	public boolean removeAttribute(Name name) {
-        org.apache.axis2.om.OMAttribute attr = this.element.getFirstAttribute(
-                new QName(name.getURI(),
-                        name.getLocalName(),
-                        name.getPrefix()));
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#removeAttribute(javax.xml.soap.Name)
+      */
+    public boolean removeAttribute(Name name) {
+        org.apache.axis2.om.OMAttribute attr = element.getAttribute(new QName(name.getURI(),
+                                                                              name.getLocalName(),
+                                                                              name.getPrefix()));
         if (attr != null) {
             this.element.removeAttribute(attr);
             return true;
         }
         return false;
-	}
+    }
 
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPElement#removeContents()
-	 */
-	public void removeContents() {
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#removeContents()
+      */
+    public void removeContents() {
         //We will get all the children and iteratively call the detach() on all of 'em.
         Iterator childIter = this.element.getChildren();
 
@@ -303,155 +349,237 @@
             if (o instanceof org.apache.axis2.om.OMNode)
                 ((org.apache.axis2.om.OMNode) o).detach();
         }
-	}
+    }
+
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#removeNamespaceDeclaration(java.lang.String)
+      */
+    public boolean removeNamespaceDeclaration(String prefix) {
+        return this.element.removeNamespace(prefix);
+    }
+
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#setEncodingStyle(java.lang.String)
+      */
+    public void setEncodingStyle(String encodingStyle) throws SOAPException {
+        ((DocumentImpl) this.getOwnerDocument()).setCharsetEncoding(encodingStyle);
+    }
+
+    /* (non-Javadoc)
+      * @see org.apache.axis2.om.impl.OMNodeEx#setParent(org.apache.axis2.om.OMContainer)
+      */
+    public void setParent(OMContainer parentElement) {
+        this.element.setParent(parentElement);
+    }
+
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#getAttribute(java.lang.String)
+      */
+    public String getAttribute(String name) {
+        return this.element.getAttribute(name);
+    }
+
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#getAttributeNode(java.lang.String)
+      */
+    public Attr getAttributeNode(String name) {
+        return this.element.getAttributeNode(name);
+    }
+
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#getAttributeNodeNS(java.lang.String, java.lang.String)
+      */
+    public Attr getAttributeNodeNS(String namespaceURI, String localName) {
+        return this.element.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 this.element.getAttributeNS(namespaceURI, localName);
+    }
+
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#getElementsByTagName(java.lang.String)
+      */
+    public NodeList getElementsByTagName(String name) {
+        return this.element.getElementsByTagName(name);
+    }
+
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#getElementsByTagNameNS(java.lang.String, java.lang.String)
+      */
+    public NodeList getElementsByTagNameNS(String namespaceURI, String localName) {
+        return this.element.getElementsByTagNameNS(namespaceURI, localName);
+    }
+
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#getTagName()
+      */
+    public String getTagName() {
+        return this.element.getTagName();
+    }
+
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#hasAttribute(java.lang.String)
+      */
+    public boolean hasAttribute(String name) {
+        return this.element.hasAttribute(name);
+    }
+
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#hasAttributeNS(java.lang.String, java.lang.String)
+      */
+    public boolean hasAttributeNS(String namespaceURI, String localName) {
+        return this.element.hasAttributeNS(namespaceURI, localName);
+    }
+
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#removeAttribute(java.lang.String)
+      */
+    public void removeAttribute(String name) throws DOMException {
+        this.element.removeAttribute(name);
+    }
+
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#removeAttributeNode(org.w3c.dom.Attr)
+      */
+    public Attr removeAttributeNode(Attr attr) throws DOMException {
+        return this.element.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 {
+        this.element.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 {
+        this.element.setAttribute(name, value);
+    }
+
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#setAttributeNode(org.w3c.dom.Attr)
+      */
+    public Attr setAttributeNode(Attr attr) throws DOMException {
+        return this.element.setAttributeNode(attr);
+    }
+
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#setAttributeNodeNS(org.w3c.dom.Attr)
+      */
+    public Attr setAttributeNodeNS(Attr attr) throws DOMException {
+        return this.element.setAttributeNodeNS(attr);
+    }
+
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#setAttributeNS(java.lang.String, java.lang.String, java.lang.String)
+      */
+    public void setAttributeNS(String namespaceURI, String qualifiedName, String value) throws DOMException {
+        this.element.setAttributeNS(namespaceURI, qualifiedName, value);
+    }
+
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Node#getNodeName()
+      */
+    public String getNodeName() {
+        return this.element.getNodeName();
+    }
+
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Node#getNodeType()
+      */
+    public short getNodeType() {
+        return Node.ELEMENT_NODE;
+    }
+
+    public ElementImpl getElement() {
+        return element;
+    }
+
+    /**
+     * Returns the parent element of this <code>Node</code> object.
+     * This method can throw an <code>UnsupportedOperationException</code>
+     * if the tree is not kept in memory.
+     *
+     * @return the <code>SOAPElement</code> object that is the parent of
+     *         this <code>Node</code> object or <code>null</code> if this
+     *         <code>Node</code> object is root
+     * @throws UnsupportedOperationException if the whole tree is not kept in memory
+     * @see #setParentElement(javax.xml.soap.SOAPElement) setParentElement(javax.xml.soap.SOAPElement)
+     */
+    public SOAPElement getParentElement() {
+        return (SOAPElement) this.element.getParent();
+    }
+
+
+    /**
+     * 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 this.element.getOwnerDocument();
+    }
+
+    /**
+     * Returns the the value of the immediate child of this <code>Node</code>
+     * object if a child exists and its value is text.
+     *
+     * @return a <code>String</code> with the text of the immediate child of
+     *         this <code>Node</code> object if (1) there is a child and
+     *         (2) the child is a <code>Text</code> object;
+     *         <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();
+            } else {
+                return ((SOAPElementImpl) firstOMChild).getValue();
+            }
+        }
+        return null;
+    }
+
 
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPElement#removeNamespaceDeclaration(java.lang.String)
-	 */
-	public boolean removeNamespaceDeclaration(String prefix) {
-		return this.element.removeNamespace(prefix);
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPElement#setEncodingStyle(java.lang.String)
-	 */
-	public void setEncodingStyle(String encodingStyle) throws SOAPException {
-		((DocumentImpl)this.getOwnerDocument()).setCharsetEncoding(encodingStyle);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.apache.axis2.om.impl.OMNodeEx#setParent(org.apache.axis2.om.OMContainer)
-	 */
-	public void setParent(OMContainer parentElement) {
-		this.element.setParent(parentElement);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.w3c.dom.Element#getAttribute(java.lang.String)
-	 */
-	public String getAttribute(String name) {
-		return this.element.getAttribute(name);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.w3c.dom.Element#getAttributeNode(java.lang.String)
-	 */
-	public Attr getAttributeNode(String name) {
-		return this.element.getAttributeNode(name);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.w3c.dom.Element#getAttributeNodeNS(java.lang.String, java.lang.String)
-	 */
-	public Attr getAttributeNodeNS(String namespaceURI, String localName) {
-		return this.element.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 this.element.getAttributeNS(namespaceURI, localName);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.w3c.dom.Element#getElementsByTagName(java.lang.String)
-	 */
-	public NodeList getElementsByTagName(String name) {
-		return this.element.getElementsByTagName(name);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.w3c.dom.Element#getElementsByTagNameNS(java.lang.String, java.lang.String)
-	 */
-	public NodeList getElementsByTagNameNS(String namespaceURI, String localName) {
-		return this.element.getElementsByTagNameNS(namespaceURI, localName);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.w3c.dom.Element#getTagName()
-	 */
-	public String getTagName() {
-		return this.element.getTagName();
-	}
-
-	/* (non-Javadoc)
-	 * @see org.w3c.dom.Element#hasAttribute(java.lang.String)
-	 */
-	public boolean hasAttribute(String name) {
-		return this.element.hasAttribute(name);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.w3c.dom.Element#hasAttributeNS(java.lang.String, java.lang.String)
-	 */
-	public boolean hasAttributeNS(String namespaceURI, String localName) {
-		return this.element.hasAttributeNS(namespaceURI, localName);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.w3c.dom.Element#removeAttribute(java.lang.String)
-	 */
-	public void removeAttribute(String name) throws DOMException {
-		this.element.removeAttribute(name);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.w3c.dom.Element#removeAttributeNode(org.w3c.dom.Attr)
-	 */
-	public Attr removeAttributeNode(Attr attr) throws DOMException {
-		return this.element.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 {
-		this.element.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 {
-		this.element.setAttribute(name, value);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.w3c.dom.Element#setAttributeNode(org.w3c.dom.Attr)
-	 */
-	public Attr setAttributeNode(Attr attr) throws DOMException {
-		return this.element.setAttributeNode(attr);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.w3c.dom.Element#setAttributeNodeNS(org.w3c.dom.Attr)
-	 */
-	public Attr setAttributeNodeNS(Attr attr) throws DOMException {
-		return this.element.setAttributeNodeNS(attr);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.w3c.dom.Element#setAttributeNS(java.lang.String, java.lang.String, java.lang.String)
-	 */
-	public void setAttributeNS(String namespaceURI, String qualifiedName, String value) throws DOMException {
-		this.element.setAttributeNS(namespaceURI, qualifiedName, value);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.w3c.dom.Node#getNodeName()
-	 */
-	public String getNodeName() {
-		return this.element.getNodeName();
-	}
-
-	/* (non-Javadoc)
-	 * @see org.w3c.dom.Node#getNodeType()
-	 */
-	public short getNodeType() {
-		return Node.ELEMENT_NODE;
-	}
-	
-	
-	
+    public org.w3c.dom.Node getFirstChild() {
+        return this.element.getFirstChild();
+    }
+
+    /**
+     * Method getLastChild
+     *
+     * @see org.w3c.dom.Node#getLastChild()
+     */
+    public org.w3c.dom.Node getLastChild() {
+        return this.element.getLastChild();
+    }
+
+    /**
+     * dom Node method
+     */
+    public org.w3c.dom.Node getNextSibling() {
+        return this.element.getNextSibling();
+    }
+
+    public Node getPreviousSibling() {
+        return this.element.getPreviousSibling();
+    }
+
+    public NodeList getChildNodes() {
+        return this.element.getChildNodes();
+    }
+
+    public boolean hasChildNodes() {
+        return this.element.hasChildNodes();
+    }
 }

Added: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPEnvelopeImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPEnvelopeImpl.java?rev=358784&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPEnvelopeImpl.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPEnvelopeImpl.java Fri Dec 23 01:40:17 2005
@@ -0,0 +1,198 @@
+/*                                                                             
+ * Copyright 2004,2005 The Apache Software Foundation.                         
+ *                                                                             
+ * Licensed under the Apache License, Version 2.0 (the "License");             
+ * you may not use this file except in compliance with the License.            
+ * You may obtain a copy of the License at                                     
+ *                                                                             
+ *      http://www.apache.org/licenses/LICENSE-2.0                             
+ *                                                                             
+ * Unless required by applicable law or agreed to in writing, software         
+ * distributed under the License is distributed on an "AS IS" BASIS,           
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.    
+ * See the License for the specific language governing permissions and         
+ * limitations under the License.                                              
+ */
+package org.apache.axis2.saaj2;
+
+import org.apache.axis2.om.impl.dom.DocumentImpl;
+import org.apache.axis2.om.impl.dom.ElementImpl;
+import org.apache.axis2.soap.impl.dom.soap11.SOAP11BodyImpl;
+import org.apache.axis2.soap.impl.dom.soap11.SOAP11HeaderImpl;
+import org.w3c.dom.Document;
+
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPElement;
+
+/**
+ * 
+ */
+public class SOAPEnvelopeImpl extends SOAPElementImpl implements javax.xml.soap.SOAPEnvelope {
+
+    private org.apache.axis2.soap.SOAPEnvelope omSOAPEnvelope;
+
+    public SOAPEnvelopeImpl(final org.apache.axis2.soap.SOAPEnvelope element) {
+        super((ElementImpl) element);
+        omSOAPEnvelope = element;
+    }
+
+    public void setOwnerDocument(Document document) {
+        super.setOwnerDocument((DocumentImpl) document);
+    }
+
+    public org.apache.axis2.soap.SOAPEnvelope getOMEnvelope() {
+        return omSOAPEnvelope;
+    }
+    
+    /**
+     * Creates a new <CODE>Name</CODE> object initialized with the
+     * given local name, namespace prefix, and namespace URI.
+     * <p/>
+     * <P>This factory method creates <CODE>Name</CODE> objects
+     * for use in the SOAP/XML document.
+     *
+     * @param localName a <CODE>String</CODE> giving
+     *                  the local name
+     * @param prefix    a <CODE>String</CODE> giving
+     *                  the prefix of the namespace
+     * @param uri       a <CODE>String</CODE> giving the
+     *                  URI of the namespace
+     * @return a <CODE>Name</CODE> object initialized with the given
+     *         local name, namespace prefix, and namespace URI
+     * @throws javax.xml.soap.SOAPException if there is a SOAP error
+     */
+    public Name createName(String localName, String prefix, String uri) throws SOAPException {
+        try {
+            return new PrefixedQName(uri, localName, prefix);
+        } catch (Exception e) {
+            throw new SOAPException(e);
+        }
+    }
+
+    /**
+     * Creates a new <CODE>Name</CODE> object initialized with the
+     * given local name.
+     * <p/>
+     * <P>This factory method creates <CODE>Name</CODE> objects
+     * for use in the SOAP/XML document.
+     *
+     * @param localName a <CODE>String</CODE> giving
+     *                  the local name
+     * @return a <CODE>Name</CODE> object initialized with the given
+     *         local name
+     * @throws javax.xml.soap.SOAPException if there is a SOAP error
+     */
+    public Name createName(String localName) throws SOAPException {
+        try {
+            return new PrefixedQName(null, localName, null);
+        } catch (Exception e) {
+            throw new SOAPException(e);
+        }
+    }
+
+    /**
+     * Returns the <CODE>SOAPHeader</CODE> object for this <CODE>
+     * SOAPEnvelope</CODE> object.
+     * <p/>
+     * <P>A new <CODE>SOAPMessage</CODE> object is by default
+     * created with a <CODE>SOAPEnvelope</CODE> object that
+     * contains an empty <CODE>SOAPHeader</CODE> object. As a
+     * result, the method <CODE>getHeader</CODE> will always
+     * return a <CODE>SOAPHeader</CODE> object unless the header
+     * has been removed and a new one has not been added.
+     *
+     * @return the <CODE>SOAPHeader</CODE> object or <CODE>
+     *         null</CODE> if there is none
+     * @throws javax.xml.soap.SOAPException if there is a problem
+     *                                      obtaining the <CODE>SOAPHeader</CODE> object
+     */
+    public SOAPHeader getHeader() throws SOAPException {
+        org.apache.axis2.soap.SOAPHeader soapHeader = omSOAPEnvelope.getHeader();
+        if (soapHeader != null) {
+            return new SOAPHeaderImpl(soapHeader);
+        }
+        return null;
+    }
+
+    /**
+     * Returns the <CODE>SOAPBody</CODE> object associated with
+     * this <CODE>SOAPEnvelope</CODE> object.
+     * <p/>
+     * <P>A new <CODE>SOAPMessage</CODE> object is by default
+     * created with a <CODE>SOAPEnvelope</CODE> object that
+     * contains an empty <CODE>SOAPBody</CODE> object. As a
+     * result, the method <CODE>getBody</CODE> will always return
+     * a <CODE>SOAPBody</CODE> object unless the body has been
+     * removed and a new one has not been added.
+     *
+     * @return the <CODE>SOAPBody</CODE> object for this <CODE>
+     *         SOAPEnvelope</CODE> object or <CODE>null</CODE> if there
+     *         is none
+     * @throws javax.xml.soap.SOAPException if there is a problem
+     *                                      obtaining the <CODE>SOAPBody</CODE> object
+     */
+    public SOAPBody getBody() throws SOAPException {
+        final org.apache.axis2.soap.SOAPBody body = omSOAPEnvelope.getBody();
+        if (body != null) {
+            return new SOAPBodyImpl(body);
+        }
+        return null;
+    }
+
+    /**
+     * Creates a <CODE>SOAPHeader</CODE> object and sets it as the
+     * <CODE>SOAPHeader</CODE> object for this <CODE>
+     * SOAPEnvelope</CODE> object.
+     * <p/>
+     * <P>It is illegal to add a header when the envelope already
+     * contains a header. Therefore, this method should be called
+     * only after the existing header has been removed.
+     *
+     * @return the new <CODE>SOAPHeader</CODE> object
+     * @throws javax.xml.soap.SOAPException if this <CODE>
+     *                                      SOAPEnvelope</CODE> object already contains a valid
+     *                                      <CODE>SOAPHeader</CODE> object
+     */
+    public SOAPHeader addHeader() throws SOAPException {
+
+        org.apache.axis2.soap.SOAPHeader header = omSOAPEnvelope.getHeader();
+        if (header == null) {
+            header = new SOAP11HeaderImpl(omSOAPEnvelope);
+            omSOAPEnvelope.addChild(header);
+            return (new SOAPHeaderImpl(header));
+        } else {
+            throw new SOAPException("Header already present, can't set header again without " +
+                                    "deleting the existing header.");
+        }
+    }
+
+    /**
+     * Creates a <CODE>SOAPBody</CODE> object and sets it as the
+     * <CODE>SOAPBody</CODE> object for this <CODE>
+     * SOAPEnvelope</CODE> object.
+     * <p/>
+     * <P>It is illegal to add a body when the envelope already
+     * contains a body. Therefore, this method should be called
+     * only after the existing body has been removed.
+     *
+     * @return the new <CODE>SOAPBody</CODE> object
+     * @throws javax.xml.soap.SOAPException if this <CODE>
+     *                                      SOAPEnvelope</CODE> object already contains a valid
+     *                                      <CODE>SOAPBody</CODE> object
+     */
+    public SOAPBody addBody() throws SOAPException {
+        org.apache.axis2.soap.SOAPBody body = omSOAPEnvelope.getBody();
+        if (body == null) {
+            body = new SOAP11BodyImpl(omSOAPEnvelope);
+            omSOAPEnvelope.addChild(body);
+            return (new SOAPBodyImpl(body));
+        } else {
+            throw new SOAPException("Body already present, can't set body again without " +
+                                    "deleting the existing body.");
+        }
+    }
+
+}

Added: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPFactoryImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPFactoryImpl.java?rev=358784&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPFactoryImpl.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPFactoryImpl.java Fri Dec 23 01:40:17 2005
@@ -0,0 +1,143 @@
+/*                                                                             
+ * Copyright 2004,2005 The Apache Software Foundation.                         
+ *                                                                             
+ * Licensed under the Apache License, Version 2.0 (the "License");             
+ * you may not use this file except in compliance with the License.            
+ * You may obtain a copy of the License at                                     
+ *                                                                             
+ *      http://www.apache.org/licenses/LICENSE-2.0                             
+ *                                                                             
+ * Unless required by applicable law or agreed to in writing, software         
+ * distributed under the License is distributed on an "AS IS" BASIS,           
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.    
+ * See the License for the specific language governing permissions and         
+ * limitations under the License.                                              
+ */
+package org.apache.axis2.saaj2;
+
+import org.apache.axis2.om.DOOMAbstractFactory;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMNamespace;
+import org.apache.axis2.om.impl.dom.ElementImpl;
+import org.apache.axis2.om.impl.dom.factory.OMDOMFactory;
+
+import javax.xml.soap.Detail;
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFactory;
+
+/**
+ * 
+ */
+public class SOAPFactoryImpl extends SOAPFactory {
+
+    /**
+     * Create a <code>SOAPElement</code> object initialized with the
+     * given <code>Name</code> object.
+     *
+     * @param name a <code>Name</code> object with the XML name for
+     *             the new element
+     * @return the new <code>SOAPElement</code> object that was
+     *         created
+     * @throws javax.xml.soap.SOAPException if there is an error in creating the
+     *                                      <code>SOAPElement</code> object
+     */
+    public SOAPElement createElement(Name name) throws SOAPException {
+        String localName = name.getLocalName();
+        String prefix = name.getPrefix();
+        String uri = name.getURI();
+        OMElement omElement = DOOMAbstractFactory.getOMFactory().createOMElement(localName, uri, prefix);
+        return new SOAPElementImpl((ElementImpl) omElement);
+    }
+
+    /**
+     * Create a <code>SOAPElement</code> object initialized with the
+     * given local name.
+     *
+     * @param localName a <code>String</code> giving the local name for
+     *                  the new element
+     * @return the new <code>SOAPElement</code> object that was
+     *         created
+     * @throws javax.xml.soap.SOAPException if there is an error in creating the
+     *                                      <code>SOAPElement</code> object
+     */
+    public SOAPElement createElement(String localName) throws SOAPException {
+        OMDOMFactory omdomFactory = (OMDOMFactory) DOOMAbstractFactory.getOMFactory();
+
+        OMNamespace ns = omdomFactory.createOMNamespace(null, null);
+        OMElement omElement = omdomFactory.createOMElement(localName, ns);
+        return new SOAPElementImpl((ElementImpl) omElement);
+    }
+
+    /**
+     * Create a new <code>SOAPElement</code> object with the given
+     * local name, prefix and uri.
+     *
+     * @param localName a <code>String</code> giving the local name
+     *                  for the new element
+     * @param prefix    the prefix for this <code>SOAPElement</code>
+     * @param uri       a <code>String</code> giving the URI of the
+     *                  namespace to which the new element belongs
+     * @return the new <code>SOAPElement</code> object that was
+     *         created
+     * @throws javax.xml.soap.SOAPException if there is an error in creating the
+     *                                      <code>SOAPElement</code> object
+     */
+    public SOAPElement createElement(String localName, String prefix, String uri) throws SOAPException {
+        OMElement omElement = DOOMAbstractFactory.getOMFactory().createOMElement(localName, uri, prefix);
+        return new SOAPElementImpl((ElementImpl) omElement);
+    }
+
+    /**
+     * Creates a new <code>Detail</code> object which serves as a container
+     * for <code>DetailEntry</code> objects.
+     * <p/>
+     * This factory method creates <code>Detail</code> objects for use in
+     * situations where it is not practical to use the <code>SOAPFault</code>
+     * abstraction.
+     *
+     * @return a <code>Detail</code> object
+     * @throws javax.xml.soap.SOAPException if there is a SOAP error
+     */
+    public Detail createDetail() throws SOAPException {
+        //TODO: Method implementation
+        return null;
+    }
+
+    /**
+     * Creates a new <code>Name</code> object initialized with the
+     * given local name, namespace prefix, and namespace URI.
+     * <p/>
+     * This factory method creates <code>Name</code> objects for use in
+     * situations where it is not practical to use the <code>SOAPEnvelope</code>
+     * abstraction.
+     *
+     * @param localName a <code>String</code> giving the local name
+     * @param prefix    a <code>String</code> giving the prefix of the namespace
+     * @param uri       a <code>String</code> giving the URI of the namespace
+     * @return a <code>Name</code> object initialized with the given
+     *         local name, namespace prefix, and namespace URI
+     * @throws javax.xml.soap.SOAPException if there is a SOAP error
+     */
+    public Name createName(String localName, String prefix, String uri) throws SOAPException {
+        return new PrefixedQName(uri, localName, prefix);
+    }
+
+    /**
+     * Creates a new <code>Name</code> object initialized with the
+     * given local name.
+     * <p/>
+     * This factory method creates <code>Name</code> objects for use in
+     * situations where it is not practical to use the <code>SOAPEnvelope</code>
+     * abstraction.
+     *
+     * @param localName a <code>String</code> giving the local name
+     * @return a <code>Name</code> object initialized with the given
+     *         local name
+     * @throws javax.xml.soap.SOAPException if there is a SOAP error
+     */
+    public Name createName(String localName) throws SOAPException {
+        return new PrefixedQName(null, localName, null);
+    }
+}

Modified: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPFaultImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPFaultImpl.java?rev=358784&r1=358783&r2=358784&view=diff
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPFaultImpl.java (original)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPFaultImpl.java Fri Dec 23 01:40:17 2005
@@ -1,12 +1,5 @@
 package org.apache.axis2.saaj2;
 
-import java.util.Locale;
-
-import javax.xml.soap.Detail;
-import javax.xml.soap.Name;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPFault;
-
 import org.apache.axis2.om.impl.dom.ElementImpl;
 import org.apache.axis2.soap.SOAPFaultCode;
 import org.apache.axis2.soap.SOAPFaultReason;
@@ -19,162 +12,175 @@
 import org.apache.axis2.soap.impl.dom.soap11.SOAP11FaultTextImpl;
 import org.apache.axis2.soap.impl.dom.soap11.SOAP11FaultValueImpl;
 
-public class SOAPFaultImpl extends SOAPBodyElementImpl implements
-		SOAPFault {
-	
-	protected org.apache.axis2.soap.SOAPFault fault;
-	
-	/**
-	 * @param element
-	 */
-	public SOAPFaultImpl(org.apache.axis2.soap.SOAPFault element) {
-		super((ElementImpl)element);
-		fault = element;
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPFault#setFaultCode(java.lang.String)
-	 */
-	public void setFaultCode(String faultCode) throws SOAPException {
-		SOAPFaultCode code = new SOAP11FaultCodeImpl(fault);
-		SOAP11FaultValueImpl faultValueImpl = new SOAP11FaultValueImpl(code);
-		faultValueImpl.setText(faultCode);
-		code.setValue(faultValueImpl);
-		this.fault.setCode(code);
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPFault#getFaultCode()
-	 */
-	public String getFaultCode() {
-		return this.fault.getCode().getValue().getText();
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPFault#setFaultActor(java.lang.String)
-	 */
-	public void setFaultActor(String faultActor) throws SOAPException {
-		if(this.fault.getRole() == null) {
-			SOAP11FaultRoleImpl faultRoleImpl = new SOAP11FaultRoleImpl(this.fault);
-			faultRoleImpl.setRoleValue(faultActor);
-			this.fault.setRole(faultRoleImpl);
-		} else {
-			SOAPFaultRole role = this.fault.getRole();
-			role.setRoleValue(faultActor);
-		}
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPFault#getFaultActor()
-	 */
-	public String getFaultActor() {
-		if(this.fault.getRole() != null) {
-			return this.fault.getRole().getRoleValue();
-		}
-		return null;
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPFault#setFaultString(java.lang.String)
-	 */
-	public void setFaultString(String faultString) throws SOAPException {
-		if(this.fault.getReason() != null) {
-			SOAPFaultReason reason = this.fault.getReason();
-			if(reason.getSOAPText() != null) {
-				reason.getSOAPText().setText(faultString);
-			} else {
-				SOAPFaultText text = new SOAP11FaultTextImpl(reason);
-				text.setText(faultString);
-				reason.setSOAPText(text);
-			}
-		} else {
-			SOAPFaultReason reason = new SOAP11FaultReasonImpl(this.fault);
-			SOAPFaultText text = new SOAP11FaultTextImpl(reason);
-			text.setText(faultString);
-			reason.setSOAPText(text);
-			this.fault.setReason(reason);
-		}
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPFault#getFaultString()
-	 */
-	public String getFaultString() {
-		if(this.fault.getReason() != null && this.fault.getReason().getSOAPText() != null) {
-			return this.fault.getReason().getSOAPText().getText();
-		}
-		return null;
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPFault#getDetail()
-	 */
-	public Detail getDetail() {
-		if(this.fault.getDetail() != null) {
-			return new DetailImpl(this.fault.getDetail());
-		}
-		return null;
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPFault#addDetail()
-	 */
-	public Detail addDetail() throws SOAPException {
-		SOAP11FaultDetailImpl omDetail = new SOAP11FaultDetailImpl(this.fault);
-		this.fault.setDetail(omDetail);
-		Detail detail = new DetailImpl(omDetail);
-		return detail;
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPFault#setFaultCode(javax.xml.soap.Name)
-	 */
-	public void setFaultCode(Name name) throws SOAPException {
-		// TODO TODO
-		throw new UnsupportedOperationException("TODO");
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPFault#getFaultCodeAsName()
-	 */
-	public Name getFaultCodeAsName() {
-		// TODO TODO
-		throw new UnsupportedOperationException("TODO");
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPFault#setFaultString(java.lang.String, java.util.Locale)
-	 */
-	public void setFaultString(String faultString, Locale locale) throws SOAPException {
-		if(this.fault.getReason() != null) {
-			SOAPFaultReason reason = this.fault.getReason();
-			if(reason.getSOAPText() != null) {
-				reason.getSOAPText().setText(faultString);
-				reason.getSOAPText().setLang(locale.getLanguage());
-			} else {
-				SOAPFaultText text = new SOAP11FaultTextImpl(reason);
-				text.setText(faultString);
-				text.setLang(locale.getLanguage());
-				reason.setSOAPText(text);
-			}
-		} else {
-			SOAPFaultReason reason = new SOAP11FaultReasonImpl(this.fault);
-			SOAPFaultText text = new SOAP11FaultTextImpl(reason);
-			text.setText(faultString);
-			text.setLang(locale.getLanguage());
-			reason.setSOAPText(text);
-			this.fault.setReason(reason);
-		}
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPFault#getFaultStringLocale()
-	 */
-	public Locale getFaultStringLocale() {
-		//We only save the language in OM,
-		//Can we construct a Locale with it :-?
-		// TODO TODO
-		throw new UnsupportedOperationException("TODO");
-	}
+import javax.xml.soap.Detail;
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFault;
+import java.util.Locale;
+
+public class SOAPFaultImpl extends SOAPBodyElementImpl implements SOAPFault {
+
+    protected org.apache.axis2.soap.SOAPFault fault;
+
+    /**
+     * @param element
+     */
+    public SOAPFaultImpl(org.apache.axis2.soap.SOAPFault element) {
+        super((ElementImpl) element);
+        fault = element;
+    }
+
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPFault#setFaultCode(java.lang.String)
+      */
+    public void setFaultCode(String faultCode) throws SOAPException {
+        SOAPFaultCode code = new SOAP11FaultCodeImpl(fault);
+        SOAP11FaultValueImpl faultValueImpl = new SOAP11FaultValueImpl(code);
+        faultValueImpl.setText(faultCode);
+        code.setValue(faultValueImpl);
+        this.fault.setCode(code);
+    }
+
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPFault#getFaultCode()
+      */
+    public String getFaultCode() {
+        return this.fault.getCode().getValue().getText();
+    }
+
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPFault#setFaultActor(java.lang.String)
+      */
+    public void setFaultActor(String faultActor) throws SOAPException {
+        if (this.fault.getRole() == null) {
+            SOAP11FaultRoleImpl faultRoleImpl = new SOAP11FaultRoleImpl(this.fault);
+            faultRoleImpl.setRoleValue(faultActor);
+            this.fault.setRole(faultRoleImpl);
+        } else {
+            SOAPFaultRole role = this.fault.getRole();
+            role.setRoleValue(faultActor);
+        }
+    }
+
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPFault#getFaultActor()
+      */
+    public String getFaultActor() {
+        if (this.fault.getRole() != null) {
+            return this.fault.getRole().getRoleValue();
+        }
+        return null;
+    }
+
+    /**
+     * Sets the fault string for this <CODE>SOAPFault</CODE>
+     * object to the given string.
+     *
+     * @param faultString a <CODE>String</CODE>
+     *                    giving an explanation of the fault
+     * @throws SOAPException if there was an error in
+     *                       adding the <CODE>faultString</CODE> to the underlying XML
+     *                       tree.
+     * @see #getFaultString() getFaultString()
+     */
+    public void setFaultString(String faultString) throws SOAPException {
+        if (this.fault.getReason() != null) {
+            SOAPFaultReason reason = this.fault.getReason();
+            if (reason.getSOAPText() != null) {
+                reason.getSOAPText().setText(faultString);
+            } else {
+                SOAPFaultText text = new SOAP11FaultTextImpl(reason);
+                text.setText(faultString);
+                reason.setSOAPText(text);
+            }
+        } else {
+            SOAPFaultReason reason = new SOAP11FaultReasonImpl(this.fault);
+            SOAPFaultText text = new SOAP11FaultTextImpl(reason);
+            text.setText(faultString);
+            reason.setSOAPText(text);
+            this.fault.setReason(reason);
+        }
+    }
+
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPFault#getFaultString()
+      */
+    public String getFaultString() {
+        if (this.fault.getReason() != null && this.fault.getReason().getSOAPText() != null) {
+            return this.fault.getReason().getSOAPText().getText();
+        }
+        return null;
+    }
+
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPFault#getDetail()
+      */
+    public Detail getDetail() {
+        if (this.fault.getDetail() != null) {
+            return new DetailImpl(this.fault.getDetail());
+        }
+        return null;
+    }
+
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPFault#addDetail()
+      */
+    public Detail addDetail() throws SOAPException {
+        SOAP11FaultDetailImpl omDetail = new SOAP11FaultDetailImpl(this.fault);
+        this.fault.setDetail(omDetail);
+        Detail detail = new DetailImpl(omDetail);
+        return detail;
+    }
+
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPFault#setFaultCode(javax.xml.soap.Name)
+      */
+    public void setFaultCode(Name name) throws SOAPException {
+        // TODO TODO
+        throw new UnsupportedOperationException("TODO");
+    }
+
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPFault#getFaultCodeAsName()
+      */
+    public Name getFaultCodeAsName() {
+        // TODO TODO
+        throw new UnsupportedOperationException("TODO");
+    }
+
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPFault#setFaultString(java.lang.String, java.util.Locale)
+      */
+    public void setFaultString(String faultString, Locale locale) throws SOAPException {
+        if (this.fault.getReason() != null) {
+            SOAPFaultReason reason = this.fault.getReason();
+            if (reason.getSOAPText() != null) {
+                reason.getSOAPText().setText(faultString);
+                reason.getSOAPText().setLang(locale.getLanguage());
+            } else {
+                SOAPFaultText text = new SOAP11FaultTextImpl(reason);
+                text.setText(faultString);
+                text.setLang(locale.getLanguage());
+                reason.setSOAPText(text);
+            }
+        } else {
+            SOAPFaultReason reason = new SOAP11FaultReasonImpl(this.fault);
+            SOAPFaultText text = new SOAP11FaultTextImpl(reason);
+            text.setText(faultString);
+            text.setLang(locale.getLanguage());
+            reason.setSOAPText(text);
+            this.fault.setReason(reason);
+        }
+    }
+
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPFault#getFaultStringLocale()
+      */
+    public Locale getFaultStringLocale() {
+        //We only save the language in OM,
+        //Can we construct a Locale with it :-?
+        // TODO TODO
+        throw new UnsupportedOperationException("TODO");
+    }
 
 }

Modified: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPHeaderElementImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPHeaderElementImpl.java?rev=358784&r1=358783&r2=358784&view=diff
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPHeaderElementImpl.java (original)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPHeaderElementImpl.java Fri Dec 23 01:40:17 2005
@@ -15,48 +15,83 @@
  */
 package org.apache.axis2.saaj2;
 
-import javax.xml.soap.SOAPHeaderElement;
-
 import org.apache.axis2.om.impl.dom.ElementImpl;
 import org.apache.axis2.soap.SOAPHeaderBlock;
 
-public class SOAPHeaderElementImpl extends SOAPElementImpl implements
-		SOAPHeaderElement {
+import javax.xml.soap.SOAPHeaderElement;
+
+public class SOAPHeaderElementImpl extends SOAPElementImpl implements SOAPHeaderElement {
 
-	SOAPHeaderBlock headerElem;
-	/**
-	 * @param element
-	 */
-	public SOAPHeaderElementImpl(SOAPHeaderBlock element) {
-		super((ElementImpl)element);
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPHeaderElement#setActor(java.lang.String)
-	 */
-	public void setActor(String actorURI) {
-		this.headerElem.setRole(actorURI);
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPHeaderElement#getActor()
-	 */
-	public String getActor() {
-		return this.headerElem.getRole();
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPHeaderElement#setMustUnderstand(boolean)
-	 */
-	public void setMustUnderstand(boolean mustUnderstand) {
-		this.headerElem.setMustUnderstand(mustUnderstand);
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPHeaderElement#getMustUnderstand()
-	 */
-	public boolean getMustUnderstand() {
-		return this.headerElem.getMustUnderstand();
-	}
+    private SOAPHeaderBlock headerElem;
 
+    /**
+     * @param element
+     */
+    public SOAPHeaderElementImpl(SOAPHeaderBlock element) {
+        super((ElementImpl) element);
+        this.headerElem = element;
+    }
+
+    /**
+     * Sets the actor associated with this <CODE>
+     * SOAPHeaderElement</CODE> object to the specified actor. The
+     * default value of an actor is: <CODE>
+     * SOAPConstants.URI_SOAP_ACTOR_NEXT</CODE>
+     *
+     * @param actorURI a <CODE>String</CODE> giving
+     *                 the URI of the actor to set
+     * @throws java.lang.IllegalArgumentException
+     *          if
+     *          there is a problem in setting the actor.
+     * @see #getActor() getActor()
+     */
+    public void setActor(String actorURI) {
+        this.headerElem.setRole(actorURI);
+    }
+
+    /**
+     * Returns the uri of the actor associated with this <CODE>
+     * SOAPHeaderElement</CODE> object.
+     *
+     * @return a <CODE>String</CODE> giving the URI of the
+     *         actor
+     * @see #setActor(java.lang.String) setActor(java.lang.String)
+     */
+    public String getActor() {
+        return this.headerElem.getRole();
+    }
+
+    /**
+     * Sets the mustUnderstand attribute for this <CODE>
+     * SOAPHeaderElement</CODE> object to be on or off.
+     * <p/>
+     * <P>If the mustUnderstand attribute is on, the actor who
+     * receives the <CODE>SOAPHeaderElement</CODE> must process it
+     * correctly. This ensures, for example, that if the <CODE>
+     * SOAPHeaderElement</CODE> object modifies the message, that
+     * the message is being modified correctly.</P>
+     *
+     * @param mustUnderstand <CODE>true</CODE> to
+     *                       set the mustUnderstand attribute on; <CODE>false</CODE>
+     *                       to turn if off
+     * @throws java.lang.IllegalArgumentException
+     *          if
+     *          there is a problem in setting the actor.
+     * @see #getMustUnderstand() getMustUnderstand()
+     */
+    public void setMustUnderstand(boolean mustUnderstand) {
+        this.headerElem.setMustUnderstand(mustUnderstand);
+    }
+
+    /**
+     * Returns whether the mustUnderstand attribute for this
+     * <CODE>SOAPHeaderElement</CODE> object is turned on.
+     *
+     * @return <CODE>true</CODE> if the mustUnderstand attribute of
+     *         this <CODE>SOAPHeaderElement</CODE> object is turned on;
+     *         <CODE>false</CODE> otherwise
+     */
+    public boolean getMustUnderstand() {
+        return this.headerElem.getMustUnderstand();
+    }
 }

Modified: webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPHeaderImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPHeaderImpl.java?rev=358784&r1=358783&r2=358784&view=diff
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPHeaderImpl.java (original)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith_dims/saaj2/src/org/apache/axis2/saaj2/SOAPHeaderImpl.java Fri Dec 23 01:40:17 2005
@@ -15,121 +15,157 @@
  */
 package org.apache.axis2.saaj2;
 
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import javax.xml.soap.Name;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPHeader;
-import javax.xml.soap.SOAPHeaderElement;
-
 import org.apache.axis2.om.OMNamespace;
 import org.apache.axis2.om.impl.dom.ElementImpl;
 import org.apache.axis2.om.impl.dom.NamespaceImpl;
 import org.apache.axis2.soap.SOAPHeaderBlock;
 import org.apache.axis2.soap.impl.dom.soap11.SOAP11HeaderBlockImpl;
 
-public class SOAPHeaderImpl extends SOAPElementImpl implements
-		SOAPHeader {
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPHeaderElement;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+public class SOAPHeaderImpl extends SOAPElementImpl implements SOAPHeader {
 
-    private org.apache.axis2.soap.SOAPHeader omHeader;
-    
-	/**
-	 * @param element
-	 */
-	public SOAPHeaderImpl(org.apache.axis2.soap.SOAPHeader header) {
-		super((ElementImpl)header);
-		this.omHeader = header;
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPHeader#addHeaderElement(javax.xml.soap.Name)
-	 */
-	public SOAPHeaderElement addHeaderElement(Name name) throws SOAPException {
-		OMNamespace ns = new NamespaceImpl(name.getURI(), name.getPrefix());
-		SOAPHeaderBlock headerBlock = new SOAP11HeaderBlockImpl(name.getLocalName(), ns, this.omHeader);
-		return new SOAPHeaderElementImpl(headerBlock);
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPHeader#examineHeaderElements(java.lang.String)
-	 */
-	public Iterator examineHeaderElements(String actor) {
-		Iterator headerElems = this.omHeader.examineHeaderBlocks(actor);
-		ArrayList aList = new ArrayList();
-		while (headerElems.hasNext()) {
-			Object element =  headerElems.next();
-			if(element instanceof SOAPHeaderBlock) {
-				aList.add(new SOAPHeaderElementImpl((SOAPHeaderBlock)element));
-			}
-			
-		}
-		return aList.iterator();
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPHeader#extractHeaderElements(java.lang.String)
-	 */
-	public Iterator extractHeaderElements(String actor) {
-		Iterator headerElems = this.omHeader.extractHeaderBlocks(actor);
-		ArrayList aList = new ArrayList();
-		while (headerElems.hasNext()) {
-			Object element =  headerElems.next();
-			if(element instanceof SOAPHeaderBlock) {
-				aList.add(new SOAPHeaderElementImpl((SOAPHeaderBlock)element));
-			}
-			
-		}
-		return aList.iterator();
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPHeader#examineMustUnderstandHeaderElements(java.lang.String)
-	 */
-	public Iterator examineMustUnderstandHeaderElements(String actor) {
-		Iterator headerElems = this.omHeader.examineMustUnderstandHeaderBlocks(actor);
-		ArrayList aList = new ArrayList();
-		while (headerElems.hasNext()) {
-			Object element =  headerElems.next();
-			if(element instanceof SOAPHeaderBlock) {
-				aList.add(new SOAPHeaderElementImpl((SOAPHeaderBlock)element));
-			}
-			
-		}
-		return aList.iterator();
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPHeader#examineAllHeaderElements()
-	 */
-	public Iterator examineAllHeaderElements() {
-		Iterator headerElems = this.omHeader.examineAllHeaderBlocks();
-		ArrayList aList = new ArrayList();
-		while (headerElems.hasNext()) {
-			Object element =  headerElems.next();
-			if(element instanceof SOAPHeaderBlock) {
-				aList.add(new SOAPHeaderElementImpl((SOAPHeaderBlock)element));
-			}
-			
-		}
-		return aList.iterator();
-	}
-
-	/* (non-Javadoc)
-	 * @see javax.xml.soap.SOAPHeader#extractAllHeaderElements()
-	 */
-	public Iterator extractAllHeaderElements() {
-		Iterator headerElems = this.omHeader.extractAllHeaderBlocks();
-		ArrayList aList = new ArrayList();
-		while (headerElems.hasNext()) {
-			Object element =  headerElems.next();
-			if(element instanceof SOAPHeaderBlock) {
-				aList.add(new SOAPHeaderElementImpl((SOAPHeaderBlock)element));
-			}
-			
-		}
-		return aList.iterator();
-	}
+    private org.apache.axis2.soap.SOAPHeader omSOAPHeader;
 
-	
+    /**
+     * Constructor
+     *
+     * @param header
+     */
+    public SOAPHeaderImpl(org.apache.axis2.soap.SOAPHeader header) {
+        super((ElementImpl) header);
+        omSOAPHeader = header;
+    }
+
+    /**
+     * Creates a new <CODE>SOAPHeaderElement</CODE> object
+     * initialized with the specified name and adds it to this
+     * <CODE>SOAPHeader</CODE> object.
+     *
+     * @param name a <CODE>Name</CODE> object with
+     *             the name of the new <CODE>SOAPHeaderElement</CODE>
+     *             object
+     * @return the new <CODE>SOAPHeaderElement</CODE> object that
+     *         was inserted into this <CODE>SOAPHeader</CODE>
+     *         object
+     * @throws SOAPException if a SOAP error occurs
+     */
+    public SOAPHeaderElement addHeaderElement(Name name) throws SOAPException {
+        OMNamespace ns = new NamespaceImpl(name.getURI(), name.getPrefix());
+        SOAPHeaderBlock headerBlock = new SOAP11HeaderBlockImpl(name.getLocalName(), ns, omSOAPHeader);
+        return new SOAPHeaderElementImpl(headerBlock);
+    }
+
+    /**
+     * Returns a list of all the <CODE>SOAPHeaderElement</CODE>
+     * objects in this <CODE>SOAPHeader</CODE> object that have the
+     * the specified actor. An actor is a global attribute that
+     * indicates the intermediate parties to whom the message should
+     * be sent. An actor receives the message and then sends it to
+     * the next actor. The default actor is the ultimate intended
+     * recipient for the message, so if no actor attribute is
+     * included in a <CODE>SOAPHeader</CODE> object, the message is
+     * sent to its ultimate destination.
+     *
+     * @param actor a <CODE>String</CODE> giving the
+     *              URI of the actor for which to search
+     * @return an <CODE>Iterator</CODE> object over all the <CODE>
+     *         SOAPHeaderElement</CODE> objects that contain the
+     *         specified actor
+     * @see #extractHeaderElements(java.lang.String) extractHeaderElements(java.lang.String)
+     */
+    public Iterator examineHeaderElements(String actor) {
+        Collection elements = new ArrayList();
+        for (Iterator iterator = omSOAPHeader.examineHeaderBlocks(actor); iterator.hasNext();) {
+            elements.add(new SOAPHeaderElementImpl((SOAPHeaderBlock) iterator.next()));
+        }
+        return elements.iterator();
+    }
+
+    /**
+     * Returns a list of all the <CODE>SOAPHeaderElement</CODE>
+     * objects in this <CODE>SOAPHeader</CODE> object that have
+     * the the specified actor and detaches them from this <CODE>
+     * SOAPHeader</CODE> object.
+     * <p/>
+     * <P>This method allows an actor to process only the parts of
+     * the <CODE>SOAPHeader</CODE> object that apply to it and to
+     * remove them before passing the message on to the next
+     * actor.
+     *
+     * @param actor a <CODE>String</CODE> giving the
+     *              URI of the actor for which to search
+     * @return an <CODE>Iterator</CODE> object over all the <CODE>
+     *         SOAPHeaderElement</CODE> objects that contain the
+     *         specified actor
+     * @see #examineHeaderElements(java.lang.String) examineHeaderElements(java.lang.String)
+     */
+    public Iterator extractHeaderElements(String actor) {
+        Collection elements = new ArrayList();
+        for (Iterator iterator = omSOAPHeader.extractHeaderBlocks(actor); iterator.hasNext();) {
+            elements.add(new SOAPHeaderElementImpl((SOAPHeaderBlock) iterator.next()));
+        }
+        return elements.iterator();
+    }
+
+    /**
+     * Returns an <code>Iterator</code> over all the
+     * <code>SOAPHeaderElement</code> objects in this <code>SOAPHeader</code>
+     * object that have the specified actor and that have a MustUnderstand
+     * attribute whose value is equivalent to <code>true</code>.
+     *
+     * @param actor a <code>String</code> giving the URI of the actor for which
+     *              to search
+     * @return an <code>Iterator</code> object over all the
+     *         <code>SOAPHeaderElement</code> objects that contain the
+     *         specified actor and are marked as MustUnderstand
+     */
+    public Iterator examineMustUnderstandHeaderElements(String actor) {
+        Collection elements = new ArrayList();
+        for (Iterator iterator = omSOAPHeader.examineMustUnderstandHeaderBlocks(actor); iterator.hasNext();)
+        {
+            elements.add(new SOAPHeaderElementImpl((SOAPHeaderBlock) iterator.next()));
+        }
+        return elements.iterator();
+    }
+
+    /**
+     * Returns an <code>Iterator</code> over all the
+     * <code>SOAPHeaderElement</code> objects in this <code>SOAPHeader</code>
+     * object.
+     *
+     * @return an <code>Iterator</code> object over all the
+     *         <code>SOAPHeaderElement</code> objects contained by this
+     *         <code>SOAPHeader</code>
+     */
+    public Iterator examineAllHeaderElements() {
+        Collection elements = new ArrayList();
+        for (Iterator iterator = omSOAPHeader.examineAllHeaderBlocks(); iterator.hasNext();) {
+            elements.add(new SOAPHeaderElementImpl((SOAPHeaderBlock) iterator.next()));
+        }
+        return elements.iterator();
+    }
+
+    /**
+     * Returns an <code>Iterator</code> over all the
+     * <code>SOAPHeaderElement</code> objects in this <code>SOAPHeader </code>
+     * object and detaches them from this <code>SOAPHeader</code> object.
+     *
+     * @return an <code>Iterator</code> object over all the
+     *         <code>SOAPHeaderElement</code> objects contained by this
+     *         <code>SOAPHeader</code>
+     */
+    public Iterator extractAllHeaderElements() {
+        Collection elements = new ArrayList();
+        for (Iterator iterator = omSOAPHeader.extractAllHeaderBlocks(); iterator.hasNext();) {
+            elements.add(new SOAPHeaderElementImpl((SOAPHeaderBlock) iterator.next()));
+        }
+        return elements.iterator();
+    }
 }