You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ch...@apache.org on 2005/03/24 11:17:32 UTC

svn commit: r158906 [1/2] - in webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2: ./ lib/ src/ src/java/ src/java/org/ src/java/org/apache/ src/java/org/apache/axis/ src/java/org/apache/axis/encoding/ src/java/org/apache/axis/om/ src/java/org/apache/axis/om/impl/ src/java/org/apache/axis/om/impl/llom/ src/java/org/apache/axis/om/impl/llom/builder/ src/java/org/apache/axis/om/impl/llom/mtom/ src/java/org/apache/axis/om/impl/llom/serialize/ src/test-resources/ src/test/ src/test/org/ src/test/org/apache/ src/test/org/apache/axis/ src/test/org/apache/axis/om/ src/test/org/apache/axis/om/impl/ src/test/org/apache/axis/om/impl/llom/ src/test/org/apache/axis/om/impl/llom/mtom/

Author: chinthaka
Date: Thu Mar 24 02:17:28 2005
New Revision: 158906

URL: http://svn.apache.org/viewcvs?view=rev&rev=158906
Log:
Committing for Thilina - Incorporating new OM classes to MTOM

Added:
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/activation.jar   (with props)
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/axis2-core-M1.jar   (with props)
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/axis2-om-M1.jar   (with props)
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/commons-logging-1.0.3.jar   (with props)
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/jsr173_1.0_api.jar   (with props)
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/jsr173_1.0_ri.jar   (with props)
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/junit.jar   (with props)
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/mail.jar   (with props)
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/encoding/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/encoding/Base64.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/OMBlob.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/OMNode.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/OMText.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/OMBlobImpl.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/OMTextImpl.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/builder/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/builder/MTOMStAXSOAPModelBuilder.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/builder/StAXBuilder.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/builder/StAXOMBuilder.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/builder/StAXSOAPModelBuilder.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/mtom/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/mtom/ByteArrayDataSource.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/mtom/MTOMHelper.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/mtom/MTOMXMLStreamWriter.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/serialize/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/serialize/SimpleOMSerializer.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/test/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/test-resources/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/test-resources/OMSerializeBase64Out.xml
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/test-resources/OMSerializeMTOMOut.txt
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/test/org/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/test/org/apache/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/test/org/apache/axis/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/test/org/apache/axis/om/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/test/org/apache/axis/om/impl/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/test/org/apache/axis/om/impl/llom/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/test/org/apache/axis/om/impl/llom/OMTextImplTest.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/test/org/apache/axis/om/impl/llom/mtom/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/test/org/apache/axis/om/impl/llom/mtom/MTOMTest.java

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/activation.jar
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/activation.jar?view=auto&rev=158906
==============================================================================
Binary file - no diff available.

Propchange: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/activation.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/axis2-core-M1.jar
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/axis2-core-M1.jar?view=auto&rev=158906
==============================================================================
Binary file - no diff available.

Propchange: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/axis2-core-M1.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/axis2-om-M1.jar
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/axis2-om-M1.jar?view=auto&rev=158906
==============================================================================
Binary file - no diff available.

Propchange: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/axis2-om-M1.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/commons-logging-1.0.3.jar
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/commons-logging-1.0.3.jar?view=auto&rev=158906
==============================================================================
Binary file - no diff available.

Propchange: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/commons-logging-1.0.3.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/jsr173_1.0_api.jar
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/jsr173_1.0_api.jar?view=auto&rev=158906
==============================================================================
Binary file - no diff available.

Propchange: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/jsr173_1.0_api.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/jsr173_1.0_ri.jar
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/jsr173_1.0_ri.jar?view=auto&rev=158906
==============================================================================
Binary file - no diff available.

Propchange: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/jsr173_1.0_ri.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/junit.jar
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/junit.jar?view=auto&rev=158906
==============================================================================
Binary file - no diff available.

Propchange: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/junit.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/mail.jar
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/mail.jar?view=auto&rev=158906
==============================================================================
Binary file - no diff available.

Propchange: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/lib/mail.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/encoding/Base64.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/encoding/Base64.java?view=auto&rev=158906
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/encoding/Base64.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/encoding/Base64.java Thu Mar 24 02:17:28 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/Thilina/MTOM2/src/java/org/apache/axis/om/OMBlob.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/OMBlob.java?view=auto&rev=158906
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/OMBlob.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/OMBlob.java Thu Mar 24 02:17:28 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;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.activation.DataHandler;
+import javax.mail.MessagingException;
+
+/**
+ * @author Thilina
+ * @date Mar 20, 2005
+ */
+public interface OMBlob {
+    public abstract OutputStream getOutputStream() throws IOException,
+            MessagingException;
+
+    public abstract DataHandler getDataHandler() throws MessagingException;
+}
\ No newline at end of file

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/OMNode.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/OMNode.java?view=auto&rev=158906
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/OMNode.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/OMNode.java Thu Mar 24 02:17:28 2005
@@ -0,0 +1,188 @@
+/*
+ * 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;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+/**
+ * Interface OMNode
+ */
+public interface OMNode {
+    /**
+     * The node is an <code>Element</code>.
+     */
+    public static final short ELEMENT_NODE = 1;
+
+    /**
+     * The node is an <code>Attr</code>.
+     */
+    public static final short ATTRIBUTE_NODE = 2;
+
+    /**
+     * The node is a <code>Text</code> node.
+     */
+    public static final short TEXT_NODE = 3;
+
+    /**
+     * The node is a <code>CDATASection</code>.
+     */
+    public static final short CDATA_SECTION_NODE = 4;
+
+    /**
+     * The node is a <code>Comment</code>.
+     */
+    public static final short COMMENT_NODE = 8;
+
+    /**
+     * The node is a <code>Document</code>.
+     */
+    public static final short DOCUMENT_NODE = 9;
+
+    /**
+     * The node is a <code>Binary</code>.
+     */
+    public static final short BLOB_NODE = 10;
+
+    /**
+     * This method should return the immediate parent of the node. Parent is
+     * always an Element
+     * 
+     * @return
+     * @throws OMException
+     */
+    public OMElement getParent() throws OMException;
+
+    /**
+     * Method setParent
+     * 
+     * @param element
+     */
+    public void setParent(OMElement element);
+
+    /**
+     * This will give the next sibling. This can be an OMAttribute for
+     * OMAttribute or OMText or OMELement for others.
+     * 
+     * @return
+     * @throws OMException
+     */
+    public OMNode getNextSibling() throws OMException;
+
+    /**
+     * Method setNextSibling
+     * 
+     * @param node
+     */
+    public void setNextSibling(OMNode node);
+
+    /**
+     * This will return the literal value of the node. OMText --> the text
+     * OMElement --> local name of the element in String format OMAttribute -->
+     * the value of the attribue
+     * 
+     * @return
+     * @throws OMException
+     */
+    public String getValue() throws OMException;
+
+    /**
+     * Method setValue
+     * 
+     * @param value
+     */
+    public void setValue(String value);
+
+    /**
+     * this will indicate whether parser has parsed this information item
+     * completely or not. If somethings info are not available in the item, one
+     * has to check this attribute to make sure that, this item has been parsed
+     * completely or not.
+     * 
+     * @return
+     */
+    public boolean isComplete();
+
+    /**
+     * Method setComplete
+     * 
+     * @param state
+     */
+    public void setComplete(boolean state);
+
+    /**
+     * This will remove this information item and its children, from the model
+     * completely
+     * 
+     * @throws OMException
+     */
+    public void detach() throws OMException;
+
+    /**
+     * This will insert a sibling just after the current information item.
+     * 
+     * @param sibling
+     * @throws OMException
+     */
+    public void insertSiblingAfter(OMNode sibling) throws OMException;
+
+    /**
+     * This will insert a sibling just before the current information item
+     * 
+     * @param sibling
+     * @throws OMException
+     */
+    public void insertSiblingBefore(OMNode sibling) throws OMException;
+
+    /**
+     * This is to get the type of node, as this is the super class of all the
+     * nodes
+     * 
+     * @return
+     * @throws OMException
+     */
+    public short getType() throws OMException;
+
+    /**
+     * Method setType
+     * 
+     * @param nodeType
+     * @throws OMException
+     */
+    public void setType(short nodeType) throws OMException;
+
+    /**
+     * get the previous sibling
+     * 
+     * @return
+     */
+    public OMNode getPreviousSibling();
+
+    /**
+     * Set the previous sibling
+     * 
+     * @param previousSibling
+     */
+    public void setPreviousSibling(OMNode previousSibling);
+
+    /**
+     * @param writer
+     * @param cache
+     * @throws XMLStreamException
+     */
+    public void serialize(XMLStreamWriter writer, boolean cache)
+            throws XMLStreamException;
+}
\ No newline at end of file

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/OMText.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/OMText.java?view=auto&rev=158906
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/OMText.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/OMText.java Thu Mar 24 02:17:28 2005
@@ -0,0 +1,41 @@
+/*
+ * 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;
+
+import javax.activation.DataHandler;
+
+/**
+ * Interface OMText
+ */
+public interface OMText extends OMNode {
+    /**
+     * We use the OMText class to hold comments, text, characterData, CData,
+     * etc., Also to hold base64 encoded binary Data The codes are found in
+     * OMNode class
+     * 
+     * @param type
+     */
+    public void setTextType(short type);
+
+    /**
+     * Method getTextType
+     * 
+     * @return
+     */
+    public short getTextType();
+
+    public DataHandler getDataHandler();
+}
\ No newline at end of file

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/OMBlobImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/OMBlobImpl.java?view=auto&rev=158906
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/OMBlobImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/OMBlobImpl.java Thu Mar 24 02:17:28 2005
@@ -0,0 +1,198 @@
+/**
+ * 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;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+
+import javax.activation.DataHandler;
+import javax.mail.MessagingException;
+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.OMBlob;
+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;
+import org.apache.axis.om.impl.llom.mtom.MTOMHelper;
+import org.apache.axis.om.impl.llom.mtom.MTOMXMLStreamWriter;
+
+/**
+ * @author Thilina Gunarathne thilina@opensource.lk
+ */
+
+public class OMBlobImpl extends OMNodeImpl implements OMBlob {
+
+    private String contentID = null;
+
+    private MTOMHelper mtomHelper;
+
+    private OMXMLParserWrapper builder;
+
+    private DataHandler dataHandler = null;
+
+    public OMBlobImpl(DataHandler dataHandler) {
+        this.dataHandler = dataHandler;
+    }
+
+    public OMBlobImpl(String contentID, OMElement parent, MTOMHelper mtomHelper,
+            OMXMLParserWrapper builder) {
+        super(parent);
+        this.builder = builder;
+        this.contentID = contentID;
+        this.mtomHelper = mtomHelper;
+    }
+
+    public java.io.OutputStream getOutputStream() throws IOException,
+            MessagingException {
+        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 MessagingException {
+        if (dataHandler == null) {
+            dataHandler = mtomHelper.getDataHandler(contentID);
+        }
+        return dataHandler;
+    }
+
+    public short getType() throws OMException {
+        return OMNode.BLOB_NODE;
+    }
+
+    public boolean isComplete() {
+        return true;
+    }
+
+    public void serialize(XMLStreamWriter writer, boolean cache)
+            throws XMLStreamException {
+        boolean firstElement = false;
+
+        // Special case for the pull type building with cache off
+        // The getPullParser method returns the current elements itself.
+
+        if (isComplete()) {
+
+            // serialize own normally
+            if (writer instanceof MTOMXMLStreamWriter) {
+                MTOMXMLStreamWriter mtomWriter = (MTOMXMLStreamWriter) writer;
+                // write the XOP:Include namespace
+                OMNamespace ns = new OMNamespaceImpl(
+                        "http://www.w3.org/2004/08/xop/Include", "xop");
+                String prefix = null;
+                String nameSpaceName = null;
+                if (ns != null) {
+                    prefix = ns.getPrefix();
+                    nameSpaceName = ns.getName();
+                    if (prefix != null) {
+                        mtomWriter.writeStartElement(prefix, "Include",
+                                nameSpaceName);
+                        //if (!prefixList.contains(prefix)) {
+                        mtomWriter.writeNamespace(prefix, nameSpaceName);
+                        //	prefixList.add(prefix);
+                        //}
+                    }
+                }
+
+                //get the Cid from the MTOMwriter
+                String contentID;
+                contentID = mtomWriter.writeAttachment(this);
+                OMAttribute href = new OMAttributeImpl("href",
+                        new OMNamespaceImpl("", ""), "cid:" + contentID.trim());
+                serializeAttribute(href, writer);
+                mtomWriter.writeEndElement();
+            } else {
+                ByteArrayOutputStream byteStream;
+
+                try {
+                    byteStream = (ByteArrayOutputStream) this.getOutputStream();
+                    writer.writeCharacters(Base64.encode(byteStream
+                            .toByteArray()));
+                } catch (IOException e) {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                } catch (MessagingException e) {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                }
+            }
+            if (nextSibling != null) {
+                // serilize next sibling
+                nextSibling.serialize(writer, cache);
+            } else {
+                if (parent == null) {
+                    return;
+                } else if (parent.isComplete()) {
+                    return;
+                } else {
+                    // do the special serialization
+                    // Only the push serializer is left now
+                    builder.setCache(cache);
+                    builder.next();
+                }
+            }
+        }
+    }
+
+    protected 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());
+        }
+
+    }
+}
\ No newline at end of file

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/OMTextImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/OMTextImpl.java?view=auto&rev=158906
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/OMTextImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/OMTextImpl.java Thu Mar 24 02:17:28 2005
@@ -0,0 +1,177 @@
+/*
+ * 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;
+
+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.OMConstants;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMException;
+import org.apache.axis.om.OMNode;
+import org.apache.axis.om.OMText;
+import org.apache.axis.om.impl.llom.mtom.ByteArrayDataSource;
+
+/**
+ * Class OMTextImpl
+ */
+public class OMTextImpl extends OMNodeImpl implements OMText, OMConstants {
+    /**
+     * Field textType
+     */
+    protected short textType = TEXT_NODE;
+
+    protected String mimeType;
+
+    /**
+     * Constructor OMTextImpl
+     * 
+     * @param parent
+     * @param text
+     */
+    public OMTextImpl(OMElement parent, String text) {
+        super(parent);
+        setValue(text);
+        done = true;
+    }
+
+    /**
+     * Constructor OMTextImpl
+     * 
+     * @param s
+     */
+    public OMTextImpl(String s) {
+        setValue(s);
+    }
+
+    /**
+     * Constructor OMTextImpl Used when the contant is Base64 encoded binary
+     * 
+     * @param s
+     * @param type -
+     *            Mime type
+     */
+    public OMTextImpl(String s, String mimeType) {
+        setValue(s);
+        this.mimeType = mimeType;
+    }
+    public OMTextImpl(OMElement parent,String s, String mimeType) {
+        super(parent);
+        setValue(s);
+        this.mimeType = mimeType;
+    }
+
+    /**
+     * 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) {
+        if ((type == TEXT_NODE) || (type == COMMENT_NODE)
+                || (type == CDATA_SECTION_NODE)) {
+            this.textType = type;
+        } else {
+            throw new UnsupportedOperationException("Attempt to set wrong type");
+        }
+    }
+
+    /**
+     * Method getTextType
+     * 
+     * @return
+     */
+    public short getTextType() {
+        return textType;
+    }
+
+    /**
+     * Method getFirstChild
+     * 
+     * @return
+     * @throws OMException
+     */
+    public OMNode getFirstChild() throws OMException {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Method setFirstChild
+     * 
+     * @param node
+     * @throws OMException
+     */
+    public void setFirstChild(OMNode node) throws OMException {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * @return
+     * @throws org.apache.axis.om.OMException
+     * @throws OMException
+     */
+    public short getType() throws OMException {
+        return textType;
+    }
+
+    /**
+     * @return
+     * @throws org.apache.axis.om.OMException
+     * @throws OMException
+     */
+    public DataHandler getDataHandler() throws OMException {
+        /*
+         * this should return a DataHandler containing the binary data
+         * reperesented by the Base64 strings stored in OMText
+         */
+        String value;
+        if ((value = getValue()) != null) {
+            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 dataHandler = new DataHandler(dataSource);
+            return dataHandler;
+        }
+        return null;
+    }
+
+    /**
+     * @param writer
+     * @param cache
+     * @throws XMLStreamException
+     */
+    public void serialize(XMLStreamWriter writer, boolean cache)
+            throws XMLStreamException {
+        if (textType == TEXT_NODE) {
+            writer.writeCharacters(this.value);
+        } else if (textType == COMMENT_NODE) {
+            writer.writeComment(this.value);
+        } else if (textType == CDATA_SECTION_NODE) {
+            writer.writeCData(this.value);
+        }
+        OMNode nextSibling = this.getNextSibling();
+        if (nextSibling != null) {
+            nextSibling.serialize(writer, cache);
+        }
+    }
+}
\ No newline at end of file

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/builder/MTOMStAXSOAPModelBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/builder/MTOMStAXSOAPModelBuilder.java?view=auto&rev=158906
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/builder/MTOMStAXSOAPModelBuilder.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/builder/MTOMStAXSOAPModelBuilder.java Thu Mar 24 02:17:28 2005
@@ -0,0 +1,115 @@
+
+package org.apache.axis.om.impl.llom.builder;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.mail.MessagingException;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axis.om.OMAttribute;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMException;
+import org.apache.axis.om.OMFactory;
+import org.apache.axis.om.OMNode;
+import org.apache.axis.om.impl.llom.OMBlobImpl;
+import org.apache.axis.om.impl.llom.mtom.MTOMHelper;
+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());
+
+    MTOMHelper mtomHelper;
+
+    public MTOMStAXSOAPModelBuilder(OMFactory ombuilderFactory,
+            InputStream inStream) throws XMLStreamException,
+            FactoryConfigurationError, OMException {
+        super(ombuilderFactory);
+        mtomHelper = new MTOMHelper(inStream);
+        this.parser = mtomHelper.getParser();
+    }
+
+    public MTOMStAXSOAPModelBuilder(InputStream inStream)
+            throws XMLStreamException, FactoryConfigurationError, IOException,
+            MessagingException {
+        super();
+        mtomHelper = new MTOMHelper(inStream);
+        this.parser = mtomHelper.getParser();
+    }
+
+    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(),
+                        mtomHelper, this);
+                lastNode.setNextSibling(node);
+                node.setPreviousSibling(lastNode);
+            } else {
+                OMElement e = (OMElement) lastNode;
+                node = new OMBlobImpl(contentID, (OMElement) lastNode,
+                        mtomHelper, 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);
+            log.info("Build the OMElelment {" + node.getNamespaceName() + '}'
+                    + node.getLocalName() + "By the StaxSOAPModelBuilder");
+            return node;
+        }
+    }
+}
\ No newline at end of file

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/builder/StAXBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/builder/StAXBuilder.java?view=auto&rev=158906
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/builder/StAXBuilder.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/builder/StAXBuilder.java Thu Mar 24 02:17:28 2005
@@ -0,0 +1,468 @@
+/*
+ * 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.builder;
+
+import java.io.InputStream;
+
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axis.om.OMConstants;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMException;
+import org.apache.axis.om.OMFactory;
+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.OMElementImpl;
+import org.apache.axis.om.impl.llom.OMNodeImpl;
+
+/**
+ * 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 {
+    /**
+     * Field ombuilderFactory
+     */
+    protected OMFactory ombuilderFactory;
+
+    /**
+     * Field parser
+     */
+    protected XMLStreamReader parser;
+
+    /**
+     * Field omfactory
+     */
+    protected OMFactory omfactory;
+
+    /**
+     * Field lastNode
+     */
+    protected OMNode lastNode;
+
+    // returns the state of completion
+
+    /**
+     * Field done
+     */
+    protected boolean done = false;
+
+    // keeps the state of the cache
+
+    /**
+     * Field cache
+     */
+    protected boolean cache = true;
+
+    // keeps the state of the parser access. if the parser is
+    // accessed atleast once,this flag will be set
+
+    /**
+     * Field parserAccessed
+     */
+    protected boolean parserAccessed = false;
+
+    /**
+     * Constructor StAXBuilder
+     * 
+     * @param ombuilderFactory
+     * @param parser
+     * @throws FactoryConfigurationError
+     * @throws XMLStreamException
+     */
+    protected StAXBuilder(OMFactory ombuilderFactory, InputStream inStream)
+            throws XMLStreamException, FactoryConfigurationError {
+        this.ombuilderFactory = ombuilderFactory;
+        this.parser = XMLInputFactory.newInstance().createXMLStreamReader(
+                inStream);
+        omfactory = OMFactory.newInstance();
+    }
+
+    /**
+     * Constructor StAXBuilder
+     * 
+     * @param parser
+     * @throws FactoryConfigurationError
+     * @throws XMLStreamException
+     */
+    protected StAXBuilder(InputStream inStream) throws XMLStreamException,
+            FactoryConfigurationError {
+        this(OMFactory.newInstance(), inStream);
+        omfactory = OMFactory.newInstance();
+    }
+
+    // want suggestions
+    /*
+     * Edited by Thilina Gunarathne
+     */
+    protected StAXBuilder() {
+        this.ombuilderFactory = OMFactory.newInstance();
+        omfactory = OMFactory.newInstance();
+    }
+
+    protected StAXBuilder(OMFactory ombuilderFactory) {
+        this.ombuilderFactory = ombuilderFactory;
+        omfactory = OMFactory.newInstance();
+    }
+
+    /*
+     * Edit Over
+     */
+
+    /**
+     * Method setOmbuilderFactory
+     * 
+     * @param ombuilderFactory
+     */
+    public void setOmbuilderFactory(OMFactory ombuilderFactory) {
+        this.ombuilderFactory = ombuilderFactory;
+    }
+
+    /*
+     * Edited by Thilina Gunarathne
+     *  // clarify how to enforce to do this protected void
+     * setParser(XMLStreamReader parser) { this.parser = parser; }
+     * 
+     * Edit Over
+     */
+    /**
+     * Method processNamespaceData
+     * 
+     * @param node
+     * @param isSOAPElement
+     */
+    protected abstract void processNamespaceData(OMElement node,
+            boolean isSOAPElement);
+
+    // since the behaviors are different when it comes to namespaces
+    // this must be implemented differently
+
+    /**
+     * Method processAttributes
+     * 
+     * @param node
+     */
+    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(parser.getAttributeLocalName(i), parser
+                    .getAttributeValue(i), ns);
+        }
+    }
+
+    /**
+     * Method createOMText
+     * 
+     * @return
+     * @throws OMException
+     */
+    protected OMNode createOMText() throws OMException {
+        if (lastNode == null) {
+            throw new OMException();
+        }
+        OMNode node;
+        if (lastNode.isComplete()) {
+            node = omfactory.createText(lastNode.getParent(), parser.getText());
+            lastNode.setNextSibling(node);
+            node.setPreviousSibling(lastNode);
+        } else {
+            OMElementImpl e = (OMElementImpl) lastNode;
+            node = omfactory.createText(e, parser.getText());
+            e.setFirstChild(node);
+        }
+        return node;
+    }
+
+    /**
+     * Method reset
+     * 
+     * @param node
+     * @throws OMException
+     */
+    public void reset(OMNode node) throws OMException {
+        lastNode = null;
+    }
+
+    /**
+     * Method discard
+     * 
+     * @param el
+     * @throws OMException
+     */
+    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.getQName()));
+            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);
+        }
+    }
+
+    /**
+     * Method getText
+     * 
+     * @return
+     * @throws OMException
+     */
+    public String getText() throws OMException {
+        return parser.getText();
+    }
+
+    /**
+     * Method getNamespace
+     * 
+     * @return
+     * @throws OMException
+     */
+    public String getNamespace() throws OMException {
+        return parser.getNamespaceURI();
+    }
+
+    /**
+     * Method getNamespaceCount
+     * 
+     * @return
+     * @throws OMException
+     */
+    public int getNamespaceCount() throws OMException {
+        try {
+            return parser.getNamespaceCount();
+        } catch (Exception e) {
+            throw new OMException(e);
+        }
+    }
+
+    /**
+     * Method getNamespacePrefix
+     * 
+     * @param index
+     * @return
+     * @throws OMException
+     */
+    public String getNamespacePrefix(int index) throws OMException {
+        try {
+            return parser.getNamespacePrefix(index);
+        } catch (Exception e) {
+            throw new OMException(e);
+        }
+    }
+
+    /**
+     * Method getNamespaceUri
+     * 
+     * @param index
+     * @return
+     * @throws OMException
+     */
+    public String getNamespaceUri(int index) throws OMException {
+        try {
+            return parser.getNamespaceURI(index);
+        } catch (Exception e) {
+            throw new OMException(e);
+        }
+    }
+
+    /**
+     * Method setCache
+     * 
+     * @param b
+     */
+    public void setCache(boolean b) {
+        if (parserAccessed && b) {
+            throw new UnsupportedOperationException(
+                    "parser accessed. cannot set cache");
+        }
+        cache = b;
+    }
+
+    /**
+     * Method getName
+     * 
+     * @return
+     * @throws OMException
+     */
+    public String getName() throws OMException {
+        return parser.getLocalName();
+    }
+
+    /**
+     * Method getPrefix
+     * 
+     * @return
+     * @throws OMException
+     */
+    public String getPrefix() throws OMException {
+        return parser.getPrefix();
+    }
+
+    /**
+     * Method getAttributeCount
+     * 
+     * @return
+     * @throws OMException
+     */
+    public int getAttributeCount() throws OMException {
+        return parser.getAttributeCount();
+    }
+
+    /**
+     * Method getAttributeNamespace
+     * 
+     * @param arg
+     * @return
+     * @throws OMException
+     */
+    public String getAttributeNamespace(int arg) throws OMException {
+        return parser.getAttributeNamespace(arg);
+    }
+
+    /**
+     * Method getAttributeName
+     * 
+     * @param arg
+     * @return
+     * @throws OMException
+     */
+    public String getAttributeName(int arg) throws OMException {
+        return parser.getAttributeNamespace(arg);
+    }
+
+    /**
+     * Method getAttributePrefix
+     * 
+     * @param arg
+     * @return
+     * @throws OMException
+     */
+    public String getAttributePrefix(int arg) throws OMException {
+        return parser.getAttributeNamespace(arg);
+    }
+
+    /**
+     * Method getParser
+     * 
+     * @return
+     */
+    public Object getParser() {
+        if (!cache) {
+            parserAccessed = true;
+            return parser;
+        } else {
+            throw new UnsupportedOperationException(
+                    "cache must be switched off to access the parser");
+        }
+    }
+
+    /**
+     * Method isCompleted
+     * 
+     * @return
+     */
+    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. If the cache is set to false, then should be return the
+     * event, *without* building the OM tree. 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;
+
+    /**
+     * @return
+     */
+    public short getBuilderType() {
+        return OMConstants.PULL_TYPE_BUILDER;
+    }
+
+    /**
+     * Method registerExternalContentHandler
+     * 
+     * @param obj
+     */
+    public void registerExternalContentHandler(Object obj) {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Method getRegisteredContentHandler
+     * 
+     * @return
+     */
+    public Object getRegisteredContentHandler() {
+        throw new UnsupportedOperationException();
+    }
+}
\ No newline at end of file

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/builder/StAXOMBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/builder/StAXOMBuilder.java?view=auto&rev=158906
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/builder/StAXOMBuilder.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/builder/StAXOMBuilder.java Thu Mar 24 02:17:28 2005
@@ -0,0 +1,199 @@
+/*
+ * 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.builder;
+
+import java.io.InputStream;
+
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMException;
+import org.apache.axis.om.OMFactory;
+import org.apache.axis.om.OMNamespace;
+import org.apache.axis.om.OMNode;
+import org.apache.axis.om.OMXMLParserWrapper;
+import org.apache.axis.om.SOAPEnvelope;
+import org.apache.axis.om.impl.llom.OMDocument;
+
+/**
+ * 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 {
+    /**
+     * Field document
+     */
+    protected OMDocument document;
+
+    /**
+     * Field omFactory
+     */
+    protected OMFactory omFactory;
+
+    /**
+     * Constructor StAXOMBuilder
+     * 
+     * @param ombuilderFactory
+     * @param parser
+     * @throws FactoryConfigurationError
+     * @throws XMLStreamException
+     */
+    public StAXOMBuilder(OMFactory ombuilderFactory, InputStream inStream)
+            throws XMLStreamException, FactoryConfigurationError {
+        super(ombuilderFactory, inStream);
+        document = new OMDocument(this);
+        omfactory = OMFactory.newInstance();
+    }
+
+    /**
+     * Constructor StAXOMBuilder
+     * 
+     * @param parser
+     * @throws FactoryConfigurationError
+     * @throws XMLStreamException
+     */
+    public StAXOMBuilder(InputStream inStream) throws XMLStreamException,
+            FactoryConfigurationError {
+        super(inStream);
+        document = new OMDocument(this);
+        omfactory = OMFactory.newInstance();
+    }
+
+    /**
+     * Method createOMElement
+     * 
+     * @return
+     * @throws OMException
+     */
+    protected OMNode createOMElement() throws OMException {
+        OMElement node;
+        String elementName = parser.getLocalName();
+        if (lastNode == null) {
+            node = omfactory.createOMElement(elementName, null, null, this);
+            document.setRootElement(node);
+        } else if (lastNode.isComplete()) {
+            node = omfactory.createOMElement(elementName, null, lastNode
+                    .getParent(), this);
+            lastNode.setNextSibling(node);
+            node.setPreviousSibling(lastNode);
+        } else {
+            OMElement e = (OMElement) lastNode;
+            node = omfactory.createOMElement(elementName, null,
+                    (OMElement) lastNode, this);
+            e.setFirstChild(node);
+        }
+
+        // create the namespaces
+        processNamespaceData(node, false);
+
+        // fill in the attributes
+        processAttributes(node);
+        return node;
+    }
+
+    /**
+     * Method getOMEnvelope
+     * 
+     * @return
+     * @throws OMException
+     */
+    public SOAPEnvelope getOMEnvelope() throws OMException {
+        throw new UnsupportedOperationException(); // TODO implement this
+    }
+
+    /**
+     * Method next
+     * 
+     * @return
+     * @throws OMException
+     */
+    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 {
+                    OMElement e = (OMElement) 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) {
+            throw new OMException(e);
+        }
+    }
+
+    /**
+     * Method getDocumentElement
+     * 
+     * @return
+     */
+    public OMElement getDocumentElement() {
+        return document.getRootElement();
+    }
+
+    /**
+     * Method processNamespaceData
+     * 
+     * @param node
+     * @param isSOAPElement
+     */
+    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/MTOM2/src/java/org/apache/axis/om/impl/llom/builder/StAXSOAPModelBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/builder/StAXSOAPModelBuilder.java?view=auto&rev=158906
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/builder/StAXSOAPModelBuilder.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/builder/StAXSOAPModelBuilder.java Thu Mar 24 02:17:28 2005
@@ -0,0 +1,341 @@
+/*
+ * 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.builder;
+
+import java.io.InputStream;
+
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axis.om.OMConstants;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMException;
+import org.apache.axis.om.OMFactory;
+import org.apache.axis.om.OMNamespace;
+import org.apache.axis.om.OMNode;
+import org.apache.axis.om.SOAPBody;
+import org.apache.axis.om.SOAPEnvelope;
+import org.apache.axis.om.impl.llom.OMElementImpl;
+import org.apache.axis.om.impl.llom.SOAPEnvelopeImpl;
+import org.apache.axis.om.impl.llom.exception.OMBuilderException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Class StAXSOAPModelBuilder
+ */
+public class StAXSOAPModelBuilder extends StAXBuilder {
+    /**
+     * Field envelope
+     */
+    private SOAPEnvelopeImpl envelope;
+
+    /**
+     * Field headerPresent
+     */
+    private boolean headerPresent = false;
+
+    /**
+     * Field bodyPresent
+     */
+    private boolean bodyPresent = false;
+
+    /**
+     * Field log
+     */
+    private Log log = LogFactory.getLog(getClass());
+
+    /**
+     * element level 1 = envelope level element level 2 = Header or Body level
+     * element level 3 = HeaderElement or BodyElement level
+     */
+    private int elementLevel = 0;
+
+    /**
+     * Constructor StAXSOAPModelBuilder
+     * 
+     * @param ombuilderFactory
+     * @param inStream
+     * @throws FactoryConfigurationError
+     * @throws XMLStreamException
+     */
+    public StAXSOAPModelBuilder(OMFactory ombuilderFactory, InputStream inStream)
+            throws XMLStreamException, FactoryConfigurationError {
+        super(inStream);
+    }
+
+    /**
+     * Constructor StAXSOAPModelBuilder
+     * 
+     * @param parser
+     * @throws FactoryConfigurationError
+     * @throws XMLStreamException
+     */
+    public StAXSOAPModelBuilder(InputStream inStream)
+            throws XMLStreamException, FactoryConfigurationError {
+        super(inStream);
+    }
+
+    /**
+     * Constructor StAXSOAPModelBuilder to be used by MTOMSOAPModelBuilder
+     * 
+     * @param ombuilderFactory
+     */
+    protected StAXSOAPModelBuilder(OMFactory ombuilderFactory) {
+        super(ombuilderFactory);
+    }
+
+    /**
+     * Constructor StAXSOAPModelBuilder to be used by MTOMSOAPModelBuilder
+     */
+    protected StAXSOAPModelBuilder() {
+        super();
+    }
+
+    /**
+     * Method getSOAPEnvelope
+     * 
+     * @return
+     * @throws OMException
+     */
+    public SOAPEnvelope getSOAPEnvelope() throws OMException {
+        while ((envelope == null) && !done) {
+            next();
+        }
+        return envelope;
+    }
+
+    /**
+     * Method createOMElement
+     * 
+     * @return
+     * @throws OMException
+     */
+    protected OMNode createOMElement() throws OMException {
+        OMElement node;
+        String elementName = parser.getLocalName();
+        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);
+        log.info("Build the OMElelment {" + node.getNamespaceName() + '}'
+                + node.getLocalName() + "By the StaxSOAPModelBuilder");
+        return node;
+    }
+
+    /**
+     * Method constructNode
+     * 
+     * @param parent
+     * @param elementName
+     * @param isEnvelope
+     * @return
+     */
+    protected OMElement constructNode(OMElement parent, String elementName,
+            boolean isEnvelope) {
+        OMElement element = null;
+        if (isEnvelope) {
+            if (!elementName
+                    .equalsIgnoreCase(OMConstants.SOAPENVELOPE_LOCAL_NAME)) {
+                throw new OMException(
+                        "First Element must contain the local name, "
+                                + OMConstants.SOAPENVELOPE_LOCAL_NAME);
+            }
+            envelope = (SOAPEnvelopeImpl) ombuilderFactory.createSOAPEnvelope(
+                    null, this);
+            element = (OMElementImpl) envelope;
+            processNamespaceData(element, true);
+        } else if (elementLevel == 2) {
+
+            // this is either a header or a body
+            if (elementName.equals(OMConstants.HEADER_LOCAL_NAME)) {
+                if (headerPresent) {
+                    throw new OMBuilderException(
+                            "Multiple headers encountered!");
+                }
+                if (bodyPresent) {
+                    throw new OMBuilderException("Header Body wrong order!");
+                }
+                headerPresent = true;
+                element = ombuilderFactory.createSOAPHeader(
+                        (SOAPEnvelope) parent, this);
+
+                // envelope.setHeader((SOAPHeader)element);
+                processNamespaceData(element, true);
+            } else if (elementName.equals(OMConstants.BODY_LOCAL_NAME)) {
+                if (bodyPresent) {
+                    throw new OMBuilderException(
+                            "Multiple body elements encountered");
+                }
+                bodyPresent = true;
+                element = ombuilderFactory.createSOAPBody(
+                        (SOAPEnvelope) parent, this);
+
+                // envelope.setBody((SOAPBody)element);
+                processNamespaceData(element, true);
+            } else {
+                throw new OMBuilderException(
+                        elementName
+                                + " is not supported here. Envelope can not have elements other than Header and Body.");
+            }
+        } else if ((elementLevel == 3)
+                && parent.getLocalName().equalsIgnoreCase(
+                        OMConstants.HEADER_LOCAL_NAME)) {
+
+            // this is a headerblock
+            element = ombuilderFactory.createSOAPHeaderBlock(elementName, null,
+                    parent, this);
+            processNamespaceData(element, false);
+        } else if ((elementLevel == 3)
+                && parent.getLocalName().equalsIgnoreCase(
+                        OMConstants.BODY_LOCAL_NAME)
+                && elementName
+                        .equalsIgnoreCase(OMConstants.BODY_FAULT_LOCAL_NAME)) {
+
+            // this is a headerblock
+            element = ombuilderFactory.createSOAPFault(null, (SOAPBody) parent,
+                    this);
+            processNamespaceData(element, false);
+        } else {
+
+            // this is neither of above. Just create an element
+            element = ombuilderFactory.createOMElement(elementName, null,
+                    parent, this);
+            processNamespaceData(element, false);
+        }
+        return element;
+    }
+
+    /**
+     * Method next
+     * 
+     * @return
+     * @throws OMException
+     */
+    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:
+                elementLevel++;
+                lastNode = createOMElement();
+                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);
+                }
+                elementLevel--;
+                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) {
+            throw new OMException(e);
+        }
+    }
+
+    /**
+     * Method getDocumentElement
+     * 
+     * @return
+     */
+    public OMElement getDocumentElement() {
+        return getSOAPEnvelope();
+    }
+
+    /**
+     * Method processNamespaceData
+     * 
+     * @param node
+     * @param isSOAPElement
+     */
+    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
+        String namespaceURI = parser.getNamespaceURI();
+        String prefix = parser.getPrefix();
+        OMNamespace namespace = null;
+        if (!"".equals(namespaceURI)) {
+            if (prefix == null) {
+                // this means, this elements has a default namespace or it has
+                // inherited a default namespace from its parent
+                namespace = node.findDeclaredNamespace(namespaceURI, "");
+                if (namespace == null) {
+                    namespace = node.declareNamespace(namespaceURI, "");
+                }
+            } else {
+                namespace = node.findInScopeNamespace(namespaceURI, prefix);
+            }
+            node.setNamespace(namespace);
+        } else {
+
+        }
+
+        // TODO we got to have this to make sure OM reject mesagess that are not
+        // sname space qualified
+        // But got to comment this to interop with Axis.1.x
+        // if (namespace == null) {
+        // throw new OMException("All elements must be namespace qualified!");
+        // }
+        if (isSOAPElement) {
+            if (node.getNamespace() != null
+                    && !node.getNamespace().getName().equals(
+                            OMConstants.SOAP_ENVELOPE_NAMESPACE_URI)) {
+                throw new OMBuilderException("invalid SOAP namespace URI");
+            }
+        }
+
+    }
+}
\ No newline at end of file

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/mtom/ByteArrayDataSource.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/mtom/ByteArrayDataSource.java?view=auto&rev=158906
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/mtom/ByteArrayDataSource.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM2/src/java/org/apache/axis/om/impl/llom/mtom/ByteArrayDataSource.java Thu Mar 24 02:17:28 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");
+    }
+}
+