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/20 16:01:51 UTC

svn commit: r358015 - in /webservices/axis2/trunk/java/modules: saaj/src/org/apache/axis2/om/impl/dom/ saaj/src/org/apache/axis2/om/impl/dom/factory/ saaj/src/org/apache/axis2/soap/impl/dom/ saaj/test/org/apache/axis2/om/impl/dom/ xml/src/org/apache/ax...

Author: ruchithf
Date: Tue Dec 20 07:01:23 2005
New Revision: 358015

URL: http://svn.apache.org/viewcvs?rev=358015&view=rev
Log:
- DOOM: XML comment implemented
- Fixed a bug in StAXSOAPModelBuilder where it keept two different document instances - an OMDocument and a SOAPMessage
- Make sure the next sibling is built
- Removed incorrect constructors (that doesn't require the document to be present)


Added:
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/CommentImpl.java
Modified:
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/AttrImpl.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/CharacterImpl.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ChildNode.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DocumentImpl.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ElementImpl.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/TextImpl.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/factory/OMDOMFactory.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/SOAPFaultTextImpl.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/SOAPHeaderBlockImpl.java
    webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/om/impl/dom/OMDOMTestCase.java
    webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/SOAPMessageImpl.java
    webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/builder/StAXSOAPModelBuilder.java

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/AttrImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/AttrImpl.java?rev=358015&r1=358014&r2=358015&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/AttrImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/AttrImpl.java Tue Dec 20 07:01:23 2005
@@ -90,19 +90,6 @@
 		this.namespace = (NamespaceImpl)namespace;
 	}
 	
-	public AttrImpl(String localName, OMNamespace ns, String value) {
-		this.attrName = localName;
-		this.attrValue = new TextImpl((DocumentImpl)this.getOwnerDocument(),value);
-		this.namespace = (NamespaceImpl)ns;
-	}
-	
-	public AttrImpl(String name, String value) {
-		this.attrName = name;
-		this.attrValue = new TextImpl((DocumentImpl)this.getOwnerDocument(),value);
-	}
-	
-
-	
 	///
 	///org.w3c.dom.Node methods
 	///

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/CharacterImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/CharacterImpl.java?rev=358015&r1=358014&r2=358015&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/CharacterImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/CharacterImpl.java Tue Dec 20 07:01:23 2005
@@ -101,7 +101,7 @@
 	 * Returns the value of the data
 	 */
 	public String getData() throws DOMException {
-		return this.textValue.toString();
+		return (this.textValue != null) ? this.textValue.toString() : "";
 	}
 	
 	/**

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ChildNode.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ChildNode.java?rev=358015&r1=358014&r2=358015&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ChildNode.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ChildNode.java Tue Dec 20 07:01:23 2005
@@ -42,10 +42,13 @@
 	}
 	
 	public OMNode getNextOMSibling() throws OMException {
-		return this.nextSibling;
+        while ((nextSibling == null) && !this.parentNode.done) {
+            this.parentNode.buildNext();
+        }
+        return nextSibling;
 	}
 	public Node getNextSibling() {
-		return this.nextSibling;
+		return (Node)this.getNextOMSibling();
 	}
 	public OMNode getPreviousOMSibling() {
 		return this.previousSibling;

Added: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/CommentImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/CommentImpl.java?rev=358015&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/CommentImpl.java (added)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/CommentImpl.java Tue Dec 20 07:01:23 2005
@@ -0,0 +1,75 @@
+/*
+ * 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.om.impl.dom;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axis2.om.OMComment;
+import org.apache.axis2.om.OMException;
+import org.apache.axis2.om.impl.OMOutputImpl;
+import org.w3c.dom.Comment;
+import org.w3c.dom.Node;
+
+public class CommentImpl extends CharacterImpl implements Comment, OMComment {
+
+	public CommentImpl(DocumentImpl ownerNode) {
+		super(ownerNode);
+		this.done = true;
+	}
+
+	public CommentImpl(DocumentImpl ownerNode, String value) {
+		super(ownerNode, value);
+		this.done = true;
+	}
+
+	public String getNodeName() {
+		return "#comment";
+	}
+
+	public short getNodeType() {
+		return Node.COMMENT_NODE;
+	}
+
+	public String getValue() {
+		return this.getData();
+	}
+
+	public void setValue(String text) {
+		this.textValue.delete(0,this.textValue.length());
+		this.textValue.append(text);
+	}
+
+	public int getType() {
+		return Node.COMMENT_NODE;
+	}
+
+	public void setType(int nodeType) throws OMException {
+		throw new UnsupportedOperationException("You should not set the node type of a comment");
+	}
+
+	public void serialize(OMOutputImpl omOutput) throws XMLStreamException {
+        XMLStreamWriter writer = omOutput.getXmlStreamWriter();
+        writer.writeComment(this.textValue.toString());
+	}
+
+	public void serializeAndConsume(OMOutputImpl omOutput)
+			throws XMLStreamException {
+		serialize(omOutput);
+	}
+
+}

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DocumentImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DocumentImpl.java?rev=358015&r1=358014&r2=358015&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DocumentImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DocumentImpl.java Tue Dec 20 07:01:23 2005
@@ -157,9 +157,8 @@
 		throw new UnsupportedOperationException("TODO");
 	}
 	
-	public Comment createComment(String arg0) {
-		//TODO
-		throw new UnsupportedOperationException("TODO");
+	public Comment createComment(String data) {
+		return new CommentImpl(this, data);
 	}
 	
 	public DocumentFragment createDocumentFragment() {

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ElementImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ElementImpl.java?rev=358015&r1=358014&r2=358015&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ElementImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ElementImpl.java Tue Dec 20 07:01:23 2005
@@ -21,12 +21,12 @@
 import java.util.Iterator;
 
 import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
 import org.apache.axis2.om.OMAttribute;
 import org.apache.axis2.om.OMConstants;
-import org.apache.axis2.om.OMContainer;
 import org.apache.axis2.om.OMElement;
 import org.apache.axis2.om.OMException;
 import org.apache.axis2.om.OMNamespace;
@@ -300,13 +300,14 @@
 
 		if(namespaceURI == OMConstants.XMLNS_NS_URI) {
 			OMNamespace ns = this.findNamespaceURI(localName);
-			AttrImpl namespaceAttr = new AttrImpl(localName, ns.getName());
+			AttrImpl namespaceAttr = new AttrImpl(this.ownerNode, localName, ns.getName());
 			NamespaceImpl xmlNs = new NamespaceImpl(OMConstants.XMLNS_NS_URI);
 			namespaceAttr.setOMNamespace(xmlNs);
 			return namespaceAttr;
 		}
 		
-		return (this.attributes == null)?null:(Attr)this.attributes.getNamedItemNS(namespaceURI,localName);
+		return (this.attributes == null) ? null : (Attr) this.attributes
+				.getNamedItemNS(namespaceURI, localName);
 
 	}
 
@@ -1094,6 +1095,16 @@
     	}
     }
     
+    
+    public OMNode getNextOMSibling() throws OMException {
+        while (!done) {
+            int token = builder.next();
+            if(token == XMLStreamConstants.END_DOCUMENT) {
+                throw new OMException();
+            }
+        }
+        return super.getNextOMSibling();
+    }
     
 	/*
 	 * DOM-Level 3 methods

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/TextImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/TextImpl.java?rev=358015&r1=358014&r2=358015&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/TextImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/TextImpl.java Tue Dec 20 07:01:23 2005
@@ -363,7 +363,7 @@
                     contentID = omOutput.getNextContentId();
                 }
                 // send binary as MTOM optimised
-                this.attribute = new AttrImpl("href",
+                this.attribute = new AttrImpl(this.ownerNode, "href",
                         new NamespaceImpl("", ""), "cid:" + getContentID());
                 this.serializeStartpart(omOutput);
                 omOutput.writeOptimized(this);
@@ -468,13 +468,6 @@
     }
 
     
-//    ///
-//    ///Special clone method to be used in cloneNode
-//    ///
-//    public Text cloneText() {
-//    	return new TextImpl(this.textValue.toString());
-//    }
-//    
     public Node cloneNode(boolean deep) {
     	TextImpl textImpl = new TextImpl(this.textValue.toString());
     	textImpl.setOwnerDocument(this.ownerNode);

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/factory/OMDOMFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/factory/OMDOMFactory.java?rev=358015&r1=358014&r2=358015&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/factory/OMDOMFactory.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/factory/OMDOMFactory.java Tue Dec 20 07:01:23 2005
@@ -28,6 +28,7 @@
 import org.apache.axis2.om.OMText;
 import org.apache.axis2.om.OMXMLParserWrapper;
 import org.apache.axis2.om.impl.dom.AttrImpl;
+import org.apache.axis2.om.impl.dom.CommentImpl;
 import org.apache.axis2.om.impl.dom.DocumentFragmentimpl;
 import org.apache.axis2.om.impl.dom.DocumentImpl;
 import org.apache.axis2.om.impl.dom.ElementImpl;
@@ -222,7 +223,7 @@
     }
 	
 	public OMAttribute createOMAttribute(String localName, OMNamespace ns, String value) {
-		return new AttrImpl(localName,ns, value);
+		return new AttrImpl(this.getDocument() ,localName,ns, value);
 	}
 
 	public OMDocType createOMDocType(OMContainer parent, String content) {
@@ -236,8 +237,9 @@
 	}
 
 	public OMComment createOMComment(OMContainer parent, String content) {
-		// TODO
-		throw new UnsupportedOperationException("TODO");
+		CommentImpl comment = new CommentImpl((DocumentImpl)((ElementImpl)parent).getOwnerDocument(), content);
+		parent.addChild(comment);
+		return comment;
 	}
 	
 	public DocumentImpl getDocument() {

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/SOAPFaultTextImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/SOAPFaultTextImpl.java?rev=358015&r1=358014&r2=358015&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/SOAPFaultTextImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/SOAPFaultTextImpl.java Tue Dec 20 07:01:23 2005
@@ -48,7 +48,7 @@
     public void setLang(String lang) {
         //langAttr = new OMAttributeImpl(SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_LOCAL_NAME, parent.getNamespace(), lang);
         langAttr =
-                new AttrImpl(
+                new AttrImpl(this.ownerNode, 
                         SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_LOCAL_NAME,
                         langNamespace,
                         lang);

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/SOAPHeaderBlockImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/SOAPHeaderBlockImpl.java?rev=358015&r1=358014&r2=358015&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/SOAPHeaderBlockImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/SOAPHeaderBlockImpl.java Tue Dec 20 07:01:23 2005
@@ -21,6 +21,7 @@
 import org.apache.axis2.om.OMNamespace;
 import org.apache.axis2.om.OMXMLParserWrapper;
 import org.apache.axis2.om.impl.dom.AttrImpl;
+import org.apache.axis2.om.impl.dom.DocumentImpl;
 import org.apache.axis2.om.impl.dom.ElementImpl;
 import org.apache.axis2.om.impl.dom.NamespaceImpl;
 import org.apache.axis2.om.impl.dom.ParentNode;
@@ -72,10 +73,10 @@
         if (omAttribute != null) {
             omAttribute.setAttributeValue(attrValue);
         } else {
-            OMAttribute attribute = new AttrImpl(attributeName,
-                    new NamespaceImpl(soapEnvelopeNamespaceURI,
-                            SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX),
-                    attrValue);
+            OMAttribute attribute = new AttrImpl(this.ownerNode, attributeName,
+					new NamespaceImpl(soapEnvelopeNamespaceURI,
+							SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX),
+					attrValue);
             this.addAttribute(attribute);
         }
     }

Modified: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/om/impl/dom/OMDOMTestCase.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/om/impl/dom/OMDOMTestCase.java?rev=358015&r1=358014&r2=358015&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/om/impl/dom/OMDOMTestCase.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/om/impl/dom/OMDOMTestCase.java Tue Dec 20 07:01:23 2005
@@ -16,12 +16,6 @@
 
 package org.apache.axis2.om.impl.dom;
 
-import org.apache.axis2.om.OMFactory;
-import org.apache.axis2.soap.SOAPEnvelope;
-import org.apache.axis2.soap.SOAPFactory;
-import org.apache.axis2.soap.impl.dom.factory.DOMSOAPFactory;
-import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
-
 import java.io.FileReader;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -32,6 +26,13 @@
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 
+import org.apache.axis2.om.OMFactory;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.axis2.soap.SOAPFactory;
+import org.apache.axis2.soap.impl.dom.factory.DOMSOAPFactory;
+import org.apache.axis2.soap.impl.dom.soap11.SOAP11Factory;
+import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
+
 public class OMDOMTestCase extends AbstractTestCase{
 
 	protected static final String IN_FILE_NAME = "soap/soapmessage.xml";
@@ -57,7 +58,7 @@
         XMLStreamReader parser = XMLInputFactory.newInstance()
                 .createXMLStreamReader(
                         new FileReader(getTestResourceFile(fileName)));
-        builder = new StAXSOAPModelBuilder(parser, new DOMSOAPFactory(), null);
+        builder = new StAXSOAPModelBuilder(parser, new SOAP11Factory(), null);
         return builder;
     }
     

Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/SOAPMessageImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/SOAPMessageImpl.java?rev=358015&r1=358014&r2=358015&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/SOAPMessageImpl.java (original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/SOAPMessageImpl.java Tue Dec 20 07:01:23 2005
@@ -56,11 +56,6 @@
         throw new UnsupportedOperationException("This is not allowed. Use set SOAPEnvelope instead");
     }
 
-    public void addChild(OMNode child) {
-        throw new UnsupportedOperationException("Can not add normal children to SOAP envelope. Use setSOAPEnvelope()");
-    }
-
-
     public void setFirstChild(OMNode firstChild) {
         throw new UnsupportedOperationException("This is not allowed. Use set SOAPEnvelope instead");
     }

Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/builder/StAXSOAPModelBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/builder/StAXSOAPModelBuilder.java?rev=358015&r1=358014&r2=358015&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/builder/StAXSOAPModelBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/builder/StAXSOAPModelBuilder.java Tue Dec 20 07:01:23 2005
@@ -98,6 +98,7 @@
         soapFactory = OMAbstractFactory.getDefaultSOAPFactory();
         isTempSOAPFactory = true;
         soapMessage = soapFactory.createSOAPMessage(this);
+        this.document = soapMessage;
         if(parser.getCharacterEncodingScheme() != null) {
             document.setCharsetEncoding(parser.getCharacterEncodingScheme());
         }
@@ -119,6 +120,7 @@
         soapFactory = factory;
         isTempSOAPFactory = false;
         soapMessage = soapFactory.createSOAPMessage(this);
+        this.document = soapMessage;
         identifySOAPVersion(soapVersion);
         parseHeaders();
     }