You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ve...@apache.org on 2005/06/03 16:26:14 UTC

svn commit: r179797 - in /webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance: ./ XMLConformanceTestingProject/src/org/apache/axis/encoding/ XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/

Author: venkat
Date: Fri Jun  3 07:26:13 2005
New Revision: 179797

URL: http://svn.apache.org/viewcvs?rev=179797&view=rev
Log:
some more updates for infoset and xml conformance stuff.

Added:
    webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/encoding/Base64.java
    webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/ByteArrayDataSource.java
    webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/DataHandlerImpl.java
    webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/DataSourceImpl.java
    webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/MTOMStAXSOAPModelBuilder.java
    webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/MTOMXMLStreamWriter.java
    webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/OMBlob.java
    webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/OMBlobImpl.java
Modified:
    webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/Readme.txt

Modified: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/Readme.txt
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/Readme.txt?rev=179797&r1=179796&r2=179797&view=diff
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/Readme.txt (original)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/Readme.txt Fri Jun  3 07:26:13 2005
@@ -1,6 +1,7 @@
+
 This is a readme file explaining the contents of this folder.
 
-The folder XMLConformanceTestingProject contains an eclipse project that is used to do the testing. It can be readily loaded as a java project in IDE to quickly rerun the test. (Jar files location might have to be changed).
+The folder XMLConformanceTestingWork contains source and test contents that I used to do the infoset support testing. eclipse project files are also provided so that it can be readily loaded as a java project in IDE to quickly rerun the test. (Jar files location might have to be changed).
 And coming to the OM code in there. I have tweaked OM quite a bit to add OMPI and OMComment functionality and also some minimalistic functionality for DTD support. Actually DTD support that exists in it is just a stupid implementation which treats a DTD element as a normal text element, captures it as a text of characters as is only to vomit it out at the time of serialization. Yeah! it's an utterly naive implementation but then I did so atleast to get away with some basic blockages that DTD elements are causing during parsing itself.
 
 As part of this tweaking some files have been modified/added, here follows a list of them
@@ -29,7 +30,7 @@
 org/apache/axis/om/impl/llom/OMDTDImpl.java
 
 
-Apart from these the testing code is under the 'junittesting' package inside the project. The file XMLConformanceTest.java has the latest code I used to test the parsing and serialization stuff. The content of wiki is pretty outdated and this is the final one.
+Apart from these the testing code is under the 'org.apache.axis.om' package inside the project. The file XMLConformanceTest.java has the latest code I used to test the parsing and serialization stuff. The content of wiki is pretty outdated and this is the final one.
 
-** The XMLSuite.jar provided here is a zip of a directory that contains only the valid version 1.0 compliant XML files
-** For those who want to rerun the tests and see the results, please edit the location of the XMLSuite directory (line 48 of junittesting.XMLConformanecTest) to the location where you would unzip this XMLSuite.zip given here.
+** The XMLSuite.zip provided here is a zip of a directory that contains only the valid version 1.0 compliant XML files
+** For those who want to rerun the tests and see the results, please edit the location of the XMLSuite directory (line 50 of org.apache.axis.om.infoset.XMLConformanecTest under test directory) to the location where you would unzip this XMLSuite.zip given here.

Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/encoding/Base64.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/encoding/Base64.java?rev=179797&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/encoding/Base64.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/encoding/Base64.java Fri Jun  3 07:26:13 2005
@@ -0,0 +1,296 @@
+ /*
+ * Copyright 2001-2004 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.axis.encoding;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+
+/**
+ * @author TAMURA Kent <kent@trl.ibm.co.jp>
+ */
+public class Base64 {
+    private static final char[] S_BASE64CHAR = { 'A', 'B', 'C', 'D', 'E', 'F',
+            'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
+            'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
+            'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
+            't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5',
+            '6', '7', '8', '9', '+', '/' };
+
+    private static final char S_BASE64PAD = '=';
+
+    private static final byte[] S_DECODETABLE = new byte[128];
+
+    static {
+        for (int i = 0; i < S_DECODETABLE.length; i++)
+            S_DECODETABLE[i] = Byte.MAX_VALUE; // 127
+        for (int i = 0; i < S_BASE64CHAR.length; i++)
+            // 0 to 63
+            S_DECODETABLE[S_BASE64CHAR[i]] = (byte) i;
+    }
+
+    private static int decode0(char[] ibuf, byte[] obuf, int wp) {
+        int outlen = 3;
+        if (ibuf[3] == S_BASE64PAD)
+            outlen = 2;
+        if (ibuf[2] == S_BASE64PAD)
+            outlen = 1;
+        int b0 = S_DECODETABLE[ibuf[0]];
+        int b1 = S_DECODETABLE[ibuf[1]];
+        int b2 = S_DECODETABLE[ibuf[2]];
+        int b3 = S_DECODETABLE[ibuf[3]];
+        switch (outlen) {
+        case 1:
+            obuf[wp] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3);
+            return 1;
+        case 2:
+            obuf[wp++] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3);
+            obuf[wp] = (byte) (b1 << 4 & 0xf0 | b2 >> 2 & 0xf);
+            return 2;
+        case 3:
+            obuf[wp++] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3);
+            obuf[wp++] = (byte) (b1 << 4 & 0xf0 | b2 >> 2 & 0xf);
+            obuf[wp] = (byte) (b2 << 6 & 0xc0 | b3 & 0x3f);
+            return 3;
+        default:
+            throw new RuntimeException("internalError00");
+        }
+    }
+
+    /**
+     *  
+     */
+    public static byte[] decode(char[] data, int off, int len) {
+        char[] ibuf = new char[4];
+        int ibufcount = 0;
+        byte[] obuf = new byte[len / 4 * 3 + 3];
+        int obufcount = 0;
+        for (int i = off; i < off + len; i++) {
+            char ch = data[i];
+            if (ch == S_BASE64PAD || ch < S_DECODETABLE.length
+                    && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
+                ibuf[ibufcount++] = ch;
+                if (ibufcount == ibuf.length) {
+                    ibufcount = 0;
+                    obufcount += decode0(ibuf, obuf, obufcount);
+                }
+            }
+        }
+        if (obufcount == obuf.length)
+            return obuf;
+        byte[] ret = new byte[obufcount];
+        System.arraycopy(obuf, 0, ret, 0, obufcount);
+        return ret;
+    }
+
+    /**
+     *  
+     */
+    public static byte[] decode(String data) {
+        char[] ibuf = new char[4];
+        int ibufcount = 0;
+        byte[] obuf = new byte[data.length() / 4 * 3 + 3];
+        int obufcount = 0;
+        for (int i = 0; i < data.length(); i++) {
+            char ch = data.charAt(i);
+            if (ch == S_BASE64PAD || ch < S_DECODETABLE.length
+                    && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
+                ibuf[ibufcount++] = ch;
+                if (ibufcount == ibuf.length) {
+                    ibufcount = 0;
+                    obufcount += decode0(ibuf, obuf, obufcount);
+                }
+            }
+        }
+        if (obufcount == obuf.length)
+            return obuf;
+        byte[] ret = new byte[obufcount];
+        System.arraycopy(obuf, 0, ret, 0, obufcount);
+        return ret;
+    }
+
+    /**
+     *  
+     */
+    public static void decode(char[] data, int off, int len,
+            OutputStream ostream) throws IOException {
+        char[] ibuf = new char[4];
+        int ibufcount = 0;
+        byte[] obuf = new byte[3];
+        for (int i = off; i < off + len; i++) {
+            char ch = data[i];
+            if (ch == S_BASE64PAD || ch < S_DECODETABLE.length
+                    && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
+                ibuf[ibufcount++] = ch;
+                if (ibufcount == ibuf.length) {
+                    ibufcount = 0;
+                    int obufcount = decode0(ibuf, obuf, 0);
+                    ostream.write(obuf, 0, obufcount);
+                }
+            }
+        }
+    }
+
+    /**
+     *  
+     */
+    public static void decode(String data, OutputStream ostream)
+            throws IOException {
+        char[] ibuf = new char[4];
+        int ibufcount = 0;
+        byte[] obuf = new byte[3];
+        for (int i = 0; i < data.length(); i++) {
+            char ch = data.charAt(i);
+            if (ch == S_BASE64PAD || ch < S_DECODETABLE.length
+                    && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
+                ibuf[ibufcount++] = ch;
+                if (ibufcount == ibuf.length) {
+                    ibufcount = 0;
+                    int obufcount = decode0(ibuf, obuf, 0);
+                    ostream.write(obuf, 0, obufcount);
+                }
+            }
+        }
+    }
+
+    /**
+     * Returns base64 representation of specified byte array.
+     */
+    public static String encode(byte[] data) {
+        return encode(data, 0, data.length);
+    }
+
+    /**
+     * Returns base64 representation of specified byte array.
+     */
+    public static String encode(byte[] data, int off, int len) {
+        if (len <= 0)
+            return "";
+        char[] out = new char[len / 3 * 4 + 4];
+        int rindex = off;
+        int windex = 0;
+        int rest = len - off;
+        while (rest >= 3) {
+            int i = ((data[rindex] & 0xff) << 16)
+                    + ((data[rindex + 1] & 0xff) << 8)
+                    + (data[rindex + 2] & 0xff);
+            out[windex++] = S_BASE64CHAR[i >> 18];
+            out[windex++] = S_BASE64CHAR[(i >> 12) & 0x3f];
+            out[windex++] = S_BASE64CHAR[(i >> 6) & 0x3f];
+            out[windex++] = S_BASE64CHAR[i & 0x3f];
+            rindex += 3;
+            rest -= 3;
+        }
+        if (rest == 1) {
+            int i = data[rindex] & 0xff;
+            out[windex++] = S_BASE64CHAR[i >> 2];
+            out[windex++] = S_BASE64CHAR[(i << 4) & 0x3f];
+            out[windex++] = S_BASE64PAD;
+            out[windex++] = S_BASE64PAD;
+        } else if (rest == 2) {
+            int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff);
+            out[windex++] = S_BASE64CHAR[i >> 10];
+            out[windex++] = S_BASE64CHAR[(i >> 4) & 0x3f];
+            out[windex++] = S_BASE64CHAR[(i << 2) & 0x3f];
+            out[windex++] = S_BASE64PAD;
+        }
+        return new String(out, 0, windex);
+    }
+
+    /**
+     * Outputs base64 representation of the specified byte array to a byte
+     * stream.
+     */
+    public static void encode(byte[] data, int off, int len,
+            OutputStream ostream) throws IOException {
+        if (len <= 0)
+            return;
+        byte[] out = new byte[4];
+        int rindex = off;
+        int rest = len - off;
+        while (rest >= 3) {
+            int i = ((data[rindex] & 0xff) << 16)
+                    + ((data[rindex + 1] & 0xff) << 8)
+                    + (data[rindex + 2] & 0xff);
+            out[0] = (byte) S_BASE64CHAR[i >> 18];
+            out[1] = (byte) S_BASE64CHAR[(i >> 12) & 0x3f];
+            out[2] = (byte) S_BASE64CHAR[(i >> 6) & 0x3f];
+            out[3] = (byte) S_BASE64CHAR[i & 0x3f];
+            ostream.write(out, 0, 4);
+            rindex += 3;
+            rest -= 3;
+        }
+        if (rest == 1) {
+            int i = data[rindex] & 0xff;
+            out[0] = (byte) S_BASE64CHAR[i >> 2];
+            out[1] = (byte) S_BASE64CHAR[(i << 4) & 0x3f];
+            out[2] = (byte) S_BASE64PAD;
+            out[3] = (byte) S_BASE64PAD;
+            ostream.write(out, 0, 4);
+        } else if (rest == 2) {
+            int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff);
+            out[0] = (byte) S_BASE64CHAR[i >> 10];
+            out[1] = (byte) S_BASE64CHAR[(i >> 4) & 0x3f];
+            out[2] = (byte) S_BASE64CHAR[(i << 2) & 0x3f];
+            out[3] = (byte) S_BASE64PAD;
+            ostream.write(out, 0, 4);
+        }
+    }
+
+    /**
+     * Outputs base64 representation of the specified byte array to a character
+     * stream.
+     */
+    public static void encode(byte[] data, int off, int len, Writer writer)
+            throws IOException {
+        if (len <= 0)
+            return;
+        char[] out = new char[4];
+        int rindex = off;
+        int rest = len - off;
+        int output = 0;
+        while (rest >= 3) {
+            int i = ((data[rindex] & 0xff) << 16)
+                    + ((data[rindex + 1] & 0xff) << 8)
+                    + (data[rindex + 2] & 0xff);
+            out[0] = S_BASE64CHAR[i >> 18];
+            out[1] = S_BASE64CHAR[(i >> 12) & 0x3f];
+            out[2] = S_BASE64CHAR[(i >> 6) & 0x3f];
+            out[3] = S_BASE64CHAR[i & 0x3f];
+            writer.write(out, 0, 4);
+            rindex += 3;
+            rest -= 3;
+            output += 4;
+            if (output % 76 == 0)
+                writer.write("\n");
+        }
+        if (rest == 1) {
+            int i = data[rindex] & 0xff;
+            out[0] = S_BASE64CHAR[i >> 2];
+            out[1] = S_BASE64CHAR[(i << 4) & 0x3f];
+            out[2] = S_BASE64PAD;
+            out[3] = S_BASE64PAD;
+            writer.write(out, 0, 4);
+        } else if (rest == 2) {
+            int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff);
+            out[0] = S_BASE64CHAR[i >> 10];
+            out[1] = S_BASE64CHAR[(i >> 4) & 0x3f];
+            out[2] = S_BASE64CHAR[(i << 2) & 0x3f];
+            out[3] = S_BASE64PAD;
+            writer.write(out, 0, 4);
+        }
+    }
+}
\ No newline at end of file

Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/ByteArrayDataSource.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/ByteArrayDataSource.java?rev=179797&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/ByteArrayDataSource.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/ByteArrayDataSource.java Fri Jun  3 07:26:13 2005
@@ -0,0 +1,71 @@
+package org.apache.axis.om.impl.llom.mtom;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.activation.DataSource;
+
+/**
+ * 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 thilina@opensource.lk
+ */
+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 ByteArrayDataSource(byte[] data) {
+        super();
+        this.data = data;
+    }
+
+    public void setType(String type) {
+        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/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/DataHandlerImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/DataHandlerImpl.java?rev=179797&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/DataHandlerImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/DataHandlerImpl.java Fri Jun  3 07:26:13 2005
@@ -0,0 +1,173 @@
+/*
+ * 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.axis.om.impl.llom.mtom;
+
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.activation.CommandInfo;
+import javax.activation.CommandMap;
+import javax.activation.DataContentHandlerFactory;
+
+import org.apache.axis.encoding.Base64;
+import org.apache.axis.om.DataHandler;
+import org.apache.axis.om.DataSource;
+
+public class DataHandlerImpl implements DataHandler {
+    private javax.activation.DataHandler datahandler;
+    public DataHandlerImpl(javax.activation.DataHandler datahandler){
+        this.datahandler =datahandler;
+    }
+
+    public void init(String value, String mimeType) {
+
+        ByteArrayDataSource dataSource;
+        byte[] data = Base64.decode(value);
+        if (mimeType != null) {
+            dataSource = new ByteArrayDataSource(data, mimeType);
+        } else {
+            // Assumes type as application/octet-stream
+            dataSource = new ByteArrayDataSource(data);
+        }
+        datahandler = new javax.activation.DataHandler(dataSource);
+    }
+    /**
+     * @param arg0
+     */
+    public synchronized static void setDataContentHandlerFactory(DataContentHandlerFactory arg0) {
+        javax.activation.DataHandler.setDataContentHandlerFactory(arg0);
+    }
+
+    /**
+     * @return
+     */
+    public CommandInfo[] getAllCommands() {
+        return datahandler.getAllCommands();
+    }
+
+    /**
+     * @param arg0
+     * @return
+     */
+    public Object getBean(CommandInfo arg0) {
+        return datahandler.getBean(arg0);
+    }
+
+    /**
+     * @param arg0
+     * @return
+     */
+    public CommandInfo getCommand(String arg0) {
+        return datahandler.getCommand(arg0);
+    }
+
+    /**
+     * @return
+     * @throws java.io.IOException
+     */
+    public Object getContent() throws IOException {
+        return datahandler.getContent();
+    }
+
+    /**
+     * @return
+     */
+    public String getContentType() {
+        return datahandler.getContentType();
+    }
+
+    /**
+     * @return
+     */
+    public DataSource getDataSource() {
+        return new DataSourceImpl(datahandler.getDataSource());
+    }
+
+    /**
+     * @return
+     * @throws java.io.IOException
+     */
+    public InputStream getInputStream() throws IOException {
+        return datahandler.getInputStream();
+    }
+
+    /**
+     * @return
+     */
+    public String getName() {
+        return datahandler.getName();
+    }
+
+    /**
+     * @return
+     * @throws java.io.IOException
+     */
+    public OutputStream getOutputStream() throws IOException {
+        return datahandler.getOutputStream();
+    }
+
+    /**
+     * @return
+     */
+    public CommandInfo[] getPreferredCommands() {
+        return datahandler.getPreferredCommands();
+    }
+
+    /**
+     * @param flavor
+     * @return
+     * @throws java.awt.datatransfer.UnsupportedFlavorException
+     * @throws java.io.IOException
+     */
+    public Object getTransferData(DataFlavor flavor)
+        throws UnsupportedFlavorException, IOException {
+        return datahandler.getTransferData(flavor);
+    }
+
+    /**
+     * @return
+     */
+    public DataFlavor[] getTransferDataFlavors() {
+        return datahandler.getTransferDataFlavors();
+    }
+
+    /**
+     * @param flavor
+     * @return
+     */
+    public boolean isDataFlavorSupported(DataFlavor flavor) {
+        return datahandler.isDataFlavorSupported(flavor);
+    }
+
+    /**
+     * @param arg0
+     */
+    public synchronized void setCommandMap(CommandMap arg0) {
+        datahandler.setCommandMap(arg0);
+    }
+
+    /**
+     * @param arg0
+     * @throws java.io.IOException
+     */
+    public void writeTo(OutputStream arg0) throws IOException {
+        datahandler.writeTo(arg0);
+    }
+
+}

Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/DataSourceImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/DataSourceImpl.java?rev=179797&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/DataSourceImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/DataSourceImpl.java Fri Jun  3 07:26:13 2005
@@ -0,0 +1,66 @@
+/*
+ * 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.axis.om.impl.llom.mtom;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.axis.om.DataSource;
+
+
+
+
+public class DataSourceImpl implements DataSource {
+    
+    
+    private javax.activation.DataSource datasource;
+    
+    public DataSourceImpl(javax.activation.DataSource datasource){
+        this.datasource =datasource;
+    }
+    
+    /**
+     * @return
+     */
+    public String getContentType() {
+        return datasource.getContentType();
+    }
+
+    /**
+     * @return
+     * @throws java.io.IOException
+     */
+    public InputStream getInputStream() throws IOException {
+        return datasource.getInputStream();
+    }
+
+    /**
+     * @return
+     */
+    public String getName() {
+        return datasource.getName();
+    }
+
+    /**
+     * @return
+     * @throws java.io.IOException
+     */
+    public OutputStream getOutputStream() throws IOException {
+        return datasource.getOutputStream();
+    }
+
+}

Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/MTOMStAXSOAPModelBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/MTOMStAXSOAPModelBuilder.java?rev=179797&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/MTOMStAXSOAPModelBuilder.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/MTOMStAXSOAPModelBuilder.java Fri Jun  3 07:26:13 2005
@@ -0,0 +1,225 @@
+
+package org.apache.axis.om.impl.llom.mtom;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.LinkedList;
+import java.util.ListIterator;
+import java.util.Properties;
+
+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 javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axis.om.OMAttribute;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMException;
+import org.apache.axis.om.OMNode;
+import org.apache.axis.soap.SOAPFactory;
+import org.apache.axis.soap.impl.llom.builder.StAXSOAPModelBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author Thilina Gunarathne thilina@opensource.lk
+ */
+public class MTOMStAXSOAPModelBuilder extends StAXSOAPModelBuilder {
+    private Log log = LogFactory.getLog(getClass());
+    
+    InputStream inStream;
+    
+    LinkedList mimeBodyPartsList;
+    
+    MimeMessage mimeMessage;
+    
+    int partIndex = 0;
+    
+    public MTOMStAXSOAPModelBuilder(SOAPFactory ombuilderFactory,
+            InputStream inStream) throws XMLStreamException,
+            FactoryConfigurationError, OMException {
+                // Fix me SOON
+        super(null, ombuilderFactory);
+        this.inStream = inStream;
+        this.parser = getParserFromMime();
+    }
+    
+    public MTOMStAXSOAPModelBuilder(InputStream inStream)
+    throws XMLStreamException, FactoryConfigurationError, IOException,
+    MessagingException {
+        // TODO Fix me SOON
+        super(null);
+        this.inStream = inStream;
+        this.parser = getParserFromMime();
+    }
+    
+    private XMLStreamReader getParserFromMime() throws OMException, XMLStreamException, FactoryConfigurationError
+    {        
+        mimeBodyPartsList = new LinkedList();
+        Properties props = new Properties();
+        javax.mail.Session session = javax.mail.Session.getInstance(props, null);
+        try {
+            mimeMessage = new MimeMessage(session, inStream);
+            
+            MimeBodyPart rootMimeBodyPart;
+            try {
+                rootMimeBodyPart = getRootMimeBodyPart();
+                return XMLInputFactory.newInstance().createXMLStreamReader(
+                        rootMimeBodyPart.getInputStream());
+                
+            } catch (IOException e1) {
+                throw new OMException(e1.toString());
+                
+            } catch (MessagingException e) {
+                throw new OMException("Unable to extract root MIME part "
+                        + e.toString());
+            }
+        } catch (MessagingException e) {
+            throw new OMException(
+            "Message identified as MTOM optimised doesn't contain a valid MIME Stream");
+        }
+    }
+    protected OMNode createOMElement() throws OMException {
+        
+        String elementName = parser.getLocalName();
+        
+        String namespaceURI = parser.getNamespaceURI();
+        
+        // create an OMBlob if the element is an <xop:Include>
+        if (elementName.equalsIgnoreCase("Include")
+                & namespaceURI
+                .equalsIgnoreCase("http://www.w3.org/2004/08/xop/include")) {
+            
+            OMBlobImpl node;
+            String contentID = null;
+            String contentIDName = null;
+            OMAttribute Attr;
+            if (lastNode == null) {
+                // Decide whether to ckeck the level >3 or not
+                throw new OMException(
+                "XOP:Include element is not supported here");
+            }
+            if (parser.getAttributeCount() > 0) {
+                contentID = parser.getAttributeValue(0);
+                contentID = contentID.trim();
+                contentIDName = parser.getAttributeLocalName(0);
+                if (contentIDName.equalsIgnoreCase("href")
+                        & contentID.substring(0, 3).equalsIgnoreCase("cid")) {
+                    contentID = contentID.substring(4);
+                } else {
+                    throw new OMException(
+                    "contentID not Found in XOP:Include element");
+                }
+            } else {
+                throw new OMException(
+                "Href attribute not found in XOP:Include element");
+            }
+            
+            if (lastNode.isComplete()) {
+                node = new OMBlobImpl(contentID, lastNode.getParent(),this);
+                lastNode.setNextSibling(node);
+                node.setPreviousSibling(lastNode);
+            } else {
+                OMElement e = (OMElement) lastNode;
+                node = new OMBlobImpl(contentID, (OMElement) lastNode, this);
+                e.setFirstChild(node);
+            }
+            return node;
+            
+        } else {
+            OMElement node;
+            if (lastNode == null) {
+                node = constructNode(null, elementName, true);
+            } else if (lastNode.isComplete()) {
+                node = constructNode(lastNode.getParent(), elementName, false);
+                lastNode.setNextSibling(node);
+                node.setPreviousSibling(lastNode);
+            } else {
+                OMElement e = (OMElement) lastNode;
+                node = constructNode((OMElement) lastNode, elementName, false);
+                e.setFirstChild(node);
+            }
+            
+            // fill in the attributes
+            processAttributes(node);
+            
+            return node;
+        }
+    }
+    
+    public DataHandler getDataHandler(String blobContentID) throws OMException {
+        /*
+         * 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 mimeBodyPart;
+        
+        boolean attachmentFound = false;
+        ListIterator partsIterator = mimeBodyPartsList.listIterator();
+        try {
+            while (partsIterator.hasNext()) {
+                mimeBodyPart = (MimeBodyPart) partsIterator.next();
+                if (blobContentID.equals(mimeBodyPart.getContentID())) {
+                    attachmentFound = true;
+                    DataHandler dh = mimeBodyPart.getDataHandler();
+                    return dh;
+                }
+            }
+            while (!attachmentFound) {
+                mimeBodyPart = this.getNextMimeBodyPart();
+                
+                if (mimeBodyPart == null) {
+                    break;
+                }
+                String partContentID = mimeBodyPart.getContentID();
+                String delimitedBlobContentID = "<" + blobContentID + ">";
+                if (delimitedBlobContentID.equals(partContentID)) {
+                    attachmentFound = true;
+                    DataHandler dh = mimeBodyPart.getDataHandler();
+                    return dh;
+                }
+            }
+            return null;
+        } catch (MessagingException e) {
+            throw new OMException("Invalid Mime Message "
+                    + e.toString());
+        }
+    }
+    private MimeBodyPart getMimeBodyPart() throws MessagingException {
+        MimeBodyPart mimeBodyPart = null;
+        
+        DataHandler dh = mimeMessage.getDataHandler();
+        MimeMultipart multiPart = new MimeMultipart((MimePartDataSource) dh.getDataSource());
+        mimeBodyPart = (MimeBodyPart) multiPart.getBodyPart(partIndex);
+        
+        partIndex++;
+        return mimeBodyPart;
+    }
+    private MimeBodyPart getRootMimeBodyPart() throws MessagingException {
+        MimeBodyPart rootMimeBodyPart;
+        if (mimeBodyPartsList.isEmpty()) {
+            rootMimeBodyPart = getMimeBodyPart();
+            mimeBodyPartsList.add(rootMimeBodyPart);
+        } else {
+            rootMimeBodyPart = (MimeBodyPart) mimeBodyPartsList.getFirst();
+        }
+        return rootMimeBodyPart;
+    }
+    
+    private MimeBodyPart getNextMimeBodyPart() throws MessagingException {
+        MimeBodyPart nextMimeBodyPart;
+        nextMimeBodyPart = getMimeBodyPart();
+        if (nextMimeBodyPart != null) {
+            mimeBodyPartsList.add(nextMimeBodyPart);
+            return nextMimeBodyPart;
+        } else
+            return null;
+    }
+}
\ No newline at end of file

Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/MTOMXMLStreamWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/MTOMXMLStreamWriter.java?rev=179797&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/MTOMXMLStreamWriter.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/MTOMXMLStreamWriter.java Fri Jun  3 07:26:13 2005
@@ -0,0 +1,438 @@
+package org.apache.axis.om.impl.llom.mtom;
+
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Properties;
+import java.util.Random;
+
+import javax.activation.DataHandler;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMultipart;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+
+/**
+ * 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 thilina@opensource.lk
+ */
+public class MTOMXMLStreamWriter implements XMLStreamWriter {
+
+    OutputStream outStream;
+
+    XMLStreamWriter writer;
+
+    Random rnd;
+
+    LinkedList blobList;
+
+    ByteArrayOutputStream bufferedSoapOutStream;
+
+    public static String[] filter = new String[] { "Message-ID" }; // to filter
+                                                                   // the
+                                                                   // message ID
+                                                                   // header
+
+    public MTOMXMLStreamWriter(OutputStream outStream)
+            throws XMLStreamException, FactoryConfigurationError {
+        super();
+        this.outStream = outStream;
+
+        bufferedSoapOutStream = new ByteArrayOutputStream();
+
+        writer = XMLOutputFactory.newInstance().createXMLStreamWriter(
+                bufferedSoapOutStream);
+        blobList = new LinkedList();
+        rnd = new Random();
+
+    }
+
+    public void writeOptimised(OMBlobImpl blob) {
+        blobList.add(blob);
+    }
+
+    private MimeBodyPart createMimeBodyPart(OMBlobImpl blob)
+            throws Exception {
+        MimeBodyPart mimeBodyPart = new MimeBodyPart();
+        mimeBodyPart.setDataHandler(blob.getDataHandler());
+        mimeBodyPart.addHeader("Content-Transfer-Encoding", "binary");
+        mimeBodyPart.addHeader("Content-ID", "<" + blob.getContentID()+ ">");
+        return mimeBodyPart;
+
+    }
+
+    public void complete() throws Exception {
+        DataHandler dh = new DataHandler(bufferedSoapOutStream.toString(),
+                "text/xml");
+        MimeBodyPart mimeBodyPart = new MimeBodyPart();
+        mimeBodyPart.setDataHandler(dh);
+        mimeBodyPart.addHeader("Content-Type", "application/xop+xml");
+        mimeBodyPart.addHeader("Content-Transfer-Encoding", "8bit");
+        String contentID = "<http://example.org/my.hsh>";
+        mimeBodyPart.addHeader("Content-ID", contentID);
+
+        Properties props = new Properties();
+        javax.mail.Session session = javax.mail.Session
+                .getInstance(props, null);
+        javax.mail.internet.MimeMessage mimeMessage = new javax.mail.internet.MimeMessage(
+                session);
+        MimeMultipart multipartMessage = new MimeMultipart("Related");
+        multipartMessage.addBodyPart(mimeBodyPart);
+
+        Iterator blobIterator = blobList.iterator();
+        while (blobIterator.hasNext()) {
+            OMBlobImpl blob = (OMBlobImpl) blobIterator.next();
+            multipartMessage
+                    .addBodyPart(createMimeBodyPart(blob));
+        }
+        mimeMessage.setContent(multipartMessage);
+        mimeMessage.writeTo(outStream, filter);
+    }
+
+    public void writeStartElement(String localName) throws XMLStreamException {
+        writer.writeStartElement(localName);
+    }
+
+    public void writeStartElement(String namespaceURI, String localName)
+            throws XMLStreamException {
+        writer.writeStartElement(namespaceURI, localName);
+
+    }
+
+    public void writeStartElement(String prefix, String localName,
+            String namespaceURI) throws XMLStreamException {
+        writer.writeStartElement(prefix, localName, namespaceURI);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#writeEmptyElement(java.lang.String,
+     *      java.lang.String)
+     */
+    public void writeEmptyElement(String namespaceURI, String localName)
+            throws XMLStreamException {
+        writer.writeEmptyElement(namespaceURI, localName);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#writeEmptyElement(java.lang.String,
+     *      java.lang.String, java.lang.String)
+     */
+    public void writeEmptyElement(String prefix, String localName,
+            String namespaceURI) throws XMLStreamException {
+        writer.writeEmptyElement(prefix, localName, namespaceURI);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#writeEmptyElement(java.lang.String)
+     */
+    public void writeEmptyElement(String localName) throws XMLStreamException {
+        writer.writeEmptyElement(localName);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#writeEndElement()
+     */
+    public void writeEndElement() throws XMLStreamException {
+        writer.writeEndElement();
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#writeEndDocument()
+     */
+    public void writeEndDocument() throws XMLStreamException {
+        writer.writeEndDocument();
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#close()
+     */
+    public void close() throws XMLStreamException {
+        writer.close();
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#flush()
+     */
+    public void flush() throws XMLStreamException {
+        writer.flush();
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#writeAttribute(java.lang.String,
+     *      java.lang.String)
+     */
+    public void writeAttribute(String localName, String value)
+            throws XMLStreamException {
+        writer.writeAttribute(localName, value);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#writeAttribute(java.lang.String,
+     *      java.lang.String, java.lang.String, java.lang.String)
+     */
+    public void writeAttribute(String prefix, String namespaceURI,
+            String localName, String value) throws XMLStreamException {
+        writer.writeAttribute(prefix, namespaceURI, localName, value);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#writeAttribute(java.lang.String,
+     *      java.lang.String, java.lang.String)
+     */
+    public void writeAttribute(String namespaceURI, String localName,
+            String value) throws XMLStreamException {
+        writer.writeAttribute(namespaceURI, localName, value);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#writeNamespace(java.lang.String,
+     *      java.lang.String)
+     */
+    public void writeNamespace(String prefix, String namespaceURI)
+            throws XMLStreamException {
+        writer.writeNamespace(prefix, namespaceURI);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#writeDefaultNamespace(java.lang.String)
+     */
+    public void writeDefaultNamespace(String namespaceURI)
+            throws XMLStreamException {
+        writer.writeDefaultNamespace(namespaceURI);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#writeComment(java.lang.String)
+     */
+    public void writeComment(String data) throws XMLStreamException {
+        writer.writeComment(data);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#writeProcessingInstruction(java.lang.String)
+     */
+    public void writeProcessingInstruction(String target)
+            throws XMLStreamException {
+        writer.writeProcessingInstruction(target);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#writeProcessingInstruction(java.lang.String,
+     *      java.lang.String)
+     */
+    public void writeProcessingInstruction(String target, String data)
+            throws XMLStreamException {
+        writer.writeProcessingInstruction(target, data);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#writeCData(java.lang.String)
+     */
+    public void writeCData(String data) throws XMLStreamException {
+        writer.writeCData(data);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#writeDTD(java.lang.String)
+     */
+    public void writeDTD(String dtd) throws XMLStreamException {
+        writer.writeDTD(dtd);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#writeEntityRef(java.lang.String)
+     */
+    public void writeEntityRef(String name) throws XMLStreamException {
+        writer.writeEntityRef(name);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#writeStartDocument()
+     */
+    public void writeStartDocument() throws XMLStreamException {
+        writer.writeStartDocument();
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#writeStartDocument(java.lang.String)
+     */
+    public void writeStartDocument(String version) throws XMLStreamException {
+        writer.writeStartDocument(version);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#writeStartDocument(java.lang.String,
+     *      java.lang.String)
+     */
+    public void writeStartDocument(String encoding, String version)
+            throws XMLStreamException {
+        writer.writeStartDocument(encoding, version);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#writeCharacters(java.lang.String)
+     */
+    public void writeCharacters(String text) throws XMLStreamException {
+        writer.writeCharacters(text);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#writeCharacters(char[], int, int)
+     */
+    public void writeCharacters(char[] text, int start, int len)
+            throws XMLStreamException {
+        writer.writeCharacters(text, start, len);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#getPrefix(java.lang.String)
+     */
+    public String getPrefix(String uri) throws XMLStreamException {
+
+        return writer.getPrefix(uri);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#setPrefix(java.lang.String,
+     *      java.lang.String)
+     */
+    public void setPrefix(String prefix, String uri) throws XMLStreamException {
+        writer.setPrefix(prefix, uri);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#setDefaultNamespace(java.lang.String)
+     */
+    public void setDefaultNamespace(String uri) throws XMLStreamException {
+        writer.setDefaultNamespace(uri);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#setNamespaceContext(javax.xml.namespace.NamespaceContext)
+     */
+    public void setNamespaceContext(NamespaceContext context)
+            throws XMLStreamException {
+        writer.setNamespaceContext(context);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#getNamespaceContext()
+     */
+    public NamespaceContext getNamespaceContext() {
+
+        return writer.getNamespaceContext();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.stream.XMLStreamWriter#getProperty(java.lang.String)
+     */
+    public Object getProperty(String name) throws IllegalArgumentException {
+
+        return writer.getProperty(name);
+    }
+}
\ No newline at end of file

Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/OMBlob.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/OMBlob.java?rev=179797&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/OMBlob.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/OMBlob.java Fri Jun  3 07:26:13 2005
@@ -0,0 +1,33 @@
+/*
+ * 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.axis.om.impl.llom.mtom;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.activation.DataHandler;
+
+import org.apache.axis.om.OMException;
+
+/**
+ * @author Thilina
+ * @date Mar 20, 2005
+ */
+public interface OMBlob {
+    public abstract OutputStream getOutputStream() throws IOException;
+
+    public abstract DataHandler getDataHandler() throws OMException;
+}
\ No newline at end of file

Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/OMBlobImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/OMBlobImpl.java?rev=179797&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/OMBlobImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/xml_conformance/XMLConformanceTestingProject/src/org/apache/axis/om/impl/llom/mtom/OMBlobImpl.java Fri Jun  3 07:26:13 2005
@@ -0,0 +1,298 @@
+/**
+ * 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/>
+ */
+package org.apache.axis.om.impl.llom.mtom;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.util.Date;
+import java.util.Random;
+
+import javax.activation.DataHandler;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axis.encoding.Base64;
+import org.apache.axis.om.OMAttribute;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMException;
+import org.apache.axis.om.OMNamespace;
+import org.apache.axis.om.OMNode;
+import org.apache.axis.om.OMXMLParserWrapper;
+import org.apache.axis.om.impl.llom.OMAttributeImpl;
+import org.apache.axis.om.impl.llom.OMNamespaceImpl;
+import org.apache.axis.om.impl.llom.OMNodeImpl;
+
+/**
+ * @author Thilina Gunarathne thilina@opensource.lk
+ */
+
+public class OMBlobImpl extends OMNodeImpl implements OMBlob {
+    /**
+     * Field contentID for the mime part
+     */
+    private String contentID = null;
+    /**
+     * Field builder
+     */
+    private OMXMLParserWrapper builder;
+    /**
+     * Field dataHandler
+     */
+    private DataHandler dataHandler = null;
+    /**
+     * Field nameSpace
+     */
+    protected OMNamespace ns = new OMNamespaceImpl("http://www.w3.org/2004/08/xop/Include", "xop");
+    /**
+     * Field localName
+     */
+    protected String localName= "Include";
+    /**
+     * Field attributes
+     */
+    protected  OMAttribute attribute;
+
+    
+    public OMBlobImpl(DataHandler dataHandler) {
+        this.dataHandler = dataHandler;
+        if (this.contentID == null) {
+            // We can use a UUID, taken using Apache commons id project.
+            //          TODO change to UUID
+            this.contentID = String.valueOf(new Random(new Date().getTime())
+                    .nextLong());
+        }
+    }
+    
+    public OMBlobImpl(String contentID, OMElement parent,
+            OMXMLParserWrapper builder) {
+        super(parent);
+        this.builder = builder;
+        this.contentID = contentID;
+    }
+    
+    public String getLocalName() {
+        return localName;
+    }
+    
+    public java.io.OutputStream getOutputStream() throws IOException {
+        if (dataHandler == null) {
+            getDataHandler();
+        }
+        OutputStream outStream = dataHandler.getOutputStream();
+        if (!(outStream instanceof java.io.OutputStream)) {
+            outStream = new ByteArrayOutputStream();
+            Object outObject = dataHandler.getContent();
+            ObjectOutputStream objectOutStream = new ObjectOutputStream(
+                    outStream);
+            objectOutStream.writeObject(outObject);
+        }
+        return outStream;
+    }
+    
+    public String getValue() throws OMException {
+        throw new OMException(
+        "Blob contains Binary data. Returns Stream or Datahandler only");
+    }
+    
+    public DataHandler getDataHandler() throws OMException {
+        if (dataHandler == null) {
+            dataHandler = ((MTOMStAXSOAPModelBuilder) builder)
+            .getDataHandler(contentID);
+        }
+        return dataHandler;
+    }
+    
+    public int getType() throws OMException {
+        return OMNode.BLOB_NODE;
+    }
+    
+    public String getContentID() {
+        return this.contentID;
+    }
+    
+    public boolean isComplete() {
+        return true;
+    }
+    
+    public void serialize(XMLStreamWriter writer)
+    throws XMLStreamException {
+        boolean firstElement = false;
+            //No caching
+            if (writer instanceof MTOMXMLStreamWriter) {
+                // send as optimised
+                MTOMXMLStreamWriter mtomWriter = (MTOMXMLStreamWriter) writer;
+                this.attribute= new OMAttributeImpl("href",new OMNamespaceImpl("", ""), "cid:" + this.contentID.trim());
+                
+                this.serializeStartpart(mtomWriter);             
+                mtomWriter.writeOptimised(this);
+                mtomWriter.writeEndElement();
+            } else {
+                // send as non optimised
+                ByteArrayOutputStream byteStream;
+                    try {
+                        byteStream = (ByteArrayOutputStream) this.getOutputStream();
+                    
+                    writer.writeCharacters(Base64.encode(byteStream
+                            .toByteArray()));
+                    } catch (IOException e) {
+                        // TODO Auto-generated catch block
+                        e.printStackTrace();
+                    }
+            
+            }
+            if (nextSibling != null) {
+                // serilize next sibling
+                nextSibling.serialize(writer);
+            } else {
+                if (parent == null) {
+                    return;
+                } else if (parent.isComplete()) {
+                    return;
+                } else {
+                    // do the special serialization
+                    // Only the push serializer is left now
+                    builder.next();
+                }
+            }
+    }
+    
+    /*
+     * Methods to copy from OMSerialize utils
+     */
+    private void serializeStartpart(XMLStreamWriter writer)
+    throws XMLStreamException {
+        String nameSpaceName = null;
+        String writer_prefix = null;
+        String prefix = null;
+        if (this.ns != null) {
+            nameSpaceName = this.ns.getName();
+            writer_prefix = writer.getPrefix(nameSpaceName);
+            prefix = this.ns.getPrefix();
+            if (nameSpaceName != null) {
+                if (writer_prefix != null) {
+                    writer.writeStartElement(nameSpaceName, this.getLocalName());
+                } else {
+                    if (prefix != null) {
+                        writer.writeStartElement(prefix,
+                                this.getLocalName(), nameSpaceName);
+                        writer.writeNamespace(prefix, nameSpaceName);
+                        writer.setPrefix(prefix, nameSpaceName);
+                    } else {
+                        writer.writeStartElement(nameSpaceName, this.getLocalName());
+                        writer.writeDefaultNamespace(nameSpaceName);
+                        writer.setDefaultNamespace(nameSpaceName);
+                    }
+                }
+            } else {
+                writer.writeStartElement(this.getLocalName());
+                //        throw new OMException(
+                //                "Non namespace qualified elements are not allowed");
+            }
+        } else {
+            writer.writeStartElement(this.getLocalName());
+            //    throw new OMException(
+            //            "Non namespace qualified elements are not allowed");
+        }
+        
+        // add the elements attribute "href"
+                serializeAttribute(this.attribute, writer);
+        
+        // add the namespace
+                serializeNamespace(this.ns, writer);
+       
+    }
+    
+    /**
+     * Method serializeAttribute
+     * 
+     * @param attr
+     * @param writer
+     * @throws XMLStreamException
+     */
+    static void serializeAttribute(OMAttribute attr, XMLStreamWriter writer)
+    throws XMLStreamException {
+        
+        // first check whether the attribute is associated with a namespace
+        OMNamespace ns = attr.getNamespace();
+        String prefix = null;
+        String namespaceName = null;
+        if (ns != null) {
+            
+            // add the prefix if it's availble
+            prefix = ns.getPrefix();
+            namespaceName = ns.getName();
+            if (prefix != null) {
+                writer.writeAttribute(prefix, namespaceName, attr
+                        .getLocalName(), attr.getValue());
+            } else {
+                writer.writeAttribute(namespaceName, attr.getLocalName(), attr
+                        .getValue());
+            }
+        } else {
+            writer.writeAttribute(attr.getLocalName(), attr.getValue());
+        }
+    }
+    
+    /**
+     * Method serializeNamespace
+     * 
+     * @param namespace
+     * @param writer
+     * @throws XMLStreamException
+     */
+    static void serializeNamespace(OMNamespace namespace, XMLStreamWriter writer)
+    throws XMLStreamException {
+        if (namespace != null) {
+            String uri = namespace.getName();
+            String prefix = writer.getPrefix(uri);
+            String ns_prefix = namespace.getPrefix();
+            if (prefix == null) {
+                writer.writeNamespace(ns_prefix, namespace.getName());
+                writer.setPrefix(ns_prefix, uri);
+            }
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.axis.om.OMNode#discard()
+     */
+    public void discard() throws OMException {
+        // TODO Auto-generated method stub
+        
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.axis.om.OMNode#serializeWithCache(javax.xml.stream.XMLStreamWriter)
+     */
+    public void serializeWithCache(XMLStreamWriter writer) throws XMLStreamException {
+        // TODO Auto-generated method stub
+        
+    }
+
+  
+
+    /* (non-Javadoc)
+     * @see org.apache.axis.om.OMNode#build()
+     */
+    public void build() {
+        // TODO Auto-generated method stub
+        
+    }
+    
+}
\ No newline at end of file