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 ch...@apache.org on 2005/03/08 09:56:29 UTC

svn commit: r156512 [2/4] - in webservices/axis/trunk/archive/java/scratch/Thilina: ./ MTOM/ MTOM/lib/ MTOM/src/ MTOM/src/java/ MTOM/src/java/org/ MTOM/src/java/org/apache/ MTOM/src/java/org/apache/axis/ MTOM/src/java/org/apache/axis/encoding/ MTOM/src/java/org/apache/axis/impl/ MTOM/src/java/org/apache/axis/impl/llom/ MTOM/src/java/org/apache/axis/impl/llom/builder/ MTOM/src/java/org/apache/axis/impl/llom/exception/ MTOM/src/java/org/apache/axis/impl/llom/factory/ MTOM/src/java/org/apache/axis/impl/llom/mtom/ MTOM/src/java/org/apache/axis/impl/llom/serialize/ MTOM/src/java/org/apache/axis/impl/llom/traverse/ MTOM/src/java/org/apache/axis/om/ MTOM/src/test-resources/ MTOM/src/test/ MTOM/src/test/org/ MTOM/src/test/org/apache/ MTOM/src/test/org/apache/axis/ MTOM/src/test/org/apache/axis/mtom/

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMTextImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMTextImpl.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMTextImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMTextImpl.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,73 @@
+package org.apache.axis.impl.llom;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMException;
+import org.apache.axis.om.OMNode;
+import org.apache.axis.om.OMText;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ */
+public class OMTextImpl extends OMNodeImpl implements OMText {
+
+    protected short textType;
+
+    public OMTextImpl(OMElement parent, String text) {
+        super(parent);
+        setValue(text);
+        done = true;
+    }
+
+    public OMTextImpl(String s) {
+        super();
+        setValue(s);
+    }
+
+    /**
+     * We use the OMText class to hold comments, text, characterData, CData,
+     * etc., The codes are found in OMNode class
+     *
+     * @param type
+     */
+    public void setTextType(short type) {
+        this.textType = type;
+    }
+
+    public short getTextType() {
+        return textType;
+    }
+
+    public OMNode getFirstChild() throws OMException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setFirstChild(OMNode node) throws OMException {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * This is to get the type of node, as this is the super class of all the
+     * nodes
+     *
+     * @return
+     * @throws org.apache.axis.om.OMException
+     */
+    public short getType() throws OMException {
+        return OMNode.TEXT_NODE;
+    }
+
+
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPBodyImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPBodyImpl.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPBodyImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPBodyImpl.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,106 @@
+package org.apache.axis.impl.llom;
+
+import org.apache.axis.om.*;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ */
+public class SOAPBodyImpl extends OMElementImpl implements SOAPBody, OMConstants {
+
+    private boolean hasSOAPFault = false;
+
+
+    /**
+     * @param envelope
+     */
+    public SOAPBodyImpl(SOAPEnvelope envelope) {
+        super(envelope);
+        this.ns = envelope.getNamespace();
+        this.localName = OMConstants.BODY_LOCAL_NAME;
+    }
+
+    public SOAPBodyImpl(String localName, OMNamespace ns, OMElement parent, OMXMLParserWrapper builder) {
+        super(localName, ns, parent, builder);
+    }
+
+    /**
+     * Creates a new <code>SOAPFault</code> object and adds it to this
+     * <code>SOAPBody</code> object.
+     *
+     * @return the new <code>SOAPFault</code> object
+     * @throws org.apache.axis.om.OMException if there is a SOAP error
+     */
+    public SOAPFault addFault(Exception e) throws OMException {
+        SOAPFault soapFault = new SOAPFaultImpl(this, e);
+        addFault(soapFault);
+        return soapFault;
+    }
+
+    /**
+     * Indicates whether a <code>SOAPFault</code> object exists in this
+     * <code>SOAPBody</code> object.
+     *
+     * @return <code>true</code> if a <code>SOAPFault</code> object exists in
+     *         this <code>SOAPBody</code> object; <code>false</code> otherwise
+     */
+    public boolean hasFault() {
+        if (hasSOAPFault) {
+            return true;
+        } else {
+            Iterator soapFaultChildren = getChildrenWithName(new QName(SOAPFAULT_NAMESPACE_URI, SOAPFAULT_LOCAL_NAME));
+            if (soapFaultChildren.hasNext()) {
+                hasSOAPFault = true;
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Returns the <code>SOAPFault</code> object in this <code>SOAPBody</code>
+     * object.
+     *
+     * @return the <code>SOAPFault</code> object in this <code>SOAPBody</code>
+     *         object
+     */
+    public SOAPFault getFault() {
+        Iterator soapFaultChildren = getChildrenWithName(new QName(SOAPFAULT_NAMESPACE_URI, SOAPFAULT_LOCAL_NAME));
+        if (soapFaultChildren.hasNext()) {
+            SOAPFault soapFault = (SOAPFault) soapFaultChildren.next();
+            return soapFault;
+        }
+        return null;
+    }
+
+
+    /**
+     * @param soapFault
+     * @throws org.apache.axis.om.OMException
+     */
+    public void addFault(SOAPFault soapFault) throws OMException {
+        if (hasSOAPFault) {
+            throw new OMException("SOAP Body already has a SOAP Fault and there can not be more than one SOAP fault");
+        }
+        addChild(soapFault);
+        hasSOAPFault = true;
+
+    }
+
+
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPEnvelopeImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPEnvelopeImpl.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPEnvelopeImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPEnvelopeImpl.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,112 @@
+package org.apache.axis.impl.llom;
+
+import org.apache.axis.om.*;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ */
+public class SOAPEnvelopeImpl extends OMElementImpl implements SOAPEnvelope, OMConstants {
+
+    /**
+     * @param builder
+     */
+    public SOAPEnvelopeImpl(OMXMLParserWrapper builder) {
+        super("", null, null, builder);
+        this.localName = SOAPENVELOPE_LOCAL_NAME;
+
+    }
+
+    public SOAPEnvelopeImpl(String localName, OMNamespace ns, OMElement parent, OMXMLParserWrapper builder) {
+        super(localName, ns, parent, builder);
+    }
+
+    /**
+     * @param localName
+     * @param ns
+     */
+    public SOAPEnvelopeImpl(String localName, OMNamespace ns) {
+        super(localName, ns);
+    }
+
+    /**
+     * Creates a new <CODE>Name</CODE> object initialized with the given local
+     * name, namespace prefix, and namespace URI.
+     * <p/>
+     * <P>This factory method creates <CODE>Name</CODE> objects for use in the
+     * SOAP/XML document.
+     *
+     * @param localName a <CODE>String</CODE> giving the local name
+     * @param prefix    a <CODE>String</CODE> giving the prefix of the
+     *                  namespace
+     * @param uri       a <CODE>String</CODE> giving the URI of the namespace
+     * @return a <CODE>OMNamespace</CODE> object initialized with the given
+     *         local name, namespace prefix, and namespace URI
+     * @throws org.apache.axis.om.OMException if there is a SOAP error
+     */
+    public OMNamespace createNamespace(String localName, String prefix, String uri) throws OMException {
+        return this.createNamespace(localName, prefix, uri);
+    }
+
+    /**
+     * Returns the <CODE>SOAPHeader</CODE> object for this <CODE>
+     * SOAPEnvelope</CODE> object.
+     * <p/>
+     * <P> This SOAPHeader will just be a container for all the headers in the
+     * <CODE>OMMessage</CODE> </P>
+     *
+     * @return the <CODE>SOAPHeader</CODE> object or <CODE> null</CODE> if there
+     *         is none
+     * @throws org.apache.axis.om.OMException if there is a problem obtaining
+     *                                        the <CODE>SOAPHeader</CODE>
+     *                                        object
+     */
+    public SOAPHeader getHeader() throws OMException {
+        Iterator headerIterator = this.getChildrenWithName(new QName(OMConstants.HEADER_NAMESPACEURI, OMConstants.HEADER_LOCAL_NAME));
+        SOAPHeader soapHeader = null;
+        if (headerIterator.hasNext()) {
+            soapHeader = (SOAPHeader) headerIterator.next();
+        }
+
+        return soapHeader;
+    }
+
+    /**
+     * Returns the <CODE>SOAPBody</CODE> object associated with this
+     * <CODE>SOAPEnvelope</CODE> object.
+     * <p/>
+     * <P> This SOAPBody will just be a container for all the BodyElements in
+     * the <CODE>OMMessage</CODE> </P>
+     *
+     * @return the <CODE>SOAPBody</CODE> object for this <CODE>
+     *         SOAPEnvelope</CODE> object or <CODE>null</CODE> if there is none
+     * @throws org.apache.axis.om.OMException if there is a problem obtaining
+     *                                        the <CODE>SOAPBody</CODE> object
+     */
+    public SOAPBody getBody() throws OMException {
+        Iterator bodyIterator = this.getChildrenWithName(new QName(OMConstants.BODY_NAMESPACE_URI, OMConstants.BODY_LOCAL_NAME));
+        SOAPBody soapBody = null;
+        if (bodyIterator.hasNext()) {
+            soapBody = (SOAPBody) bodyIterator.next();
+        }
+
+        return soapBody;
+    }
+
+
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPFaultImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPFaultImpl.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPFaultImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPFaultImpl.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,81 @@
+package org.apache.axis.impl.llom;
+
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.om.*;
+
+import javax.xml.namespace.QName;
+import java.util.Locale;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ */
+public class SOAPFaultImpl extends OMElementImpl implements SOAPFault, OMConstants {
+
+    private Exception e;
+
+    public SOAPFaultImpl(OMElement parent, Exception e) {
+        super(parent);
+        this.e = e;
+        this.addChild(OMFactory.newInstance().createText(this, e.getMessage()));
+        localName = SOAPFAULT_LOCAL_NAME;
+        setNamespace(new OMNamespaceImpl(SOAPFAULT_NAMESPACE_URI, SOAPFAULT_NAMESPACE_PREFIX));
+    }
+
+//    public SOAPFaultImpl(OMElement parent) {
+//        super(parent);
+//
+//    }
+
+    public SOAPFaultImpl(OMNamespace ns, OMElement parent, OMXMLParserWrapper builder) {
+        super(SOAPFAULT_LOCAL_NAME, ns, parent, builder);
+    }
+
+    public void setFaultCode(QName faultCode) throws OMException {
+        throw new UnsupportedOperationException(); //TODO implement this
+    }
+
+    public QName getFaultCode() {
+        throw new UnsupportedOperationException(); //TODO implement this
+    }
+
+    public void setFaultActor(String faultActor) throws OMException {
+        throw new UnsupportedOperationException(); //TODO implement this
+    }
+
+    public String getFaultActor() {
+        throw new UnsupportedOperationException(); //TODO implement this
+    }
+
+    public void setFaultString(String faultString) throws OMException {
+        throw new UnsupportedOperationException(); //TODO implement this
+    }
+
+    public String getFaultString() {
+        throw new UnsupportedOperationException(); //TODO implement this
+    }
+
+    public void setFaultString(String faultString, Locale locale) throws OMException {
+        throw new UnsupportedOperationException(); //TODO implement this
+    }
+
+    public Exception getException() throws OMException {
+        if (e == null) {
+            return new AxisFault();
+        } else {
+            return e;
+        }
+    }
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPHeaderBlockImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPHeaderBlockImpl.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPHeaderBlockImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPHeaderBlockImpl.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,116 @@
+package org.apache.axis.impl.llom;
+
+import org.apache.axis.om.*;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ */
+public class SOAPHeaderBlockImpl extends OMElementImpl implements SOAPHeaderBlock {
+
+    /**
+     * @param localName
+     * @param ns
+     */
+    public SOAPHeaderBlockImpl(String localName, OMNamespace ns) {
+        super(localName, ns);
+    }
+
+    public SOAPHeaderBlockImpl(String localName, OMNamespace ns, OMElement parent, OMXMLParserWrapper builder) {
+        super(localName, ns, parent, builder);
+    }
+
+    /**
+     * Sets the actor associated with this <CODE> SOAPHeaderBlock</CODE> object
+     * to the specified actor. The default value of an actor is: <CODE>
+     * OMConstants.URI_SOAP_ACTOR_NEXT</CODE>
+     *
+     * @param actorURI a <CODE>String</CODE> giving the URI of the actor to set
+     * @throws IllegalArgumentException if there is a problem in setting the
+     *                                  actor.
+     * @see #getActor() getActor()
+     */
+    public void setActor(String actorURI) {
+        setAttribute(OMConstants.ATTR_ACTOR, actorURI);
+    }
+
+    /**
+     * @param attributeName
+     * @param attrValue
+     */
+    private void setAttribute(String attributeName, String attrValue) {
+        OMAttribute omAttribute = this.getAttributeWithQName(new QName(OMConstants.SOAP_ENVELOPE_NAMESPACE_URI, attributeName));
+        if (omAttribute != null) {
+            omAttribute.setValue(attrValue);
+        } else {
+            OMAttribute attribute = new OMAttributeImpl(attributeName, new OMNamespaceImpl(OMConstants.SOAP_ENVELOPE_NAMESPACE_URI, OMConstants.SOAPENVELOPE_NAMESPACE_PREFIX), attrValue);
+            this.insertAttribute(attribute);
+        }
+    }
+
+    /**
+     * Returns the uri of the actor associated with this <CODE>
+     * SOAPHeaderBlock</CODE> object.
+     *
+     * @return a <CODE>String</CODE> giving the URI of the actor
+     * @see #setActor(String) setActor(java.lang.String)
+     */
+    public String getActor() {
+        return getAttribute(OMConstants.ATTR_ACTOR);
+    }
+
+    private String getAttribute(String attrName) {
+
+        OMAttribute omAttribute = this.getAttributeWithQName(new QName(OMConstants.SOAP_ENVELOPE_NAMESPACE_URI, attrName));
+        return (omAttribute != null) ? omAttribute.getValue() : null;
+    }
+
+    /**
+     * Sets the mustUnderstand attribute for this <CODE> SOAPHeaderBlock</CODE>
+     * object to be on or off.
+     * <p/>
+     * <P>If the mustUnderstand attribute is on, the actor who receives the
+     * <CODE>SOAPHeaderBlock</CODE> must process it correctly. This ensures, for
+     * example, that if the <CODE> SOAPHeaderBlock</CODE> object modifies the
+     * message, that the message is being modified correctly.</P>
+     *
+     * @param mustUnderstand <CODE>true</CODE> to set the mustUnderstand
+     *                       attribute on; <CODE>false</CODE> to turn if off
+     * @throws IllegalArgumentException if there is a problem in setting the
+     *                                  actor.
+     * @see #getMustUnderstand() getMustUnderstand()
+     */
+    public void setMustUnderstand(boolean mustUnderstand) {
+        setAttribute(OMConstants.ATTR_MUSTUNDERSTAND, mustUnderstand ? "true" : "false");
+    }
+
+    /**
+     * Returns whether the mustUnderstand attribute for this
+     * <CODE>SOAPHeaderBlock</CODE> object is turned on.
+     *
+     * @return <CODE>true</CODE> if the mustUnderstand attribute of this
+     *         <CODE>SOAPHeaderBlock</CODE> object is turned on;
+     *         <CODE>false</CODE> otherwise
+     */
+    public boolean getMustUnderstand() {
+        String mustUnderstand = "";
+        if ((mustUnderstand = getAttribute(OMConstants.ATTR_MUSTUNDERSTAND)) != null) {
+            return mustUnderstand.equalsIgnoreCase("true");
+        }
+        return false;
+    }
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPHeaderImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPHeaderImpl.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPHeaderImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPHeaderImpl.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,138 @@
+package org.apache.axis.impl.llom;
+
+import org.apache.axis.om.*;
+
+import java.util.Iterator;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ */
+public class SOAPHeaderImpl extends OMElementImpl implements SOAPHeader {
+
+
+    /**
+     * @param envelope
+     */
+    public SOAPHeaderImpl(SOAPEnvelope envelope) {
+        super(envelope);
+        //set the namespaces
+        this.ns = envelope.getNamespace();
+        this.localName = OMConstants.HEADER_LOCAL_NAME;
+
+    }
+
+    public SOAPHeaderImpl(String localName, OMNamespace ns, OMElement parent, OMXMLParserWrapper builder) {
+        super(localName, ns, parent, builder);
+    }
+
+    /**
+     * Creates a new <CODE>SOAPHeaderBlock</CODE> object initialized with the
+     * specified name and adds it to this <CODE>SOAPHeader</CODE> object.
+     *
+     * @return the new <CODE>SOAPHeaderBlock</CODE> object that was inserted
+     *         into this <CODE>SOAPHeader</CODE> object
+     * @throws org.apache.axis.om.OMException if a SOAP error occurs
+     */
+    public SOAPHeaderBlock addHeaderBlock(String localName, OMNamespace ns) throws OMException {
+        SOAPHeaderBlock soapHeaderBlock = new SOAPHeaderBlockImpl(localName, ns);
+        this.addChild(soapHeaderBlock);
+        soapHeaderBlock.setComplete(true);
+        return soapHeaderBlock;
+    }
+
+    /**
+     * Returns a list of all the <CODE>SOAPHeaderBlock</CODE> objects in this
+     * <CODE>SOAPHeader</CODE> object that have the the specified actor. An
+     * actor is a global attribute that indicates the intermediate parties to
+     * whom the message should be sent. An actor receives the message and then
+     * sends it to the next actor. The default actor is the ultimate intended
+     * recipient for the message, so if no actor attribute is included in a
+     * <CODE>SOAPHeader</CODE> object, the message is sent to its ultimate
+     * destination.
+     *
+     * @param actor a <CODE>String</CODE> giving the URI of the actor for which
+     *              to search
+     * @return an <CODE>Iterator</CODE> object over all the <CODE>
+     *         SOAPHeaderBlock</CODE> objects that contain the specified actor
+     * @see #extractHeaderBlocks(String) extractHeaderBlocks(java.lang.String)
+     */
+    public Iterator examineHeaderBlocks(String actor) {
+        throw new UnsupportedOperationException(); //TODO implement this
+    }
+
+    /**
+     * Returns a list of all the <CODE>SOAPHeaderBlock</CODE> objects in this
+     * <CODE>SOAPHeader</CODE> object that have the the specified actor and
+     * detaches them from this <CODE> SOAPHeader</CODE> object.
+     * <p/>
+     * <P>This method allows an actor to process only the parts of the
+     * <CODE>SOAPHeader</CODE> object that apply to it and to remove them before
+     * passing the message on to the next actor.
+     *
+     * @param actor a <CODE>String</CODE> giving the URI of the actor for which
+     *              to search
+     * @return an <CODE>Iterator</CODE> object over all the <CODE>
+     *         SOAPHeaderBlock</CODE> objects that contain the specified actor
+     * @see #examineHeaderBlocks(String) examineHeaderBlocks(java.lang.String)
+     */
+    public Iterator extractHeaderBlocks(String actor) {
+        throw new UnsupportedOperationException(); //TODO implement this
+    }
+
+    /**
+     * Returns an <code>Iterator</code> over all the <code>SOAPHeaderBlock</code>
+     * objects in this <code>SOAPHeader</code> object that have the specified
+     * actor and that have a MustUnderstand attribute whose value is equivalent
+     * to <code>true</code>.
+     *
+     * @param actor a <code>String</code> giving the URI of the actor for which
+     *              to search
+     * @return an <code>Iterator</code> object over all the
+     *         <code>SOAPHeaderBlock</code> objects that contain the specified
+     *         actor and are marked as MustUnderstand
+     */
+    public Iterator examineMustUnderstandHeaderBlocks(String actor) {
+        throw new UnsupportedOperationException(); //TODO implement this
+    }
+
+    /**
+     * Returns an <code>Iterator</code> over all the <code>SOAPHeaderBlock</code>
+     * objects in this <code>SOAPHeader</code> object.
+     * <p/>
+     * Not that this will return elements containing the QName
+     * (http://schemas.xmlsoap.org/soap/envelope/, Header)
+     *
+     * @return an <code>Iterator</code> object over all the
+     *         <code>SOAPHeaderBlock</code> objects contained by this
+     *         <code>SOAPHeader</code>
+     */
+    public Iterator examineAllHeaderBlocks() {
+        return this.getChildrenWithName(null);
+    }
+
+    /**
+     * Returns an <code>Iterator</code> over all the <code>SOAPHeaderBlock</code>
+     * objects in this <code>SOAPHeader </code> object and detaches them from
+     * this <code>SOAPHeader</code> object.
+     *
+     * @return an <code>Iterator</code> object over all the
+     *         <code>SOAPHeaderBlock</code> objects contained by this
+     *         <code>SOAPHeader</code>
+     */
+    public Iterator extractAllHeaderBlocks() {
+        throw new UnsupportedOperationException(); //TODO implement this
+    }
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/builder/StAXBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/builder/StAXBuilder.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/builder/StAXBuilder.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/builder/StAXBuilder.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,251 @@
+package org.apache.axis.impl.llom.builder;
+
+import org.apache.axis.impl.llom.OMElementImpl;
+import org.apache.axis.impl.llom.OMNodeImpl;
+import org.apache.axis.impl.llom.OMTextImpl;
+import org.apache.axis.impl.llom.mtom.MTOMBuilder;
+import org.apache.axis.om.*;
+
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamReader;
+import java.io.InputStream;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ */
+
+/**
+ * OM should be able to built from any data source. And the model it builds may
+ * be a SOAP specific one or just an XML model. This class will give some common
+ * functionality of OM Building from StAX.
+ */
+public abstract class StAXBuilder implements OMXMLParserWrapper {
+    protected OMFactory ombuilderFactory;
+    protected XMLStreamReader parser;
+    MTOMBuilder MtomBuilder;
+
+    protected OMNode lastNode;
+//returns the state of completion
+    protected boolean done = false;
+
+    //keeps the state of the cache
+    protected boolean cache = true;
+
+    //keeps the state of the parser access. if the parser is
+    //accessed atleast once,this flag will be set
+    protected boolean parserAccessed = false;
+    
+/*
+* Edited by Thilina Gunarathne 
+*/
+    protected StAXBuilder(OMFactory ombuilderFactory, InputStream stream) {
+        this.ombuilderFactory = ombuilderFactory;
+        MtomBuilder = new MTOMBuilder(stream);
+        try {
+            this.parser = MtomBuilder.getParser();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+/*
+ * Edit Over
+*/
+    	
+
+    protected StAXBuilder(InputStream stream) {
+        this(OMFactory.newInstance(), stream);
+    }
+
+    public void setOmbuilderFactory(OMFactory ombuilderFactory) {
+        this.ombuilderFactory = ombuilderFactory;
+    }
+
+    protected abstract void processNamespaceData(OMElement node, boolean isSOAPElement);
+    //since the behaviors are different when it comes to namespaces
+    //this must be implemented differently
+
+    protected void processAttributes(OMElement node) {
+        int attribCount = parser.getAttributeCount();
+        for (int i = 0; i < attribCount; i++) {
+            OMNamespace ns = null;
+            String uri = parser.getAttributeNamespace(i);
+            if (uri.hashCode() != 0)
+                ns = node.findInScopeNamespace(uri, parser.getAttributePrefix(i));
+
+            //todo if the attributes are supposed to namespace qualified all the time
+            //todo then this should throw an exception here
+            node.insertAttribute(ombuilderFactory.createOMAttribute(parser.getAttributeLocalName(i),
+                    ns,
+                    parser.getAttributeValue(i)));
+        }
+    }
+
+    protected OMNode createOMText() throws OMException {
+        if (lastNode == null)
+            throw new OMException();
+        OMNodeImpl node;
+        if (lastNode.isComplete()) {
+            node = new OMTextImpl(lastNode.getParent(), parser.getText());
+            lastNode.setNextSibling(node);
+            node.setPreviousSibling(lastNode);
+        } else {
+            OMElementImpl e = (OMElementImpl) lastNode;
+            node = new OMTextImpl(e, parser.getText());
+            e.setFirstChild(node);
+        }
+        return node;
+    }
+
+    public void reset(OMNode node) throws OMException {
+        lastNode = null;
+    }
+
+    public void discard(OMElement el) throws OMException {
+
+        OMElementImpl elementImpl = null;
+        if (el instanceof OMElementImpl) {
+            elementImpl = (OMElementImpl) el;
+        } else {
+            throw new OMException();
+        }
+
+        if (elementImpl.isComplete() || !cache)
+            throw new OMException();
+        try {
+            cache = false;
+            do {
+                while (parser.next() != XMLStreamConstants.END_ELEMENT) ;
+                //	TODO:
+            } while (!parser.getName().equals(elementImpl.getLocalName()));
+            lastNode = (OMNodeImpl) elementImpl.getPreviousSibling();
+            if (lastNode != null)
+                lastNode.setNextSibling(null);
+            else {
+                OMElement parent = elementImpl.getParent();
+                if (parent == null)
+                    throw new OMException();
+                parent.setFirstChild(null);
+                lastNode = parent;
+            }
+            cache = true;
+        } catch (OMException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new OMException(e);
+        }
+    }
+
+    public String getText() throws OMException {
+        return parser.getText();
+    }
+
+    public String getNamespace() throws OMException {
+        return parser.getNamespaceURI();
+    }
+
+    public int getNamespaceCount() throws OMException {
+        try {
+            return parser.getNamespaceCount();
+        } catch (Exception e) {
+            throw new OMException(e);
+        }
+    }
+
+    public String getNamespacePrefix(int index) throws OMException {
+        try {
+            return parser.getNamespacePrefix(index);
+        } catch (Exception e) {
+            throw new OMException(e);
+        }
+    }
+
+    public String getNamespaceUri(int index) throws OMException {
+        try {
+            return parser.getNamespaceURI(index);
+        } catch (Exception e) {
+            throw new OMException(e);
+        }
+    }
+
+    public void setCache(boolean b) {
+        if (parserAccessed && b)
+            throw new UnsupportedOperationException("parser accessed. cannot set cache");
+        cache = b;
+    }
+
+    public String getName() throws OMException {
+        return parser.getLocalName();
+    }
+
+    public String getPrefix() throws OMException {
+        return parser.getPrefix();
+    }
+
+    public int getAttributeCount() throws OMException {
+        return parser.getAttributeCount();
+    }
+
+    public String getAttributeNamespace(int arg) throws OMException {
+        return parser.getAttributeNamespace(arg);
+    }
+
+    public String getAttributeName(int arg) throws OMException {
+        return parser.getAttributeNamespace(arg);
+    }
+
+    public String getAttributePrefix(int arg) throws OMException {
+        return parser.getAttributeNamespace(arg);
+    }
+
+    public Object getParser() {
+        if (!cache) {
+            parserAccessed = true;
+            return parser;
+        } else {
+            throw new UnsupportedOperationException("cache must be switched off to access the parser");
+        }
+    }
+
+    public boolean isCompleted() {
+        return done;
+    }
+
+    /**
+     * This method will be called with the XMLStreamConstants.START_ELEMENT
+     * event
+     *
+     * @return
+     * @throws OMException
+     */
+    protected abstract OMNode createOMElement() throws OMException;
+
+    /**
+     * This should proceed the parser one step further, if parser is not
+     * completed yet. If this has been called whist parser is done, then throw
+     * an OMException.
+     * <p/>
+     * If the cache is set to false, then should be return the event, *without*
+     * building the OM tree.
+     * <p/>
+     * If the cache is set to true, then this should handle all the events
+     * within this, and should build the object structure appropriately and
+     * return the event.
+     *
+     * @return
+     * @throws OMException
+     */
+    public abstract int next() throws OMException;
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/builder/StAXOMBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/builder/StAXOMBuilder.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/builder/StAXOMBuilder.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/builder/StAXOMBuilder.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,194 @@
+package org.apache.axis.impl.llom.builder;
+
+import org.apache.axis.impl.llom.OMDocument;
+import org.apache.axis.impl.llom.OMElementImpl;
+import org.apache.axis.impl.llom.mtom.OMBlob;
+import org.apache.axis.om.*;
+
+import javax.xml.stream.XMLStreamConstants;
+import java.io.InputStream;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ */
+
+/**
+ * This will construct an OM without using SOAP specific classes like
+ * SOAPEnvelope, SOAPHeader, SOAPHeaderBlock and SOAPBody. And this will habe
+ * the Document concept also.
+ */
+public class StAXOMBuilder extends StAXBuilder implements OMXMLParserWrapper {
+    protected OMDocument document;
+
+    /*
+     * Edited by Thilina Gunarathne
+     */
+    public StAXOMBuilder(OMFactory ombuilderFactory, InputStream stream) {
+        super(ombuilderFactory, stream);
+        document = new OMDocument(this);
+    }
+
+    public StAXOMBuilder(InputStream stream) {
+        super(stream);
+        document = new OMDocument(this);
+    }
+
+    protected OMNode createOMElement() throws OMException {
+
+        String elementName = parser.getLocalName();
+        String namespaceURI = parser.getNamespaceURI();
+
+        if (elementName.equalsIgnoreCase("Include")
+                & namespaceURI
+                .equalsIgnoreCase("http://www.w3.org/2004/08/xop/include")) {
+            OMBlob node;
+            String CID = null;
+            String CIDName = null;
+            boolean found = false;
+            OMAttribute Attr;
+
+            CID = parser.getAttributeValue(0);
+            CID = CID.trim();
+            CIDName = parser.getAttributeLocalName(0);
+            if (CIDName.equalsIgnoreCase("href")
+                    & CID.substring(0, 3).equalsIgnoreCase("cid")) {
+                CID = CID.substring(4);
+                found = true;
+            }
+
+            if (found) {
+                if (lastNode.isComplete()) {
+                    node = new OMBlob(CID, lastNode.getParent(), MtomBuilder);
+                    lastNode.setNextSibling(node);
+                    node.setPreviousSibling(lastNode);
+                } else {
+                    OMElement e = (OMElement) lastNode;
+                    node = new OMBlob(CID, (OMElement) lastNode, MtomBuilder);
+                    e.setFirstChild(node);
+                }
+            } else {
+                throw new OMException("CID not Found");
+            }
+            return node;
+        } else {
+            OMElement node;
+            if (lastNode == null) {
+                node = new OMElementImpl(elementName, null, null, this);
+                document.setRootElement(node);
+            } else if (lastNode.isComplete()) {
+                node = new OMElementImpl(elementName, null, lastNode
+                        .getParent(), this);
+                lastNode.setNextSibling(node);
+                node.setPreviousSibling(lastNode);
+            } else {
+                OMElement e = (OMElement) lastNode;
+                node = new OMElementImpl(elementName, null,
+                        (OMElement) lastNode, this);
+                e.setFirstChild(node);
+            }
+
+            //create the namespaces
+            processNamespaceData(node, false);
+
+            //fill in the attributes
+            processAttributes(node);
+
+            return node;
+        }
+    }
+
+    /*
+     * Edit Over
+     */
+
+    public SOAPEnvelope getOMEnvelope() throws OMException {
+        throw new UnsupportedOperationException(); //TODO implement this
+    }
+
+    public int next() throws OMException {
+        try {
+
+            if (done)
+                throw new OMException();
+
+            int token = parser.next();
+
+            if (!cache) {
+                return token;
+            }
+
+            switch (token) {
+                case XMLStreamConstants.START_ELEMENT:
+                    lastNode = createOMElement();
+                    break;
+
+                case XMLStreamConstants.START_DOCUMENT:
+                    document = new OMDocument(this);
+                    break;
+
+                case XMLStreamConstants.CHARACTERS:
+                    lastNode = createOMText();
+                    break;
+
+                case XMLStreamConstants.END_ELEMENT:
+                    if (lastNode.isComplete()) {
+                        OMElement parent = lastNode.getParent();
+                        parent.setComplete(true);
+                        lastNode = parent;
+                    } else {
+                        OMNode e = (OMNode) lastNode;
+                        e.setComplete(true);
+                    }
+                    break;
+
+                case XMLStreamConstants.END_DOCUMENT:
+                    done = true;
+
+                    break;
+                case XMLStreamConstants.SPACE:
+                    next();
+                    break;
+
+                default:
+                    throw new OMException();
+            }
+            return token;
+        } catch (OMException e) {
+            throw e;
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new OMException(e);
+        }
+    }
+
+    public OMElement getDocumentElement() {
+        return document.getRootElement();
+    }
+
+    protected void processNamespaceData(OMElement node, boolean isSOAPElement) {
+        int namespaceCount = parser.getNamespaceCount();
+        for (int i = 0; i < namespaceCount; i++) {
+            node.declareNamespace(parser.getNamespaceURI(i), parser
+                    .getNamespacePrefix(i));
+        }
+
+        //set the own namespace
+        OMNamespace namespace = node.findInScopeNamespace(parser
+                .getNamespaceURI(), parser.getPrefix());
+        node.setNamespace(namespace);
+    }
+
+}
\ No newline at end of file

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/MTOMException.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/MTOMException.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/MTOMException.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/MTOMException.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,11 @@
+package org.apache.axis.impl.llom.exception;
+
+/**
+ * @author Thilina Gunarathne thil747@yahoo.com
+ */
+
+public class MTOMException extends Exception {
+    public MTOMException(String s) {
+        super(s);
+    }
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMBuilderException.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMBuilderException.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMBuilderException.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMBuilderException.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,25 @@
+package org.apache.axis.impl.llom.exception;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation Date: Nov 22, 2004 Time:
+ * 10:43:32 AM
+ */
+public class OMBuilderException extends Exception {
+    public OMBuilderException(String s) {
+        super(s);
+    }
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMSerializerException.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMSerializerException.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMSerializerException.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMSerializerException.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,22 @@
+package org.apache.axis.impl.llom.exception;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation Date: Nov 18, 2004 Time:
+ * 12:14:23 PM
+ */
+public class OMSerializerException extends Exception {
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMStreamingException.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMStreamingException.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMStreamingException.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMStreamingException.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,37 @@
+package org.apache.axis.impl.llom.exception;
+
+import org.apache.axis.om.OMException;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ *
+ * @author Axis team Date: Nov 18, 2004 Time: 1:54:11 PM
+ */
+public class OMStreamingException extends OMException {
+    public OMStreamingException() {
+    }
+
+    public OMStreamingException(String message) {
+        super(message);
+    }
+
+    public OMStreamingException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public OMStreamingException(Throwable cause) {
+        super(cause);
+    }
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/XMLStreamException.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/XMLStreamException.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/XMLStreamException.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/XMLStreamException.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,22 @@
+package org.apache.axis.impl.llom.exception;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation Date: Nov 18, 2004 Time:
+ * 12:13:54 PM
+ */
+public class XMLStreamException extends Exception {
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/factory/OMLinkedListImplFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/factory/OMLinkedListImplFactory.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/factory/OMLinkedListImplFactory.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/factory/OMLinkedListImplFactory.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,131 @@
+package org.apache.axis.impl.llom.factory;
+
+import org.apache.axis.impl.llom.*;
+import org.apache.axis.om.*;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ */
+public class OMLinkedListImplFactory extends OMFactory {
+    public OMAttribute createOMAttribute(String localName, OMNamespace ns, String value) {
+        return new OMAttributeImpl(localName, ns, value);
+    }
+
+    public OMElement createOMElement(OMElement parent) {
+        return new OMElementImpl(parent);
+    }
+
+    public OMElement createOMElement(String localName, OMNamespace ns) {
+        return new OMElementImpl(localName, ns);
+    }
+
+    public OMElement createOMElement(String localName, OMNamespace ns, OMElement parent, OMXMLParserWrapper builder) {
+        return new OMElementImpl(localName, ns, parent, builder);
+    }
+
+    public OMNamedNode createOMNamedNode(String localName, OMNamespace ns, OMElement parent) {
+        return new OMNamedNodeImpl(localName, ns, parent);
+    }
+
+    public OMNamedNode createOMNamedNode(OMElement parent) {
+        return new OMNamedNodeImpl(parent);
+    }
+
+    public OMNamespace createOMNamespace(String uri, String prefix) {
+        return new OMNamespaceImpl(uri, prefix);
+    }
+
+    public OMNode createOMNode(OMElement parent) {
+        return new OMNodeImpl(parent);
+    }
+
+    public OMText createText(OMElement parent, String text) {
+        return new OMTextImpl(parent, text);
+    }
+
+    public OMText createText(String s) {
+        return new OMTextImpl(s);
+    }
+
+    public SOAPBody createSOAPBody(SOAPEnvelope envelope) {
+        return new SOAPBodyImpl(envelope);
+    }
+
+    public SOAPBody createSOAPBody(String localName, OMNamespace ns, OMElement parent, OMXMLParserWrapper builder) {
+        return new SOAPBodyImpl(localName, ns, parent, builder);
+    }
+
+    public SOAPEnvelope createSOAPEnvelope(String localName, OMNamespace ns, OMElement parent, OMXMLParserWrapper builder) {
+        if (!localName.equals(OMConstants.SOAPENVELOPE_LOCAL_NAME)) {
+            throw new OMException("wrong name for the envelope!");
+        }
+        return new SOAPEnvelopeImpl(localName, ns, parent, builder);
+
+    }
+
+    public SOAPEnvelope createSOAPEnvelope(String localName, OMNamespace ns) {
+        return new SOAPEnvelopeImpl(localName, ns);
+    }
+
+    public SOAPEnvelope createOMEnvelope(OMXMLParserWrapper parserWrapper) {
+        throw new UnsupportedOperationException(); //TODO implement this
+    }
+
+    //TODO there should be a method to create an SOAPEnvelope giving OMXMLParserWrapper, as OMMessage is no longer there
+
+    public SOAPHeader createSOAPHeader(SOAPEnvelope envelope) {
+        return new SOAPHeaderImpl(envelope);
+    }
+
+    public SOAPHeader createSOAPHeader(String localName, OMNamespace ns, OMElement parent, OMXMLParserWrapper builder) {
+        return new SOAPHeaderImpl(localName, ns, parent, builder);
+    }
+
+    public SOAPHeaderBlock createSOAPHeaderBlock(String localName, OMNamespace ns) {
+        return new SOAPHeaderBlockImpl(localName, ns);
+    }
+
+    public SOAPHeaderBlock createSOAPHeaderBlock(String localName, OMNamespace ns, OMElement parent, OMXMLParserWrapper builder) {
+        return new SOAPHeaderBlockImpl(localName, ns, parent, builder);
+    }
+
+    public SOAPFault createSOAPFault(SOAPBody parent, Exception e) {
+        return new SOAPFaultImpl(parent, e);
+    }
+
+    public SOAPFault createSOAPFault(OMNamespace ns, SOAPBody parent, OMXMLParserWrapper builder) {
+        return new SOAPFaultImpl(ns, parent, builder);
+    }
+
+    public SOAPEnvelope getDefaultEnvelope() {
+        //Create an envelop
+        OMNamespace ns = new OMNamespaceImpl(OMConstants.SOAP_ENVELOPE_NAMESPACE_URI, OMConstants.SOAPENVELOPE_NAMESPACE_PREFIX);
+        SOAPEnvelopeImpl env = new SOAPEnvelopeImpl(OMConstants.SOAPENVELOPE_LOCAL_NAME, ns);
+
+        SOAPBodyImpl bodyImpl = new SOAPBodyImpl(env);
+        bodyImpl.setComplete(true);
+        env.addChild(bodyImpl);
+
+        SOAPHeaderImpl headerImpl = new SOAPHeaderImpl(env);
+        headerImpl.setComplete(true);
+        env.addChild(headerImpl);
+
+        return env;
+
+
+    }
+
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/AttachmentPart.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/AttachmentPart.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/AttachmentPart.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/AttachmentPart.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,32 @@
+/*
+ * Created on Mar 2, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.axis.impl.llom.mtom;
+
+/**
+ * @author THilina Gunarathne
+ *         <p/>
+ *         TODO To change the template for this generated type comment go to
+ *         Window - Preferences - Java - Code Style - Code Templates
+ */
+public class AttachmentPart {
+    String cid;
+    OMBlob blob;
+
+    public AttachmentPart(String cid, OMBlob blob) {
+        this.cid = cid;
+        this.blob = blob;
+    }
+
+    public String getCid() {
+        return cid;
+    }
+
+    public OMBlob getBlob() {
+        return blob;
+    }
+
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/ByteArrayDataSource.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/ByteArrayDataSource.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/ByteArrayDataSource.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/ByteArrayDataSource.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,61 @@
+package org.apache.axis.impl.llom.mtom;
+
+import javax.activation.DataSource;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ */
+
+/**
+ * @author Thilina Gunarathne
+ */
+public class ByteArrayDataSource implements DataSource {
+
+    private byte[] data;
+
+    private String type;
+
+    public ByteArrayDataSource(byte[] data, String type) {
+        super();
+        this.data = data;
+        this.type = type;
+    }
+
+    public String getContentType() {
+        if (type == null)
+            return "application/octet-stream";
+        else
+            return type;
+    }
+
+    public InputStream getInputStream() throws IOException {
+        return new ByteArrayInputStream(data);
+    }
+
+    public String getName() {
+
+        return "ByteArrayDataSource";
+    }
+
+    public OutputStream getOutputStream() throws IOException {
+        throw new IOException("Not Supported");
+    }
+}
+

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEBodyPartInputStream.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEBodyPartInputStream.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEBodyPartInputStream.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEBodyPartInputStream.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,83 @@
+package org.apache.axis.impl.llom.mtom;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ */
+
+/**
+ * @author Thilina Gunarathne thil747@yahoo.com
+ */
+
+public class MIMEBodyPartInputStream extends InputStream {
+
+    MIMEInputStream inStream;
+
+    String boundry;
+
+    boolean done = false;
+
+    boolean began = false;
+
+    public MIMEBodyPartInputStream(MIMEInputStream inStream, String boundry) {
+        super();
+        this.inStream = inStream;
+        this.boundry = boundry;
+
+    }
+
+    public int read() throws IOException {
+
+        if (done) {
+            return -1;
+        } else {
+            int value = 0;
+            String line = "";
+
+            value = inStream.read();
+
+            while (value == 13 & !began) {
+                value = inStream.read();
+                value = inStream.read();
+            }
+            began = true;
+
+            char readChar = (char) value;
+            if (readChar == '-') {
+                inStream.mark();
+                char readNextChar = ' ';
+
+                readNextChar = (char) inStream.read();
+
+                if (readNextChar == '-') {
+                    line = inStream.read(boundry.length());
+                    if (line.equals(boundry)) {
+                        done = true;
+                        return -1;
+
+                    } else {
+                        inStream.reset();
+                    }
+                } else {
+                    inStream.reset();
+                }
+            }
+            return value;
+        }
+    }
+}
\ No newline at end of file

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEInputStream.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEInputStream.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEInputStream.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEInputStream.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,121 @@
+package org.apache.axis.impl.llom.mtom;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.LinkedList;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ */
+
+/**
+ * @author Thilina Gunarathne thil747@yahoo.com
+ */
+
+public class MIMEInputStream extends InputStream {
+
+    InputStream inStream;
+
+    LinkedList buffer;
+
+    boolean mark = false;
+
+    boolean reset = false;
+
+    int point = 0;
+
+    public MIMEInputStream(InputStream inStream) {
+        super();
+        this.inStream = inStream;
+        buffer = new LinkedList();
+    }
+
+    public int read() throws IOException {
+        int temp = readMain();
+        return temp;
+    }
+
+    public String readLine() throws IOException {
+        String line = "";
+        char character = ' ';
+        do {
+            try {
+                character = (char) readMain();
+                line += character;
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        } while (character != '\n');
+
+        return line;
+    }
+
+    public String read(int length) throws IOException {
+        String line = "";
+        char character = ' ';
+        for (int i = 0; i < length; i++) {
+            character = (char) readMain();
+            line += character;
+        }
+        return line;
+    }
+
+    public int readMain() throws IOException {
+        int temp;
+        if (mark & reset) {
+            Integer byteOb = (Integer) buffer.get(point);
+            temp = byteOb.intValue();
+            if (buffer.get(point).equals(buffer.getLast())) {
+                reset = false;
+                point = 0;
+            } else {
+                point++;
+            }
+        } else if (mark) {
+            temp = inStream.read();
+            buffer.add(new Integer(temp));
+        } else if (reset) {
+            if (buffer.isEmpty()) {
+                reset = false;
+                temp = inStream.read();
+            } else {
+                Integer byteOb = (Integer) buffer.getFirst();
+                temp = byteOb.intValue();
+                buffer.removeFirst();
+            }
+        } else {
+            temp = inStream.read();
+        }
+        return temp;
+    }
+
+    public void mark() {
+        if (!reset) {
+            buffer.clear();
+        }
+        mark = true;
+    }
+
+    public void reset() throws IOException {
+        if (mark) {
+            reset = true;
+            mark = false;
+            point = 0;
+        } else {
+            throw new IOException("not marked");
+        }
+    }
+}
\ No newline at end of file

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEParser.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEParser.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEParser.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEParser.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,176 @@
+package org.apache.axis.impl.llom.mtom;
+
+import javax.activation.DataHandler;
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+import javax.mail.internet.MimePartDataSource;
+import java.io.InputStream;
+import java.util.Properties;
+
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ */
+
+/**
+ * @author Thilina Gunarathne thil747@yahoo.com
+ */
+public class MIMEParser {
+
+    int partIndex = 0;
+    MIMEInputStream in;
+
+    String mimeVersion;
+
+    String contentType;
+
+    boolean messageMime;
+
+    String boundry;
+
+    boolean complete = false;
+
+    String start;
+    MimeMessage message;
+
+    public MIMEParser(InputStream inStream) {
+
+        Properties props = new Properties();
+        javax.mail.Session session = javax.mail.Session.getInstance(props, null);
+        try {
+            message = new MimeMessage(session, inStream);
+            messageMime = true;
+            //in = new MIMEInputStream(inStream);
+        } catch (MessagingException e) {
+            messageMime = false;
+        }
+    }
+
+    public boolean mimeMessage() {
+        return messageMime;
+/*		String line = null;
+		char readChar = ' ';
+		boolean found = false;
+		int startIndex, finishIndex, valueFinishIndex;
+		
+		//Start processing the Mime Header
+		try {
+			in.readLine();
+			line = in.readLine();
+		} catch (Exception e) {
+			System.out.println(e);
+		}
+		
+		line = line.trim();
+		String[] versionArray = line.split(":");
+		
+		//Extracts and stores MIME version information
+		if (versionArray[0].equalsIgnoreCase("MIME-Version")) {
+			mimeVersion = versionArray[1];
+			
+			/*
+			 * extract the Mime boundry
+			 */
+/*			do {
+				try {
+					line = in.readLine();
+				} catch (Exception e) {
+					System.out.println(e);
+				}
+				
+				//extracting the mime boundry string
+				startIndex = line.indexOf("boundary=");
+			} while (startIndex == -1);
+			
+			finishIndex = (startIndex + ("boundary=").length());
+			valueFinishIndex = line.indexOf(";", finishIndex);
+			
+			if (valueFinishIndex > 0) {
+				boundry = line.substring(finishIndex, valueFinishIndex);
+			} else {
+				boundry = line.substring(finishIndex);
+			}
+			boundry = boundry.replace('"', ' ');
+			boundry = boundry.trim();
+			
+			/*
+			 * Move the input stream to the begining of the MIME root part
+			 */
+/*			do {
+				try {
+					in.mark(boundry.length() + 5);
+					readChar = (char) in.read();
+				} catch (Exception e) {
+					System.out.println(e);
+				}
+				if (readChar == '-') {
+					char readNextChar = ' ';
+					try {
+						readNextChar = (char) in.read();
+					} catch (IOException e3) {
+						e3.printStackTrace();
+					}
+					
+					if (readNextChar == '-') {
+						char[] cBuf = new char[boundry.length()];
+						
+						try {
+							line = in.read(boundry.length());
+						} catch (IOException e1) {
+							e1.printStackTrace();
+						}
+						
+						if (line.equals(boundry)) {
+							found = true;
+						} else {
+							try {
+								in.reset();
+							} catch (IOException e2) {
+								e2.printStackTrace();
+							}
+						}
+					}
+				}
+			} while (!found);
+			return true;
+		} else {
+			return false;
+		}*/
+    }
+
+    public MimeBodyPart getPart() throws Exception {
+        MimeBodyPart part = null;
+        /*
+        if (!complete) {
+
+            MIMEBodyPartInputStream partStream = new MIMEBodyPartInputStream(
+                    in, boundry);
+            part = new MimeBodyPart(partStream);
+            if (part.getSize() == 0 | part.getSize() < 0) {
+                complete = true;
+                return null;
+            }
+        }*/
+        DataHandler dh = message.getDataHandler();
+        MimeMultipart multiPart = new MimeMultipart((MimePartDataSource) dh.getDataSource());
+        part = (MimeBodyPart) multiPart.getBodyPart(partIndex);
+
+        partIndex++;
+        return part;
+    }
+}
\ No newline at end of file

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MTOMBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MTOMBuilder.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MTOMBuilder.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MTOMBuilder.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,114 @@
+package org.apache.axis.impl.llom.mtom;
+
+import javax.activation.DataHandler;
+import javax.mail.internet.MimeBodyPart;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import java.io.InputStream;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ */
+
+/**
+ * @author Thilina Gunarathne thil747@yahoo.com
+ */
+public class MTOMBuilder {
+    LinkedList parts;
+
+    InputStream inStream;
+
+    MIMEParser parser;
+
+    public MTOMBuilder(InputStream inStream) {
+        this.inStream = inStream;
+        this.parser = new MIMEParser(inStream);
+        parts = new LinkedList();
+    }
+
+    public/* Serializable */DataHandler getDataHandler(String cid)
+            throws Exception {
+        /*
+         * First checks whether the part is already parsed by checking the parts
+         * linked list. If it is not parsed yet then call the getnextPart() till
+         * we find the required part.
+         */
+        MimeBodyPart part;
+
+        boolean found = false;
+        ListIterator partsIterator = parts.listIterator();
+        while (partsIterator.hasNext()) {
+            part = (MimeBodyPart) partsIterator.next();
+            if (cid.equals(part.getContentID())) {
+                found = true;
+                DataHandler dh = part.getDataHandler();
+                return dh;
+            }
+        }
+        while (!found) {
+            part = this.getNextPart();
+
+            if (part == null) {
+                break;
+            }
+            String partCid = part.getContentID();
+            String cida = "<" + cid + ">";
+            if (cida.equals(partCid)) {
+                found = true;
+                DataHandler dh = part.getDataHandler();
+                return dh;
+            }
+        }
+        return null;
+    }
+
+    public XMLStreamReader getParser() throws Exception {
+
+        if (parser.mimeMessage()) {
+            MimeBodyPart root = getRoot();
+            return XMLInputFactory.newInstance().createXMLStreamReader(root.getInputStream());
+        } else {
+            return XMLInputFactory.newInstance()
+                    .createXMLStreamReader(inStream);
+        }
+    }
+
+    public MimeBodyPart getRoot() throws Exception {
+        MimeBodyPart root;
+        if (parts.isEmpty()) {
+            root = parser.getPart();
+            parts.add(root);
+        } else {
+            root = (MimeBodyPart) parts.getFirst();
+        }
+        System.out.println("MIME root parsed. NO of parts parsed :" + parts.size());
+        return root;
+    }
+
+    public MimeBodyPart getNextPart() throws Exception {
+        MimeBodyPart nextPart;
+        nextPart = parser.getPart();
+        if (nextPart != null) {
+            parts.add(nextPart);
+            System.out.println("Next part parsed. NO of parts parsed :" + parts.size());
+            return nextPart;
+        } else
+            return null;
+    }
+
+}
\ No newline at end of file