You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ve...@apache.org on 2005/06/03 16:08:13 UTC
svn commit: r179794 [1/2] - in
/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj:
src/javax/xml/ src/org/apache/ src/org/apache/axis/
src/org/apache/axis/saaj/ src/org/apache/axis/util/ test/org/
test/org/apache/ test/org/apache/axis/ test/org/apache/axis/saaj/
Author: venkat
Date: Fri Jun 3 07:08:11 2005
New Revision: 179794
URL: http://svn.apache.org/viewcvs?rev=179794&view=rev
Log:
Adding some more files for SAAJ impl.
Added:
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/javax/xml/
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/AttrImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/DetailEntryImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/DetailImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/MessageFactoryImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/MimeHeaders.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/NodeImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/NodeListImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/PrefixedQName.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPBodyElementImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPBodyImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPConnectionFactoryImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPConnectionImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPDocumentImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPElementImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPEnvelopeImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPFactoryImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPFaultElementImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPFaultImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPHeaderElementImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPHeaderImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPMessageImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPPartImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/TextImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/util/
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/util/Dom2OmUtils.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/util/IOUtils.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/util/SessionUtils.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/util/XMLUtils.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/test/org/
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/test/org/apache/
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/test/org/apache/axis/
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/test/org/apache/axis/saaj/
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/test/org/apache/axis/saaj/TestClient.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/test/org/apache/axis/saaj/TestClient2.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/test/org/apache/axis/saaj/TestHeaders.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/test/org/apache/axis/saaj/TestPrefixes.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/test/org/apache/axis/saaj/TestSOAPBody.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/test/org/apache/axis/saaj/TestSOAPElement.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/test/org/apache/axis/saaj/TestSOAPEnvelope.java
Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/AttrImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/AttrImpl.java?rev=179794&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/AttrImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/AttrImpl.java Fri Jun 3 07:08:11 2005
@@ -0,0 +1,102 @@
+/*
+ * Created on May 23, 2005
+ *
+ */
+package org.apache.axis.saaj;
+
+import org.apache.axis.om.OMAttribute;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+
+/**
+ * @author Jayachandra
+ *
+ */
+public class AttrImpl extends NodeImpl implements Attr {
+
+ private boolean specified = false;
+ private OMAttribute omAttr;
+ private Element ownerElement=null;
+
+ /**
+ *
+ */
+ public AttrImpl() {
+ super();
+ }
+
+ /**
+ * @param attrib
+ */
+ public AttrImpl(OMAttribute attrib, Element owner) {
+ super(attrib);
+ this.omAttr = attrib;
+ this.ownerElement = owner;
+ }
+
+ /**
+ * Method getSpecified
+ * Returns true if this attribute value is set by user in the original document,
+ * if so far user didn't set some value to this OR if the user removed this
+ * attribute (may be by calling removeAttribute() on owner element) the specified
+ * value returned should be false
+ * @see org.w3c.dom.Attr#getSpecified()
+ */
+ public boolean getSpecified() {
+ return specified;
+ }
+
+ /**
+ * Method setSpecified
+ * This method sets the value of the private datamember <code>specified</code>
+ * equals to that of the passed input parameter <code>val</code> and returns the
+ * final value of <code>specified</code> flag
+ * @param val
+ * @return boolean
+ */
+ public boolean setSpecified(boolean val) {
+ this.specified = val;
+ return specified;
+ }
+
+ /**
+ * Method getName
+ * returns the localName of the attribute
+ * @return String
+ * @see org.w3c.dom.Attr#getName()
+ */
+ public String getName() {
+ return omAttr.getLocalName();
+ }
+
+ /**
+ * Method getOwnerElement
+ * returns the <code>Element</code> object to which this attribute is attached
+ * @return Element
+ * @see org.w3c.dom.Attr#getOwnerElement()
+ */
+ public Element getOwnerElement() {
+ return ownerElement;
+ }
+
+ /**
+ * Method getValue
+ * returns the value of this attribute
+ * @return String
+ */
+ public String getValue() {
+ return omAttr.getValue();
+ }
+
+ /**
+ * Method setValue
+ * This method sets the value of this attribute to the provided input
+ * <code>value</code>
+ * @param value
+ * @return
+ */
+ public void setValue(String value) {
+ omAttr.setValue(value);
+ setSpecified(true);
+ }
+}
Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/DetailEntryImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/DetailEntryImpl.java?rev=179794&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/DetailEntryImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/DetailEntryImpl.java Fri Jun 3 07:08:11 2005
@@ -0,0 +1,39 @@
+/*
+ * Created on Mar 17, 2005
+ *
+ */
+package org.apache.axis.saaj;
+
+import javax.xml.soap.DetailEntry;
+
+/**
+ * Class DetailEntryImpl
+ *
+ * @author Ashutosh Shahi
+ * ashutosh.shahi@gmail.com
+ */
+public class DetailEntryImpl extends SOAPElementImpl implements DetailEntry {
+
+ /**
+ * Field detailEntry
+ */
+ private org.apache.axis.om.OMElement detailEntry;
+
+ /**
+ * Constructor DetailEntryImpl
+ *
+ */
+ public DetailEntryImpl(){
+
+ }
+
+ /**
+ * Constructor DetailEntryImpl
+ *
+ * @param detailEntry
+ */
+ public DetailEntryImpl(org.apache.axis.om.OMElement detailEntry){
+ this.detailEntry = detailEntry;
+ }
+
+}
Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/DetailImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/DetailImpl.java?rev=179794&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/DetailImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/DetailImpl.java Fri Jun 3 07:08:11 2005
@@ -0,0 +1,102 @@
+/*
+ * Created on Mar 17, 2005
+ *
+ */
+package org.apache.axis.saaj;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import javax.xml.soap.Detail;
+import javax.xml.soap.DetailEntry;
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPException;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMFactory;
+import org.apache.axis.om.OMAbstractFactory;
+import org.apache.axis.om.OMNamespace;
+
+/**
+ * Class DetailImpl
+ *
+ * @author Ashutosh Shahi
+ * ashutosh.shahi@gmail.com
+ */
+public class DetailImpl extends SOAPFaultElementImpl implements Detail {
+
+ /**
+ * Field detail
+ */
+ OMElement detail;
+
+ /**
+ * Constructor DetailImpl
+ *
+ * @param detailName
+ * @param parent
+ */
+ public DetailImpl(javax.xml.namespace.QName detailName, OMElement parent){
+ OMFactory omFactory = OMAbstractFactory.getOMFactory();
+ detail = omFactory.createOMElement(detailName, parent);
+ }
+
+ /*public DetailImpl(OMElement detail){
+ this.detail = detail;
+ }*/
+
+ /**
+ * Method addDetailEntry
+ *
+ * @param name
+ * @return
+ * @throws SOAPException
+ * @see javax.xml.soap.Detail#addDetailEntry(javax.xml.soap.Name)
+ */
+ public DetailEntry addDetailEntry(Name name) throws SOAPException {
+
+ // Create a OMElement and add it as a child of Detail
+ // May need change after OM allows adding multiple detailEntries
+ // as then we can delegate the task there rather than dealing with OMElement here
+ String localName = name.getLocalName();
+ OMFactory omFactory = OMAbstractFactory.getOMFactory();
+ OMNamespace ns = omFactory.createOMNamespace(name.getURI(), name.getPrefix());
+ OMElement detailEntry = omFactory.createOMElement(localName, ns);
+ detail.addChild(detailEntry);
+ return (new DetailEntryImpl(detailEntry));
+ }
+
+ /**
+ * Method addDetailEntry
+ *
+ * @param detailEntry
+ * @return
+ */
+ protected DetailEntry addDetailEntry(org.apache.axis.om.OMNode detailEntry){
+ detail.addChild(detailEntry);
+ return (new DetailEntryImpl((OMElement)detailEntry));
+ }
+
+ /**
+ * Method getDetailEntries
+ *
+ * @return
+ * @see javax.xml.soap.Detail#getDetailEntries()
+ */
+ public Iterator getDetailEntries() {
+ // Get the detailEntried which will be omElements
+ // convert them to soap DetailEntry and return the iterator
+ Iterator detailEntryIter = detail.getChildren();
+ ArrayList aList = new ArrayList();
+ while(detailEntryIter.hasNext()){
+ Object o = detailEntryIter.next();
+ if(o instanceof org.apache.axis.om.OMElement){
+ OMElement omDetailEntry = (OMElement)o;
+ DetailEntry detailEntry = new DetailEntryImpl(omDetailEntry);
+ aList.add(detailEntry);
+ }
+ }
+ return aList.iterator();
+ }
+
+}
Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/MessageFactoryImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/MessageFactoryImpl.java?rev=179794&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/MessageFactoryImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/MessageFactoryImpl.java Fri Jun 3 07:08:11 2005
@@ -0,0 +1,44 @@
+/*
+ * Created on Apr 8, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.axis.saaj;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.MimeHeaders;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+
+/**
+ * @author Ashutosh Shahi ashutosh.shahi@gmail.com
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class MessageFactoryImpl extends MessageFactory {
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.MessageFactory#createMessage()
+ */
+ public SOAPMessage createMessage() throws SOAPException {
+ SOAPEnvelopeImpl env = new SOAPEnvelopeImpl();
+ SOAPMessageImpl message = new SOAPMessageImpl(env);
+ return message;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.MessageFactory#createMessage(javax.xml.soap.MimeHeaders, java.io.InputStream)
+ */
+ public SOAPMessage createMessage(MimeHeaders mimeheaders,
+ InputStream inputstream) throws IOException, SOAPException {
+ // TODO Auto-generated method stub
+ SOAPMessageImpl message = new SOAPMessageImpl(inputstream, false,mimeheaders);
+ return message;
+ }
+
+}
Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/MimeHeaders.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/MimeHeaders.java?rev=179794&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/MimeHeaders.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/MimeHeaders.java Fri Jun 3 07:08:11 2005
@@ -0,0 +1,39 @@
+/*
+ * Created on Apr 8, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.axis.saaj;
+
+import java.util.Iterator;
+import javax.xml.soap.MimeHeader;
+
+/**
+ * @author Ashutosh Shahi ashutosh.shahi@gmail.com
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class MimeHeaders extends javax.xml.soap.MimeHeaders {
+ public MimeHeaders() {
+ }
+
+ public MimeHeaders(javax.xml.soap.MimeHeaders h) {
+ Iterator iterator = h.getAllHeaders();
+ while (iterator.hasNext()) {
+ MimeHeader hdr = (MimeHeader) iterator.next();
+ addHeader(hdr.getName(), hdr.getValue());
+ }
+ }
+
+ private int getHeaderSize() {
+ int size = 0;
+ Iterator iterator = getAllHeaders();
+ while (iterator.hasNext()) {
+ iterator.next();
+ size++;
+ }
+ return size;
+ }
+}
Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/NodeImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/NodeImpl.java?rev=179794&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/NodeImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/NodeImpl.java Fri Jun 3 07:08:11 2005
@@ -0,0 +1,495 @@
+/*
+ * Created on Mar 16, 2005
+ *
+ */
+package org.apache.axis.saaj;
+
+import java.util.Iterator;
+
+import javax.xml.soap.Node;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+
+import org.apache.axis.om.OMAttribute;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMNamespace;
+import org.apache.axis.om.OMNode;
+import org.apache.axis.om.OMText;
+import org.apache.axis.util.Dom2OmUtils;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.CharacterData;
+
+/**
+ * Class NodeImpl
+ *
+ * @author Ashutosh Shahi
+ * ashutosh.shahi@gmail.com
+ */
+public class NodeImpl implements Node {
+
+ /**
+ * Field omNode
+ */
+ protected org.apache.axis.om.OMNode omNode;
+ /**
+ * field document
+ */
+ protected org.w3c.dom.Document document;
+
+ //protected CharacterData textRep = null;
+
+ /**
+ * Constructor NodeImpl
+ *
+ */
+ public NodeImpl(){
+
+ }
+
+ /**
+ * Constructor NodeImpl
+ *
+ * @param node
+ */
+ public NodeImpl(OMNode node){
+ this.omNode = node;
+ }
+ /**
+ * Constructor NodeImpl
+ *
+ * @param attrib
+ */
+ public NodeImpl(OMAttribute attrib){
+ //TODO
+ // To be implemented
+ // Find out a way to construct OMNode from a OMAttribute
+ // as OMAttributes are immutable
+ }
+
+ /**
+ * Constructor NodeImpl
+ *
+ * @param ns
+ */
+ public NodeImpl(OMNamespace ns){
+ //TODO
+ // To be implemented
+ // Find out a way to construct OMNode from OMNamespace
+ // OMNamespace is immutable
+ }
+
+ /**
+ * constructor which adopts the name and NS of the char data, and its text
+ * @param text
+ */
+/* public NodeImpl(CharacterData text) {
+
+ }
+*/
+
+ public OMNode getOMNode(){
+ return omNode;
+ }
+
+ /**
+ * Method getValue
+ *
+ * @see javax.xml.soap.Node#getValue()
+ */
+ public String getValue() {
+
+ if(omNode.getType() == OMNode.TEXT_NODE)
+ return ((OMText)omNode).getText();
+ else if(omNode.getType() == OMNode.ELEMENT_NODE)
+ new NodeImpl(((OMElement)omNode).getFirstChild()).getValue();
+ return null;
+ }
+
+ /**
+ * Method setParentElement
+ * @param parent
+ *
+ * @see javax.xml.soap.Node#setParentElement(javax.xml.soap.SOAPElement)
+ */
+ public void setParentElement(SOAPElement parent) throws SOAPException {
+
+ OMElement omParent = ((SOAPElementImpl)parent).getOMElement();
+ omNode.setParent(omParent);
+ }
+
+ /**
+ * Method getParentElement
+ * @see javax.xml.soap.Node#getParentElement()
+ */
+ public SOAPElement getParentElement() {
+
+ OMElement omParent = omNode.getParent();
+ return new SOAPElementImpl(omParent);
+ }
+
+ /**
+ * Method detachNode
+ * @see javax.xml.soap.Node#detachNode()
+ */
+ public void detachNode() {
+
+ omNode.detach();
+ }
+
+ /**
+ * Method recycleNode
+ * @see javax.xml.soap.Node#recycleNode()
+ */
+ public void recycleNode() {
+ // No corresponding implementation in OM
+ // There is no implementation in Axis 1.2 also
+
+ }
+
+ /**
+ * Method setValue
+ * @param value
+ *
+ * @see javax.xml.soap.Node#setValue(java.lang.String)
+ */
+ public void setValue(String value) {
+
+ if(omNode.getType() == OMNode.TEXT_NODE){
+ OMElement parent = omNode.getParent();
+ ((OMText)omNode).discard();
+ omNode = org.apache.axis.om.OMAbstractFactory.getOMFactory().createText(parent, value);
+ } else if(omNode.getType() == OMNode.ELEMENT_NODE){
+ OMNode firstChild = ((OMElement)omNode).getFirstChild();
+ if(firstChild == null ){
+ firstChild = org.apache.axis.om.OMAbstractFactory.getOMFactory().createText((OMElement)omNode, value);
+ }
+ else if(firstChild.getType() == OMNode.TEXT_NODE){
+ ((OMText)firstChild).discard();
+ firstChild = org.apache.axis.om.OMAbstractFactory.getOMFactory().createText((OMElement)omNode, value);
+ }
+ } else{
+ throw new IllegalStateException();
+ }
+ }
+
+ /**
+ * Method getNodeType
+ * @see org.w3c.dom.Node#getNodeType()
+ */
+ public short getNodeType() {
+
+ return (short)omNode.getType();
+ }
+
+ /**
+ * Method normalize
+ * @see org.w3c.dom.Node#normalize()
+ */
+ public void normalize() {
+ // No corresponding function in OM
+ //Axis 1.2 also doesn't have any implementation for this
+
+ }
+
+ /**
+ * Method hasAttributes
+ * @see org.w3c.dom.Node#hasAttributes()
+ */
+ public boolean hasAttributes() {
+ if(omNode instanceof OMElement){
+ Iterator iter = ((OMElement)omNode).getAttributes();
+ return (iter.hasNext() ? true : false);
+ }
+ return false;
+ }
+
+ /**
+ * Method hasChildNodes
+ * @see org.w3c.dom.Node#hasChildNodes()
+ */
+ public boolean hasChildNodes() {
+ if(omNode instanceof OMElement){
+ Iterator iter = ((OMElement)omNode).getChildren();
+ return (iter.hasNext() ? true : false);
+ }
+ return false;
+ }
+
+ /**
+ * Method getLocalName
+ * @see org.w3c.dom.Node#getLocalName()
+ */
+ public String getLocalName() {
+ if(omNode.getType() == ELEMENT_NODE || omNode.getType()
+ == ATTRIBUTE_NODE)
+ return ((OMElement)omNode).getLocalName();
+ // TODO: else if(omNode.getType() == ATTRIBUTE_NODE)
+ // return some
+ return null;
+ }
+
+ /**
+ * Method getNamespaceURI
+ * @see org.w3c.dom.Node#getNamespaceURI()
+ */
+ public String getNamespaceURI() {
+
+ return ((OMElement)omNode).getNamespace().getName();
+ }
+
+ /**
+ * Method getNodeName
+ * @see org.w3c.dom.Node#getNodeName()
+ */
+ public String getNodeName() {
+
+ if(omNode.getType() == OMNode.ELEMENT_NODE )
+ return ((OMElement)omNode).getLocalName();
+ else if(omNode.getType() == OMNode.COMMENT_NODE)
+ return "#comment";
+ else if(omNode.getType() == OMNode.CDATA_SECTION_NODE)
+ return "#cdata-section";
+ else if(omNode.getType() == OMNode.TEXT_NODE)
+ return "#text";
+ //TODO else if Attribute Node so something
+ // return attribute name
+ return null;
+ }
+
+ /**
+ * Method getNodeValue
+ * @see org.w3c.dom.Node#getNodeValue()
+ */
+ public String getNodeValue() throws DOMException {
+ // Returns text for a TEXT_NODE, null otherwise
+ if(omNode.getType() == OMNode.TEXT_NODE)
+ return ((OMText)omNode).getText();
+ //TODO else if(omNode.getType() == Attribute)
+ else
+ return null;
+ }
+
+ /**
+ * Method getPrefix
+ * @see org.w3c.dom.Node#getPrefix()
+ */
+ public String getPrefix() {
+ if(omNode.getType() == OMNode.ELEMENT_NODE)
+ return ((OMElement)omNode).getNamespace().getPrefix();
+ return null;
+ }
+
+ /**
+ * Method setNodeValue
+ * @see org.w3c.dom.Node#setNodeValue(java.lang.String)
+ */
+ public void setNodeValue(String value) throws DOMException {
+
+ if(omNode.getType() == OMNode.TEXT_NODE){
+ OMElement parent = omNode.getParent();
+ ((OMText)omNode).discard();
+ omNode = org.apache.axis.om.OMAbstractFactory.getOMFactory().createText(parent, value);
+ }
+ }
+
+ /**
+ * Method setPrefix
+ * @see org.w3c.dom.Node#setPrefix(java.lang.String)
+ */
+ public void setPrefix(String prefix) throws DOMException {
+ //TODO - Do for attribute Node
+ if(omNode.getType() == OMNode.ELEMENT_NODE /*|| Attribute Node*/){
+ OMNamespace ns = ((OMElement)omNode).getNamespace();
+ String uri = ns.getName();
+ OMNamespace newNs = org.apache.axis.om.OMAbstractFactory.getOMFactory().createOMNamespace(uri, prefix);
+ ((OMElement)omNode).setNamespace(newNs);
+ }
+
+ }
+
+ /**
+ * Method setOwnerDocument
+ * @param doc
+ */
+ public void setOwnerDocument(Document doc){
+ // method not part of org.w3c.dom.Node, created to set the document
+ this.document = doc;
+ }
+
+ /**
+ * Method getOwnerDocument
+ * @see org.w3c.dom.Node#getOwnerDocument()
+ */
+ public Document getOwnerDocument() {
+ // return the set document
+ return document;
+ }
+
+ /**
+ * Method getAttributes
+ * @see org.w3c.dom.Node#getAttributes()
+ */
+ public NamedNodeMap getAttributes() {
+ // Will have to provide an implementation of NamedNodeMap
+ // Dropping for now
+ // TODO
+ Iterator iter = ((OMElement)omNode).getAttributes();
+
+ return null;
+ }
+
+ /**
+ * Method getFirstChild
+ * @see org.w3c.dom.Node#getFirstChild()
+ */
+ public org.w3c.dom.Node getFirstChild() {
+ //
+ OMNode child = ((OMElement)omNode).getFirstChild();
+ return new NodeImpl(child);
+ }
+
+ /**
+ * Method getLastChild
+ * @see org.w3c.dom.Node#getLastChild()
+ */
+ public org.w3c.dom.Node getLastChild() {
+
+ Iterator children = ((OMElement)omNode).getChildren();
+ Object child = null;
+ while(children.hasNext()){
+ child = children.next();
+ }
+ if(child instanceof OMNode){
+ return new NodeImpl((OMNode)child);
+ }
+ return null;
+ }
+
+ /**
+ * dom Node method
+ */
+ public org.w3c.dom.Node getNextSibling() {
+
+ OMNode sibling = omNode.getNextSibling();
+ return new NodeImpl(sibling);
+ }
+
+
+ public org.w3c.dom.Node getParentNode() {
+
+ OMElement parent = omNode.getParent();
+ return new NodeImpl(parent);
+ }
+
+ /**
+ * dom Node method
+ */
+ public org.w3c.dom.Node getPreviousSibling() {
+
+ OMNode prevSibling = omNode.getPreviousSibling();
+ return new NodeImpl(prevSibling);
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Node#cloneNode(boolean)
+ */
+ public org.w3c.dom.Node cloneNode(boolean deep) {
+ //TODO
+ return null;
+ }
+
+ /**
+ * DOM Node method
+ */
+ public NodeList getChildNodes() {
+ Iterator iter = ((OMElement)omNode).getChildren();
+ NodeListImpl list = new NodeListImpl();
+ while(iter.hasNext()){
+ OMNode omChild = (OMNode)iter.next();
+ Node child = new NodeImpl(omChild);
+ list.addNode(child);
+ }
+ return list;
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Node#isSupported(java.lang.String, java.lang.String)
+ */
+ public boolean isSupported(String arg0, String arg1) {
+ //TODO: Not implemented in 1.2 as well
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Node#appendChild(org.w3c.dom.Node)
+ */
+ public org.w3c.dom.Node appendChild(org.w3c.dom.Node node)
+ throws DOMException {
+
+ OMNode child = Dom2OmUtils.toOM(node);
+ if(omNode.getType() == OMNode.ELEMENT_NODE)
+ ((OMElement)omNode).addChild(child);
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Node#removeChild(org.w3c.dom.Node)
+ */
+ public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
+ throws DOMException {
+ //Check if equals method has been removed from OMNode
+ OMNode child = Dom2OmUtils.toOM(oldChild);
+ if(omNode.getType() == OMNode.ELEMENT_NODE){
+ Iterator iter = ((OMElement)omNode).getChildren();
+ while(iter.hasNext()){
+ Object nextChild = iter.next();
+ if(nextChild instanceof OMNode && nextChild.equals(child)){
+ ((OMElement)nextChild).discard();
+ return oldChild;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @see org.w3c.dom.Node#insertBefore(org.w3c.dom.Node, org.w3c.dom.Node)
+ */
+ public org.w3c.dom.Node insertBefore(org.w3c.dom.Node arg0,
+ org.w3c.dom.Node arg1) throws DOMException {
+
+ return null;
+ }
+
+ /**
+ * @see org.w3c.dom.Node#replaceChild(org.w3c.dom.Node, org.w3c.dom.Node)
+ */
+ public org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild,
+ org.w3c.dom.Node refChild) throws DOMException {
+ OMNode newOmChild = Dom2OmUtils.toOM(newChild);
+ OMNode refOmChild = Dom2OmUtils.toOM(refChild);
+ if(omNode.getType() == OMNode.ELEMENT_NODE){
+ Iterator iter = ((OMElement)omNode).getChildren();
+ while(iter.hasNext()){
+ Object nextChild = iter.next();
+ if(nextChild instanceof OMNode && nextChild.equals(refOmChild)){
+
+ }
+ }
+ }
+ return null;
+ }
+
+ public boolean equals(Object o){
+ if(o instanceof NodeImpl){
+ if(this.omNode.equals(((NodeImpl)o).omNode))
+ return true;
+ }
+ return false;
+ }
+
+}
Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/NodeListImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/NodeListImpl.java?rev=179794&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/NodeListImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/NodeListImpl.java Fri Jun 3 07:08:11 2005
@@ -0,0 +1,69 @@
+/*
+ * Created on Apr 11, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.axis.saaj;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.util.List;
+import java.util.Collections;
+import java.util.ArrayList;
+
+/**
+ * @author Ashutosh Shahi
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class NodeListImpl implements NodeList {
+
+ List mNodes;
+
+ public static final NodeList EMPTY_NODELIST = new NodeListImpl(Collections.EMPTY_LIST);
+
+ /**
+ * Constructor and Setter is intensionally made package access only.
+ *
+ */
+ NodeListImpl() {
+ mNodes = new ArrayList();
+ }
+
+ NodeListImpl(List nodes) {
+ this();
+ mNodes.addAll(nodes);
+ }
+
+ void addNode(org.w3c.dom.Node node) {
+ mNodes.add(node);
+ }
+
+ void addNodeList(org.w3c.dom.NodeList nodes) {
+ for (int i = 0; i < nodes.getLength(); i++) {
+ mNodes.add(nodes.item(i));
+ }
+ }
+
+ /**
+ * Interface Implemented
+ *
+ * @param index
+ * @return
+ */
+ public Node item(int index) {
+ if (mNodes != null && mNodes.size() > index) {
+ return (Node) mNodes.get(index);
+ } else {
+ return null;
+ }
+ }
+
+ public int getLength() {
+ return mNodes.size();
+ }
+
+}
Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/PrefixedQName.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/PrefixedQName.java?rev=179794&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/PrefixedQName.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/PrefixedQName.java Fri Jun 3 07:08:11 2005
@@ -0,0 +1,123 @@
+/*
+ * Created on Mar 15, 2005
+ *
+ */
+package org.apache.axis.saaj;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.Name;
+
+/**
+ * Class Prefixed QName
+ *
+ * Took this implementation from Axis 1.2 code
+ */
+public class PrefixedQName implements Name {
+ /** comment/shared empty string */
+ private static final String emptyString = "".intern();
+
+ /**
+ * Field prefix
+ */
+ private String prefix;
+ /**
+ * Field qName
+ */
+ private QName qName;
+
+ /**
+ * Constructor PrefixedQName
+ * @param uri
+ * @param localName
+ * @param pre
+ */
+ public PrefixedQName(String uri, String localName, String pre) {
+ qName = new QName(uri, localName);
+ prefix = (pre == null)
+ ? emptyString
+ : pre.intern();
+ }
+
+ /**
+ * Constructor qname
+ * @param qname
+ * @return
+ */
+ public PrefixedQName(QName qname) {
+ this.qName = qname;
+ prefix = emptyString;
+ }
+
+ /**
+ * Method getLocalName
+ * @return
+ */
+ public String getLocalName() {
+ return qName.getLocalPart();
+ }
+
+ /**
+ * Method getQualifiedName
+ * @return
+ */
+ public String getQualifiedName() {
+ StringBuffer buf = new StringBuffer(prefix);
+ if(prefix != emptyString)
+ buf.append(':');
+ buf.append(qName.getLocalPart());
+ return buf.toString();
+ }
+
+ /**
+ * Method getURI
+ * @return
+ */
+ public String getURI() {
+ return qName.getNamespaceURI();
+ }
+
+ /**
+ * Method getPrefix
+ * @return
+ */
+ public String getPrefix() {
+ return prefix;
+ }
+
+ /**
+ * Method equals
+ * @param obj
+ * @return
+ */
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof PrefixedQName)) {
+ return false;
+ }
+ if (!qName.equals(((PrefixedQName)obj).qName)) {
+ return false;
+ }
+ if (prefix == ((PrefixedQName) obj).prefix) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Method hasCode
+ * @return
+ */
+ public int hashCode() {
+ return prefix.hashCode() + qName.hashCode();
+ }
+
+ /**
+ * Method toString
+ * @return
+ */
+ public String toString() {
+ return qName.toString();
+ }
+}
Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPBodyElementImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPBodyElementImpl.java?rev=179794&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPBodyElementImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPBodyElementImpl.java Fri Jun 3 07:08:11 2005
@@ -0,0 +1,36 @@
+/*
+ * Created on Mar 16, 2005
+ *
+ */
+package org.apache.axis.saaj;
+
+import javax.xml.soap.SOAPBodyElement;
+
+import org.apache.axis.om.OMElement;
+
+/**
+ * Class SOAPBodeElementImpl
+ *
+ * @author Ashutosh Shahi
+ * ashutosh.shahi@gmail.com
+ */
+public class SOAPBodyElementImpl extends SOAPElementImpl implements
+ SOAPBodyElement {
+
+ /**
+ * Constructor SOAPBodeElementImpl
+ *
+ */
+ public SOAPBodyElementImpl(){
+ super();
+ }
+
+ /**
+ * Constructor SOAPBodeElementImpl
+ * @param bodyElement
+ */
+ public SOAPBodyElementImpl(OMElement bodyElement){
+ super(bodyElement);
+ }
+
+}
Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPBodyImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPBodyImpl.java?rev=179794&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPBodyImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPBodyImpl.java Fri Jun 3 07:08:11 2005
@@ -0,0 +1,173 @@
+/*
+ * Created on Mar 16, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.axis.saaj;
+
+import java.util.Locale;
+
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPBodyElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFault;
+
+import org.w3c.dom.Document;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMFactory;
+import org.apache.axis.soap.SOAPFactory;
+import org.apache.axis.om.OMAbstractFactory;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Class SOAPBodeImpl
+ *
+ * @author Jayachandra
+ * jayachandra@gmail.com
+ */
+public class SOAPBodyImpl extends SOAPElementImpl implements SOAPBody {
+ /**
+ * Field omSOAPBody
+ * omSOAPBody is the OM's SOAPBody object that is used for delegation purpose
+ */
+ private org.apache.axis.soap.SOAPBody omSOAPBody;
+
+ /**
+ * Constructor SOAPBodeImpl
+ * The constructor to facilitate conversion of SAAJ SOAPBody out of OM SOAPBody
+ * @param omSoapBody
+ */
+ public SOAPBodyImpl(org.apache.axis.soap.SOAPBody omSoapBody)
+ {
+ super(omSoapBody);
+ this.omSOAPBody = omSoapBody;
+ }
+
+ /**
+ * Method addFault
+ * @see javax.xml.soap.SOAPBody#addFault()
+ * @return
+ * @throws SOAPException
+ */
+ public SOAPFault addFault() throws SOAPException {
+ try{
+ //OM SOAPFaultImpl has SOAPFaultImpl(OMElement parent, Exception e) constructor, will use that
+ SOAPFactory soapFactory = OMAbstractFactory.getDefaultSOAPFactory();
+ org.apache.axis.soap.SOAPFault omSoapFault = soapFactory.createSOAPFault(omSOAPBody, new Exception("No explicit faultstring available"));
+ omSOAPBody.addFault(omSoapFault);
+ return (new SOAPFaultImpl(omSoapFault));
+ }catch(Exception e)
+ {
+ throw new SOAPException(e);
+ }
+ }
+
+ /**
+ * Method hasFault
+ * @see javax.xml.soap.SOAPBody#hasFault()
+ * @return
+ */
+ public boolean hasFault() {
+ return omSOAPBody.hasFault();
+ }
+
+ /**
+ * Method getFault
+ * @see javax.xml.soap.SOAPBody#getFault()
+ * @return
+ */
+ public SOAPFault getFault() {
+ return (new SOAPFaultImpl(omSOAPBody.getFault()));
+ }
+
+ /**
+ * Method addBodyElement
+ * @param name
+ * @return
+ * @throws SOAPException
+ * @see javax.xml.soap.SOAPBody#addBodyElement(javax.xml.soap.Name)
+ */
+ public SOAPBodyElement addBodyElement(Name name) throws SOAPException {
+
+ try {
+ OMFactory omFactory = OMAbstractFactory.getOMFactory();
+ QName qname = new QName(name.getURI(), name.getLocalName(), name.getPrefix());
+ OMElement bodyElement = omFactory.createOMElement(qname, omSOAPBody);
+ omSOAPBody.addChild(bodyElement);
+ return (new SOAPBodyElementImpl(bodyElement));
+ } catch (Exception e)
+ {
+ throw new SOAPException(e);
+ }
+ }
+
+ /**
+ * Method addFault
+ * @param faultCode
+ * @param faultString
+ * @param
+ * @throws SOAPException
+ * @see javax.xml.soap.SOAPBody#addFault(javax.xml.soap.Name, java.lang.String, java.util.Locale)
+ */
+ public SOAPFault addFault(Name faultCode, String faultString, Locale locale)
+ throws SOAPException {
+ try{
+ //OM SOAPFaultImpl has SOAPFaultImpl(OMElement parent, Exception e) constructor, will use that
+ //actually soap fault is created with the OM's default SOAPFAULT_LOCALNAME and PREFIX, b'coz I've droppe the name param
+ //a work around can be possible but would be confusing as there is no straight forward soapfault constructor in om.
+ //So am deferring it.
+ //even locale param is dropped, don't know how to handle it at the moment. so dropped it.
+ SOAPFactory soapFactory = OMAbstractFactory.getDefaultSOAPFactory();
+ org.apache.axis.soap.SOAPFault omSoapFault = soapFactory.createSOAPFault(omSOAPBody, new Exception(faultString));
+ omSOAPBody.addFault(omSoapFault);
+ return (new SOAPFaultImpl(omSoapFault));
+ }catch(Exception e)
+ {
+ throw new SOAPException(e);
+ }
+ }
+
+ /**
+ * Method addFault
+ * @param faultCode
+ * @param faultString
+ * @return
+ * @throws SOAPException
+ * @see javax.xml.soap.SOAPBody#addFault(javax.xml.soap.Name, java.lang.String)
+ */
+ public SOAPFault addFault(Name faultCode, String faultString)
+ throws SOAPException {
+ try{
+ //OM SOAPFaultImpl has SOAPFaultImpl(OMElement parent, Exception e) constructor, will use that
+ //actually soap fault is created with the OM's default SOAPFAULT_LOCALNAME and PREFIX, b'coz I've droppe the name param
+ //a work around can be possible but would be confusing as there is no straight forward soapfault constructor in om.
+ //So am deferring it.
+ SOAPFactory soapFactory = OMAbstractFactory.getDefaultSOAPFactory();
+ org.apache.axis.soap.SOAPFault omSoapFault = soapFactory.createSOAPFault(omSOAPBody, new Exception(faultString));
+ omSOAPBody.addFault(omSoapFault);
+ return (new SOAPFaultImpl(omSoapFault));
+ }catch(Exception e)
+ {
+ throw new SOAPException(e);
+ }
+ }
+
+ /**
+ * Method addDocument
+ * @param document
+ * @return
+ * @throws SOAPException
+ * @see javax.xml.soap.SOAPBody#addDocument(org.w3c.dom.Document)
+ */
+ public SOAPBodyElement addDocument(Document document) throws SOAPException {
+ /*
+ * Don't know how to resolve this as yet. So deferring it.
+ */
+ return null;
+ }
+
+}
Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPConnectionFactoryImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPConnectionFactoryImpl.java?rev=179794&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPConnectionFactoryImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPConnectionFactoryImpl.java Fri Jun 3 07:08:11 2005
@@ -0,0 +1,32 @@
+/*
+ * Created on Mar 23, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.axis.saaj;
+
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPConnectionFactory;
+import javax.xml.soap.SOAPException;
+
+/**
+ * Class SOAPConnectionFactoryImpl
+ *
+ * @author Ashutosh Shahi
+ * ashutosh.shahi@gmail.com
+ */
+public class SOAPConnectionFactoryImpl extends SOAPConnectionFactory {
+
+ /**
+ * Create a new <CODE>SOAPConnection</CODE>.
+ * @return the new <CODE>SOAPConnection</CODE> object.
+ * @throws SOAPException if there was an exception
+ * creating the <CODE>SOAPConnection</CODE> object.
+ */
+ public SOAPConnection createConnection() throws SOAPException {
+
+ return new SOAPConnectionImpl();
+ }
+
+}
Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPConnectionImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPConnectionImpl.java?rev=179794&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPConnectionImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPConnectionImpl.java Fri Jun 3 07:08:11 2005
@@ -0,0 +1,62 @@
+/*
+ * Created on Mar 23, 2005
+ *
+ */
+package org.apache.axis.saaj;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPEnvelope;
+
+import org.apache.axis.Constants;
+import org.apache.axis.addressing.AddressingConstants;
+import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.clientapi.Call;
+import org.apache.axis.engine.AxisFault;
+
+
+/**
+ * Class SOAPConnectionImpl
+ *
+ * @author Ashutosh Shahi (ashutosh.shahi@gmail.com)
+ *
+ */
+public class SOAPConnectionImpl extends SOAPConnection {
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPConnection#call(javax.xml.soap.SOAPMessage, java.lang.Object)
+ */
+ public SOAPMessage call(SOAPMessage request, Object endpoint)
+ throws SOAPException {
+ try{
+ org.apache.axis.soap.SOAPEnvelope envelope = ((SOAPEnvelopeImpl)request.getSOAPPart().getEnvelope()).getOMEnvelope();
+
+ Call call = new Call();
+ URL url = new URL(endpoint.toString());
+ call.setTransportInfo(Constants.TRANSPORT_HTTP,Constants.TRANSPORT_HTTP, true);
+ call.setTo(new EndpointReference(AddressingConstants.WSA_TO, url.toString()));
+ org.apache.axis.soap.SOAPEnvelope responseEnv = (org.apache.axis.soap.SOAPEnvelope)call.invokeBlocking("echo", envelope);
+ SOAPEnvelopeImpl response = new SOAPEnvelopeImpl(responseEnv);
+ return new SOAPMessageImpl(response);
+
+ }catch (MalformedURLException mue) {
+ throw new SOAPException(mue);
+ }catch (AxisFault af){
+ throw new SOAPException(af);
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPConnection#close()
+ */
+ public void close() throws SOAPException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPDocumentImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPDocumentImpl.java?rev=179794&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPDocumentImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPDocumentImpl.java Fri Jun 3 07:08:11 2005
@@ -0,0 +1,402 @@
+/*
+ * Created on Apr 11, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.axis.saaj;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.CDATASection;
+import org.w3c.dom.Comment;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.Element;
+import org.w3c.dom.EntityReference;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.ProcessingInstruction;
+import org.w3c.dom.Text;
+
+import org.apache.axis.util.XMLUtils;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.soap.SOAPException;
+
+/**
+ * @author Ashutosh Shahi ashutosh.shahi@gmail.com
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class SOAPDocumentImpl implements Document {
+
+ // Depending on the user's parser preference
+ protected Document delegate = null;
+ protected SOAPPartImpl soapPart = null;
+
+ /**
+ * Construct the Document
+ *
+ * @param sp the soap part
+ */
+ public SOAPDocumentImpl(SOAPPartImpl sp) {
+ try {
+ delegate = XMLUtils.newDocument();
+ } catch (ParserConfigurationException e) {
+ // Do nothing
+ }
+ soapPart = sp;
+ }
+
+ public DOMImplementation getImplementation() {
+ return delegate.getImplementation();
+ }
+
+ /**
+ *
+ * Creates an empty <code>DocumentFragment</code> object. @todo not
+ * implemented yet
+ *
+ * @return A new <code>DocumentFragment</code>.
+ */
+ public DocumentFragment createDocumentFragment() {
+ return delegate.createDocumentFragment();
+ }
+
+ /**
+ * @todo : link with SOAP
+ *
+ * @return
+ */
+ public DocumentType getDoctype() {
+ return delegate.getDoctype();
+ }
+
+ /**
+ * should not be called, the method will be handled in SOAPPart
+ *
+ * @return
+ */
+ public Element getDocumentElement() {
+ return soapPart.getDocumentElement();
+ }
+
+ /**
+ * @todo: How Axis will maintain the Attribute representation ?
+ */
+ public Attr createAttribute(String name) throws DOMException {
+ return delegate.createAttribute(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Document#createCDATASection(java.lang.String)
+ */
+ public CDATASection createCDATASection(String arg0) throws DOMException {
+ // Not implementing this one, as it may not be supported in om
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Document#createComment(java.lang.String)
+ */
+ public Comment createComment(String arg0) {
+ //Not implementing this one, as it may not be supported in om
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Document#createElement(java.lang.String)
+ */
+ public Element createElement(String arg0) throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Element getElementById(String elementId) {
+ return delegate.getElementById(elementId);
+ }
+
+
+ /**
+ * @param name
+ * @return @throws
+ * DOMException
+ */
+ public EntityReference createEntityReference(String name)
+ throws DOMException {
+ throw new java.lang.UnsupportedOperationException(
+ "createEntityReference");
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Document#importNode(org.w3c.dom.Node, boolean)
+ */
+ public Node importNode(Node arg0, boolean arg1) throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Document#getElementsByTagName(java.lang.String)
+ */
+ public NodeList getElementsByTagName(String localName) {
+ try{
+ NodeListImpl list = new NodeListImpl();
+ if (soapPart != null) {
+ SOAPEnvelopeImpl soapEnv = (SOAPEnvelopeImpl)soapPart.getEnvelope();
+ SOAPHeaderImpl header = (SOAPHeaderImpl)soapEnv.getHeader();
+ if (header != null) {
+ list.addNodeList(header.getElementsByTagName(localName));
+ }
+ SOAPBodyImpl body = (SOAPBodyImpl)soapEnv.getBody();
+ if (body != null) {
+ list.addNodeList(body.getElementsByTagName(localName));
+ }
+ }
+ return list;
+ }catch (SOAPException se) {
+ throw new DOMException(DOMException.INVALID_STATE_ERR, "");
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Document#createTextNode(java.lang.String)
+ */
+ public Text createTextNode(String data) {
+ TextImpl me = new TextImpl(delegate.createTextNode(data));
+ me.setOwnerDocument(soapPart);
+ return me;
+ }
+
+ /**
+ * Attribute is not particularly dealt with in SAAJ.
+ *
+ */
+ public Attr createAttributeNS(String namespaceURI, String qualifiedName)
+ throws DOMException {
+ return delegate.createAttributeNS(namespaceURI, qualifiedName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Document#createElementNS(java.lang.String, java.lang.String)
+ */
+ public Element createElementNS(String arg0, String arg1)
+ throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Document#getElementsByTagNameNS(java.lang.String, java.lang.String)
+ */
+ public NodeList getElementsByTagNameNS(String namespaceURI, String localName) {
+ try{
+ NodeListImpl list = new NodeListImpl();
+ if (soapPart != null) {
+ SOAPEnvelopeImpl soapEnv = (SOAPEnvelopeImpl)soapPart.getEnvelope();
+ SOAPHeaderImpl header = (SOAPHeaderImpl)soapEnv.getHeader();
+ if (header != null) {
+ list.addNodeList(header.getElementsByTagNameNS(namespaceURI, localName));
+ }
+ SOAPBodyImpl body = (SOAPBodyImpl)soapEnv.getBody();
+ if (body != null) {
+ list.addNodeList(body.getElementsByTagNameNS(namespaceURI, localName));
+ }
+ }
+ return list;
+ }catch (SOAPException se) {
+ throw new DOMException(DOMException.INVALID_STATE_ERR, "");
+ }
+ }
+
+
+ public ProcessingInstruction createProcessingInstruction(
+ String target,
+ String data)
+ throws DOMException {
+ throw new java.lang.UnsupportedOperationException(
+ "createProcessingInstruction");
+ }
+
+
+ /**
+ * override it in sub-classes
+ *
+ * @return
+ */
+ public short getNodeType() {
+ return Node.DOCUMENT_NODE;
+ }
+
+
+ public void normalize() {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "");
+ }
+
+
+ public boolean hasAttributes() {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "");
+ }
+
+ public boolean hasChildNodes() {
+ try {
+ if (soapPart != null) {
+ if (soapPart.getEnvelope() != null) {
+ return true;
+ }
+ }
+ return false;
+ } catch (SOAPException se) {
+ throw new DOMException(DOMException.INVALID_STATE_ERR, "");
+ }
+ }
+
+ public String getLocalName() {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "");
+ }
+
+ public String getNamespaceURI() {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "");
+ }
+
+
+ public String getNodeName() {
+ return null;
+ }
+
+ public String getNodeValue() throws DOMException {
+ throw new DOMException(
+ DOMException.NO_DATA_ALLOWED_ERR,
+ "Cannot use TextNode.get in " + this);
+ }
+
+ public String getPrefix() {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "");
+ }
+
+ public void setNodeValue(String nodeValue) throws DOMException {
+ throw new DOMException(
+ DOMException.NO_DATA_ALLOWED_ERR,
+ "Cannot use TextNode.set in " + this);
+ }
+
+
+ public void setPrefix(String prefix) {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "");
+ }
+
+ /**
+ *
+ * we have to have a link to them...
+ */
+ public Document getOwnerDocument() {
+ return null;
+ }
+
+ public NamedNodeMap getAttributes() {
+ return null;
+ }
+
+ public Node getFirstChild() {
+ try {
+ if (soapPart != null)
+ return (org.apache.axis.saaj.SOAPEnvelopeImpl) soapPart
+ .getEnvelope();
+ else
+ return null;
+ } catch (SOAPException se) {
+ throw new DOMException(DOMException.INVALID_STATE_ERR, "");
+ }
+ }
+
+ public Node getLastChild() {
+ try {
+ if (soapPart != null)
+ return (org.apache.axis.saaj.SOAPEnvelopeImpl) soapPart
+ .getEnvelope();
+ else
+ return null;
+ } catch (SOAPException se) {
+ throw new DOMException(DOMException.INVALID_STATE_ERR, "");
+ }
+ }
+
+ public Node getNextSibling() {
+
+ return null;
+ }
+
+ public Node getParentNode() {
+ return null;
+ }
+
+ public Node getPreviousSibling() {
+ return null;
+ }
+
+ public Node cloneNode(boolean deep) {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "");
+ }
+
+
+ public NodeList getChildNodes() {
+ try {
+ if (soapPart != null) {
+ NodeListImpl children = new NodeListImpl();
+ children.addNode(soapPart.getEnvelope());
+ return children;
+ } else {
+ return NodeListImpl.EMPTY_NODELIST;
+ }
+ } catch (SOAPException se) {
+ throw new DOMException(DOMException.INVALID_STATE_ERR, "");
+ }
+
+ }
+
+ // fill appropriate features
+ private String[] features = { "foo", "bar" };
+ private String version = "version 2.0";
+
+ public boolean isSupported(String feature, String version) {
+ if (!version.equalsIgnoreCase(version))
+ return false;
+ else
+ return true;
+ }
+
+ public Node appendChild(Node newChild) throws DOMException {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "");
+ }
+
+ public Node removeChild(Node oldChild) throws DOMException {
+ try {
+ Node envNode;
+ if (soapPart != null) {
+ envNode = soapPart.getEnvelope();
+ if (envNode.equals(oldChild)) {
+ return envNode;
+ }
+ }
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "");
+ } catch (SOAPException se) {
+ throw new DOMException(DOMException.INVALID_STATE_ERR, "");
+ }
+ }
+
+ public Node insertBefore(Node newChild, Node refChild)
+ throws DOMException {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "");
+ }
+
+ public Node replaceChild(Node newChild, Node oldChild)
+ throws DOMException {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "");
+ }
+
+
+}
Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPElementImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPElementImpl.java?rev=179794&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPElementImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/org/apache/axis/saaj/SOAPElementImpl.java Fri Jun 3 07:08:11 2005
@@ -0,0 +1,730 @@
+/*
+ * Created on Mar 17, 2005
+ *
+ */
+package org.apache.axis.saaj;
+
+import java.util.Iterator;
+
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.NodeList;
+
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+/**
+ * Class SOAPElementImpl
+ *
+ * @author Jayachandra
+ * jayachandra@gmail.com
+ */
+public class SOAPElementImpl extends NodeImpl implements SOAPElement {
+ /**
+ * Field omElement
+ * The corresponding OM object for SOAPElement is OMElement, so we would
+ * have a datamember of type OMElement in this class
+ */
+ protected org.apache.axis.om.OMElement omElement;
+
+ /**
+ * Constructor SOAPElementImpl
+ * The standard constructor for being able to create SOAPElement given a omElement
+ * @param omElement
+ */
+ public SOAPElementImpl(org.apache.axis.om.OMElement omElement)
+ {
+ super(omElement);
+ this.omElement = omElement;
+ }
+
+ /**
+ * Constructor SOAPElementImpl
+ * The empty constructor
+ */
+ public SOAPElementImpl() {
+ super();
+ }
+
+ /**
+ * Method getOMElement
+ * getter method on the data member omElement
+ * @return
+ */
+ public org.apache.axis.om.OMElement getOMElement() {
+ return this.omElement;
+ }
+
+ /**
+ * Method addChildElement
+ * @param name
+ * @return SOAPElement
+ * @throws SOAPException
+ * @see javax.xml.soap.SOAPElement#addChildElement(javax.xml.soap.Name)
+ */
+ public SOAPElement addChildElement(Name name) throws SOAPException {
+ //We will create a new OMElement and add that as a child to the OMElement datamember that
+ //we are carrying along. And return back a wrapped SOAPElement corresponding to the
+ //created OMElement
+
+ //Since a <code>Name</code> object is given as parameter we should try to create an OMElement
+ //and register it with the contents of the <code>name</code> element
+ org.apache.axis.om.OMElement newOMElement = org.apache.axis.om.OMAbstractFactory.getOMFactory().createOMElement(new QName(name.getURI(), name.getLocalName(), name.getPrefix()), omElement);
+ omElement.addChild(newOMElement);
+ return new SOAPElementImpl(newOMElement);
+ }
+
+ /**
+ * Method addChildElement
+ * @param localName
+ * @return
+ * @throws SOAPException
+ * @see javax.xml.soap.SOAPElement#addChildElement(java.lang.String)
+ */
+ public SOAPElement addChildElement(String localName) throws SOAPException {
+ //We will create a new OMElement and add that as a child to the OMElement datamember that
+ //we are carrying along. And return back a wrapped SOAPElement corresponding to the
+ //created OMElement
+ org.apache.axis.om.OMElement newOMElement = org.apache.axis.om.OMAbstractFactory.getOMFactory().createOMElement(new QName(localName), omElement);
+ omElement.addChild(newOMElement);
+ return new SOAPElementImpl(newOMElement);
+ }
+
+ /**
+ * Method addChildElement
+ * @param localName
+ * @param prefix
+ * @return
+ * @throws SOAPException
+ * @see javax.xml.soap.SOAPElement#addChildElement(java.lang.String, java.lang.String)
+ */
+ public SOAPElement addChildElement(String localName, String prefix)
+ throws SOAPException {
+ org.apache.axis.om.OMElement newOMElement = org.apache.axis.om.OMAbstractFactory.getOMFactory().createOMElement(new QName(null,localName,prefix), omElement);
+ omElement.addChild(newOMElement);
+ return new SOAPElementImpl(newOMElement);
+ }
+
+ /**
+ * Method addChildElement
+ * @param localName
+ * @param prefix
+ * @return
+ * @throws SOAPException
+ * @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 {
+ org.apache.axis.om.OMElement newOMElement = org.apache.axis.om.OMAbstractFactory.getOMFactory().createOMElement(new QName(uri,localName,prefix), omElement);
+ omElement.addChild(newOMElement);
+ return new SOAPElementImpl(newOMElement);
+ }
+
+ /**
+ * Method addChildElement
+ * @param element
+ * @return
+ * @throws SOAPException
+ * @see javax.xml.soap.SOAPElement#addChildElement(javax.xml.soap.SOAPElement)
+ */
+ public SOAPElement addChildElement(SOAPElement element)
+ throws SOAPException {
+ //TODO:
+ //The fragment rooted in element is either added as a whole or not at all, if there was an error.
+ //The fragment rooted in element cannot contain elements named Envelope, Header or Body
+ //and in the SOAP namespace. Any namespace prefixes present in the fragment should be fully
+ //resolved using appropriate namespace declarations within the fragment itself.
+
+ org.apache.axis.om.OMElement omElementToAdd = ((SOAPElementImpl)element).getOMElement();
+ omElementToAdd.setParent(omElement);
+ omElement.addChild(omElementToAdd);
+ return new SOAPElementImpl(omElementToAdd);
+ }
+
+ /**
+ * Method addTextNode
+ * @param text
+ * @return
+ * @throws SOAPException
+ * @see javax.xml.soap.SOAPElement#addTextNode(java.lang.String)
+ */
+ public SOAPElement addTextNode(String text) throws SOAPException {
+ //We need to create an OMText node and add that to
+ //the omElement delegate member that we have with us. All this OMElement's setText() does
+ omElement.setText(text);
+ return this;
+ }
+
+ /**
+ * Method addAttribute
+ * This method adds an attribute to the underlying omElement datamember and returns ourselves
+ * @param name
+ * @param value
+ * @return ourself
+ * @throws SOAPException
+ * @see javax.xml.soap.SOAPElement#addAttribute(javax.xml.soap.Name, java.lang.String)
+ */
+ public SOAPElement addAttribute(Name name, String value)
+ throws SOAPException {
+ org.apache.axis.om.OMNamespace omNS = org.apache.axis.om.OMAbstractFactory.getOMFactory().createOMNamespace(name.getURI(), name.getPrefix());
+ //TODO:
+ //The namespace of the attribute must be within the scope of the SOAPElement
+ //That check should be performed here.
+ omElement.addAttribute(name.getLocalName(), value, omNS);
+ return this;
+ }
+
+ /**
+ * Method addNamespaceDeclaration
+ * @param prefix
+ * @param uri
+ * @return
+ * @throws SOAPException
+ * @see javax.xml.soap.SOAPElement#addNamespaceDeclaration(java.lang.String, java.lang.String)
+ */
+ public SOAPElement addNamespaceDeclaration(String prefix, String uri)
+ throws SOAPException {
+ omElement.declareNamespace(uri, prefix);
+ return this;
+ }
+
+ /**
+ * Method getAttributeValue
+ * @param name
+ * @return
+ * @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 omElement.getFirstAttribute( new QName(name.getURI(),name.getLocalName(),name.getPrefix())).getValue();
+ }
+
+ /**
+ * Method getAllAttributes
+ * @return
+ * @see javax.xml.soap.SOAPElement#getAllAttributes()
+ */
+ public Iterator getAllAttributes() {
+ Iterator attrIter = omElement.getAttributes();
+ ArrayList arrayList = new ArrayList();
+ while (attrIter.hasNext()) {
+ Object o = attrIter.next();
+ if (o instanceof org.apache.axis.om.OMAttribute) {
+ //we need to create a SOAPNode for this and add to the arrayList
+ javax.xml.soap.Node soapNode = new NodeImpl((org.apache.axis.om.OMAttribute)o);
+ arrayList.add(soapNode);
+ }
+ }
+ return arrayList.iterator();
+ }
+
+ /**
+ * Method getNamespaceURI
+ * @param prefix
+ * @return
+ * @see javax.xml.soap.SOAPElement#getNamespaceURI(java.lang.String)
+ */
+ public String getNamespaceURI(String prefix) {
+ //Lets get all the inscope namespaces of this SOAPElement and iterate over them,
+ //whenever the prefix mathces break and return the corresponding URI.
+ Iterator nsIter = omElement.getAllDeclaredNamespaces();
+
+ //loop over to see a prefix matching namespace.
+ while(nsIter.hasNext()) {
+ Object o = nsIter.next();
+ if (o instanceof org.apache.axis.om.OMNamespace) {
+ org.apache.axis.om.OMNamespace ns = (org.apache.axis.om.OMNamespace)o;
+ if( ns.getPrefix().equalsIgnoreCase(prefix))
+ return ns.getName();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * method getNamespacePrefixes
+ * This method returns an iterator over all the declared namespaces prefix names.
+ * @return Iterator
+ * @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 = omElement.getAllDeclaredNamespaces();
+ while(nsIter.hasNext()) {
+ Object o = nsIter.next();
+ if (o instanceof org.apache.axis.om.OMNamespace) {
+ org.apache.axis.om.OMNamespace ns = (org.apache.axis.om.OMNamespace)o;
+ prefixList.add(ns.getPrefix());
+ }
+ }
+ return prefixList.iterator();
+ }
+
+ /**
+ * Method getElementName
+ * @return
+ * @see javax.xml.soap.SOAPElement#getElementName()
+ */
+ public Name getElementName() {
+ QName qName = omElement.getQName();
+ return (Name)(new PrefixedQName(qName.getNamespaceURI(), qName.getLocalPart(), qName.getPrefix()));
+ }
+
+ /**
+ * method removeAttribute
+ * This method removes an attribute with the specified name from the element.
+ * Returns true if the attribute was removed successfully; false if it was not
+ * @param name
+ * @return boolean
+ * @see javax.xml.soap.SOAPElement#removeAttribute(javax.xml.soap.Name)
+ */
+ public boolean removeAttribute(Name name) {
+ //get the OMAttribute with the given Name first, and call a removeAttribute(OMAttribute)
+ //method on the omElement datamember this SOAPElement has in it.
+ org.apache.axis.om.OMAttribute attr = omElement.getFirstAttribute(new QName(name.getURI(),name.getLocalName(),name.getPrefix()));
+ if (attr != null) {
+ omElement.removeAttribute(attr);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * method removeNamespaceDeclaration
+ * @param prefix
+ * @return
+ * @see javax.xml.soap.SOAPElement#removeNamespaceDeclaration(java.lang.String)
+ */
+ public boolean removeNamespaceDeclaration(String prefix) {
+ //TODO:
+ //I'm waiting on a removeNamespace method to be added to OMElement API
+ return false;
+ }
+
+ /**
+ * method getChildElements
+ * @return
+ * @see javax.xml.soap.SOAPElement#getChildElements()
+ */
+ 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 = omElement.getChildren();
+ ArrayList arrayList = new ArrayList();
+ while(childIter.hasNext()) {
+ Object o = childIter.next();
+ if (o instanceof org.apache.axis.om.OMNode) {
+ SOAPElement childElement = new SOAPElementImpl((org.apache.axis.om.OMElement)o);
+ arrayList.add(childElement);
+ }
+ }
+ return arrayList.iterator();
+ }
+
+ /**
+ * method getChildElements
+ * @param name
+ * @return
+ * @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 = omElement.getChildrenWithName(qName);
+ ArrayList arrayList = new ArrayList();
+ while(childIter.hasNext()) {
+ Object o = childIter.next();
+ if (o instanceof org.apache.axis.om.OMNode) {
+ SOAPElement childElement = new SOAPElementImpl((org.apache.axis.om.OMElement)o);
+ arrayList.add(childElement);
+ }
+ }
+ return arrayList.iterator();
+ }
+
+ /**
+ * method setEncodingStyle
+ * @param encodingStyle
+ * @see javax.xml.soap.SOAPElement#setEncodingStyle(java.lang.String)
+ */
+ public void setEncodingStyle(String encodingStyle) throws SOAPException {
+
+ //TODO:
+ //Donno how to tackle this right now.
+ //Couldn't figure out corresponding functionality in OM
+ //Should re-visit
+
+ }
+
+ /**
+ * method getEncodingStyle
+ * @return
+ * @see javax.xml.soap.SOAPElement#getEncodingStyle()
+ */
+ public String getEncodingStyle() {
+ //TODO:
+ //This is incomplete, needs to be revisited later
+ return null;
+ }
+
+ /**
+ * method removeContents
+ * @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 = omElement.getChildren();
+
+ while(childIter.hasNext()) {
+ Object o = childIter.next();
+ if(o instanceof org.apache.axis.om.OMNode)
+ ((org.apache.axis.om.OMNode)o).detach();
+ }
+ }
+
+ /**
+ * method getVisibleNamespacePrefixes
+ * @return
+ * @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 = omElement.getAllDeclaredNamespaces();
+ ArrayList returnList = new ArrayList();
+ while(namespacesIter.hasNext()) {
+ Object o = namespacesIter.next();
+ if (o instanceof org.apache.axis.om.OMNamespace) {
+ javax.xml.soap.Node soapNode = new NodeImpl((org.apache.axis.om.OMNamespace)o);
+ returnList.add(soapNode);
+ }
+ }//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.axis.om.OMElement parent = omElement.getParent();
+ if (parent!=null) {
+ Iterator parentScopeNamespacesIter = parent.getAllDeclaredNamespaces();
+ while(parentScopeNamespacesIter.hasNext()) {
+ Object o = parentScopeNamespacesIter.next();
+ if (o instanceof org.apache.axis.om.OMNamespace) {
+ javax.xml.soap.Node soapNode = new NodeImpl((org.apache.axis.om.OMNamespace)o);
+ returnList.add(soapNode);
+ }
+ }
+ }
+ return returnList.iterator();
+ }
+
+ /**
+ * method getTagName
+ * @return
+ * @see org.w3c.dom.Element#getTagName()
+ */
+ public String getTagName() {
+ return this.getLocalName();
+ }
+
+ /**
+ * method removeAttribute
+ * @param arg0
+ * @see org.w3c.dom.Element#removeAttribute(java.lang.String)
+ */
+ public void removeAttribute(String localName) throws DOMException {
+ //just got a localName, so assuming the namespace to be that of element
+ Name elementQualifiedName = this.getElementName();
+ //now try to remove that Attribute from this SOAPElement
+ this.removeAttribute(new PrefixedQName(elementQualifiedName.getURI(), localName, elementQualifiedName.getPrefix()));
+ }
+
+ /**
+ * method hasAttribute
+ * This method returns true when an attribute with a given name is specified
+ * on this element, false otherwise.
+ * @param localName
+ * @return
+ * @see org.w3c.dom.Element#hasAttribute(java.lang.String)
+ */
+ public boolean hasAttribute(String localName) {
+ Iterator attrIter = omElement.getAttributes();
+ while(attrIter.hasNext()) {
+ org.apache.axis.om.OMAttribute omAttr = (org.apache.axis.om.OMAttribute)(attrIter.next());
+ if (omAttr.getLocalName().equals(localName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * method getAttribute
+ * This method retrieves the value of an attribute having specified localname.
+ * In case of an element having multiple attributes with same localname but declared
+ * in different namespaces, use of this method is unadvised.
+ * @param name
+ * @return String
+ * @see org.w3c.dom.Element#getAttribute(java.lang.String)
+ */
+ public String getAttribute(String name) {
+ Iterator attrIter = omElement.getAttributes();
+ while(attrIter.hasNext()) {
+ org.apache.axis.om.OMAttribute omAttr = (org.apache.axis.om.OMAttribute)(attrIter.next());
+ if (omAttr.getLocalName().equals(name)) {
+ return omAttr.getValue();
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Element#removeAttributeNS(java.lang.String, java.lang.String)
+ */
+ public void removeAttributeNS(String namespaceURI, String localName) throws DOMException {
+ Name name = new PrefixedQName(namespaceURI, localName, null);
+ this.removeAttribute(name);
+ }
+
+ /**
+ * Method setAttribute
+ * This method creates and adds an attribute with the given localName and value
+ * into the underlying OM. It uses the namespace of omElement datamember of this SOAPElement for the
+ * newly added attribute.
+ * @param localName
+ * @param value
+ * @return
+ * @see org.w3c.dom.Element#setAttribute(java.lang.String, java.lang.String)
+ */
+ public void setAttribute(String localName, String value) throws DOMException {
+ //We will create a OMAttribute for the given input params, add it
+ //to the omElement datamemeber
+ org.apache.axis.om.OMAttribute omAttr = org.apache.axis.om.OMAbstractFactory.getOMFactory().createOMAttribute(localName, omElement.getNamespace(), value);
+ omElement.addAttribute(omAttr);
+ }
+
+ /**
+ * method hasAttributeNS
+ * This method returns true when an attribute with a given local name and
+ * namespace URI is specified on this element or has a default value, false
+ * otherwise.
+ * @param namespaceURI
+ * @param localName
+ * @return boolean
+ * @see org.w3c.dom.Element#hasAttributeNS(java.lang.String, java.lang.String)
+ */
+ public boolean hasAttributeNS(String namespaceURI, String localName) {
+ Iterator attrIter = omElement.getAttributes();
+ while(attrIter.hasNext()) {
+ org.apache.axis.om.OMAttribute omAttr = (org.apache.axis.om.OMAttribute)(attrIter.next());
+ if (omAttr.getLocalName().equals(localName) && omAttr.getNamespace().getName().equals(namespaceURI)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * method getAttributeNode
+ * This method retrieves an attribute node by the specified localname
+ * @param name
+ * @returns Attr
+ * @see org.w3c.dom.Element#getAttributeNode(java.lang.String)
+ */
+ public Attr getAttributeNode(String localName) {
+ Iterator attrIter = omElement.getAttributes();
+ while(attrIter.hasNext()) {
+ org.apache.axis.om.OMAttribute omAttr = (org.apache.axis.om.OMAttribute)(attrIter.next());
+ if (omAttr.getLocalName().equals(localName)) {
+ //So we have the right OMAttribute in hand.
+ //wrap it into a org.w3c.dom.Attr object and return
+ return (new org.apache.axis.saaj.AttrImpl(omAttr, this));
+ }
+ }
+ return null;
+ }
+
+ /**
+ * method removeAttributeNode
+ * This method removes the specified attribute node from this element.
+ * @param Attr
+ * The attribute node that should be removed.
+ * @return Attr
+ * The removed attribute node
+ * @see org.w3c.dom.Element#removeAttributeNode(org.w3c.dom.Attr)
+ */
+ public Attr removeAttributeNode(Attr oldAttr) throws DOMException {
+ //create a OMAttribute with the input object's localName, namespace (URI + prefix), value
+ //remove from underlying omElement such an attribute
+ //wrap the OMAttribute used for removing, into a dom Attr object and return.
+ org.apache.axis.om.OMNamespace oldAttrNS = org.apache.axis.om.OMAbstractFactory.getOMFactory().createOMNamespace(oldAttr.getNamespaceURI(),oldAttr.getPrefix());
+ org.apache.axis.om.OMAttribute omAttr = org.apache.axis.om.OMAbstractFactory.getOMFactory().createOMAttribute(oldAttr.getName(), oldAttrNS, oldAttr.getValue());
+ omElement.removeAttribute( omAttr );
+ return ( new org.apache.axis.saaj.AttrImpl(omAttr, this));
+ }
+
+ /**
+ * Method setAttributeNode
+ * This method creates and adds an attribute corresponding to the supplied <code>Attr</code>
+ * object into the underlying OM. The attribute that gets added to OM is created against this.omElement's namespace
+ * @param attr - a dom Attr object
+ * @return Attr - a dom Attr object corresponding to the added attribute.
+ * @see org.w3c.dom.Element#setAttributeNode(org.w3c.dom.Attr)
+ */
+ public Attr setAttributeNode(Attr attr) throws DOMException {
+ //Create a OMAttribute out of the supplied Attr, add this to the
+ //omElement and now wrap the created OMAttribute into a Attr and return
+ org.apache.axis.om.OMAttribute omAttr = org.apache.axis.om.OMAbstractFactory.getOMFactory().createOMAttribute(attr.getName(), omElement.getNamespace(), attr.getValue());
+ omElement.addAttribute(omAttr);
+ return (new org.apache.axis.saaj.AttrImpl(omAttr, this));
+ }
+
+ /**
+ * Method setAttributeNode
+ * This method creates and adds an attribute corresponding to the supplied <code>Attr</code>
+ * object into the underlying OM. The attribute added is created against it's own namespace
+ * @param attr - a dom Attr object
+ * @return Attr - a dom Attr object corresponding to the added attribute.
+ * @see org.w3c.dom.Element#setAttributeNodeNS(org.w3c.dom.Attr)
+ */
+ public Attr setAttributeNodeNS(Attr attr) throws DOMException {
+ org.apache.axis.om.OMNamespace attrNS = org.apache.axis.om.OMAbstractFactory.getOMFactory().createOMNamespace(attr.getNamespaceURI(), attr.getPrefix());
+ org.apache.axis.om.OMAttribute omAttr = org.apache.axis.om.OMAbstractFactory.getOMFactory().createOMAttribute(attr.getName(), attrNS, attr.getValue());
+ omElement.addAttribute(omAttr);
+ return (new org.apache.axis.saaj.AttrImpl(omAttr, this));
+ }
+
+ /**
+ * Method getElementsByTagName
+ * Returns a NodeList of all the descendant Elements with the given local
+ * name, in the order in which they are encountered in a preorder traversal
+ * of this Element tree.
+ * Current SOAPElement MAY not feature in the returned NodeList, only
+ * the descendant elements matching the criterion should be added.
+ * @param localName
+ * @return NodeList
+ * @see org.w3c.dom.Element#getElementsByTagName(java.lang.String)
+ */
+ public NodeList getElementsByTagName(String localName) {
+ Iterator childIter = this.getChildElements();
+ NodeListImpl returnList;
+ if (childIter==null)
+ return null;
+ else {
+ returnList = new NodeListImpl();
+ while(childIter.hasNext()) {
+ NodeList list = getElementsByTagNamePreOrder((SOAPElement)childIter.next(), localName);
+ //should *append* this list to the existing list. Remember, we are doing preorder
+ returnList.addNodeList(list);
+ }
+ }
+ return (NodeList)returnList;
+ }
+
+ private NodeList getElementsByTagNamePreOrder(SOAPElement child, String localName) {
+ NodeListImpl returnList = new NodeListImpl();
+ //We are doing preorder, so see if root itself is a match and place it first in the order
+ if(child.getLocalName().equals(localName)) {
+ //so this must be first in the returnList
+ returnList.addNode((org.w3c.dom.Node)child);
+ }
+ returnList.addNodeList(child.getElementsByTagName(localName));
+ return returnList;
+ }
+
+ /**
+ * method getAttributeNS
+ * This method retrieves the value of the attribute matching the specified namespaceURI, and localName
+ * @param namespaceURI
+ * @param localName
+ * @return String
+ * @see org.w3c.dom.Element#getAttributeNS(java.lang.String, java.lang.String)
+ */
+ public String getAttributeNS(String namespaceURI, String localName) {
+ Iterator attrIter = omElement.getAttributes();
+ while(attrIter.hasNext()) {
+ org.apache.axis.om.OMAttribute omAttr = (org.apache.axis.om.OMAttribute)(attrIter.next());
+ if (omAttr.getLocalName().equals(localName) && omAttr.getNamespace().getName().equals(namespaceURI)) {
+ return omAttr.getValue();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Method setAttributeNS
+ * This method creates and adds an attribute with the given namespaceURI, localName and value
+ * into the underlying OM.
+ * @param localName
+ * @param value
+ * @return
+ * @see org.w3c.dom.Element#setAttributeNS(java.lang.String, java.lang.String, java.lang.String)
+ */
+ public void setAttributeNS(String namespaceURI, String localName, String value)
+ throws DOMException {
+ //since no prefix is given, we create a OMNamespace with given URI and null prefix. How good is it???
+ org.apache.axis.om.OMNamespace attrNS = org.apache.axis.om.OMAbstractFactory.getOMFactory().createOMNamespace(namespaceURI,null);
+ org.apache.axis.om.OMAttribute omAttr = org.apache.axis.om.OMAbstractFactory.getOMFactory().createOMAttribute(localName, attrNS, value);
+ omElement.addAttribute( omAttr );
+ }
+
+ /**
+ * method getAttributeNodeNS
+ * This method retrieves an org.w3c.dom.Attr node matching the specified namespaceURI and localName
+ * @param namespaceURI
+ * @param localName
+ * @return Attr
+ * @see org.w3c.dom.Element#getAttributeNodeNS(java.lang.String, java.lang.String)
+ */
+ public Attr getAttributeNodeNS(String namespaceURI, String localName) {
+ Iterator attrIter = omElement.getAttributes();
+ while(attrIter.hasNext()) {
+ org.apache.axis.om.OMAttribute omAttr = (org.apache.axis.om.OMAttribute)(attrIter.next());
+ if (omAttr.getLocalName().equals(localName) && omAttr.getNamespace().getName().equals(namespaceURI)) {
+ return (new org.apache.axis.saaj.AttrImpl(omAttr, this));
+ }
+ }
+ return null;
+ }
+
+ /**
+ * getElementsByTagNameNS
+ * Returns a NodeList of all the descendant Elements with a given local
+ * name and namespace URI in the order in which they are encountered in a
+ * preorder traversal of this Element tree.
+ * Current SOAPElement MAY not feature in the returned NodeList, only
+ * the descendant elements matching the criterion should be added.
+ * @param namespaceURI
+ * @param localName
+ * @return NodeList
+ * @see org.w3c.dom.Element#getElementsByTagNameNS(java.lang.String, java.lang.String)
+ */
+ public NodeList getElementsByTagNameNS(String namespaceURI, String localName) {
+ Iterator childIter = this.getChildElements();
+ NodeListImpl returnList;
+ if (childIter==null)
+ return null;
+ else {
+ returnList = new NodeListImpl();
+ while(childIter.hasNext()) {
+ NodeList list = getElementsByTagNameNSPreOrder((SOAPElement)childIter.next(), namespaceURI, localName);
+ //should *append* this list to the existing list. Remember, we are doing preorder
+ returnList.addNodeList(list);
+ }
+ }
+ return (NodeList)returnList;
+ }
+
+ private NodeList getElementsByTagNameNSPreOrder(SOAPElement child, String namespaceURI, String localName) {
+ NodeListImpl returnList = new NodeListImpl();
+ //We are doing preorder, so see if root itself is a match and place it first in the order
+ if(child.getNamespaceURI().equals(namespaceURI) && child.getLocalName().equals(localName)) {
+ //so this must be first in the returnList
+ returnList.addNode((org.w3c.dom.Node)child);
+ }
+ returnList.addNodeList(child.getElementsByTagNameNS(namespaceURI, localName));
+ return returnList;
+ }
+
+}