axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chinth...@apache.org
Subject svn commit: r156512 [1/4] - in webservices/axis/trunk/archive/java/scratch/Thilina: ./ MTOM/ MTOM/lib/ MTOM/src/ MTOM/src/java/ MTOM/src/java/org/ MTOM/src/java/org/apache/ MTOM/src/java/org/apache/axis/ MTOM/src/java/org/apache/axis/encoding/ MTOM/src/java/org/apache/axis/impl/ MTOM/src/java/org/apache/axis/impl/llom/ MTOM/src/java/org/apache/axis/impl/llom/builder/ MTOM/src/java/org/apache/axis/impl/llom/exception/ MTOM/src/java/org/apache/axis/impl/llom/factory/ MTOM/src/java/org/apache/axis/impl/llom/mtom/ MTOM/src/java/org/apache/axis/impl/llom/serialize/ MTOM/src/java/org/apache/axis/impl/llom/traverse/ MTOM/src/java/org/apache/axis/om/ MTOM/src/test-resources/ MTOM/src/test/ MTOM/src/test/org/ MTOM/src/test/org/apache/ MTOM/src/test/org/apache/axis/ MTOM/src/test/org/apache/axis/mtom/
Date Tue, 08 Mar 2005 08:56:29 GMT
Author: chinthaka
Date: Tue Mar  8 00:56:12 2005
New Revision: 156512

URL: http://svn.apache.org/viewcvs?view=rev&rev=156512
Log:
Applying Thilina's patch on MTOM implementation.

Added:
    webservices/axis/trunk/archive/java/scratch/Thilina/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/lib/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/lib/activation.jar   (with props)
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/lib/axis2-core-M1.jar   (with props)
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/lib/axis2-om-M1.jar   (with props)
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/lib/jsr173_1.0_api.jar   (with props)
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/lib/jsr173_1.0_ri.jar   (with props)
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/lib/mail.jar   (with props)
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/encoding/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/encoding/Base64.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMAttributeImpl.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMDocument.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMElementImpl.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMNamedNodeImpl.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMNamespaceImpl.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMNavigator.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMNodeImpl.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMStAXWrapper.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMTextImpl.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPBodyImpl.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPEnvelopeImpl.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPFaultImpl.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPHeaderBlockImpl.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPHeaderImpl.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/builder/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/builder/StAXBuilder.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/builder/StAXOMBuilder.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/MTOMException.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMBuilderException.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMSerializerException.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMStreamingException.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/XMLStreamException.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/factory/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/factory/OMLinkedListImplFactory.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/AttachmentPart.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/ByteArrayDataSource.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEBodyPartInputStream.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEInputStream.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEParser.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MTOMBuilder.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MTOMXMLStreamWriter.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/OMBlob.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/serialize/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/serialize/SimpleOMSerializer.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/serialize/StreamingOMSerializer.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/serialize/XMLSerilazer.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/traverse/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/traverse/OMChildrenIterator.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/traverse/OMChildrenQNameIterator.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/FactoryFinder.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMAttribute.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMBody.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMConstants.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMElement.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMEnvelope.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMException.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMFactory.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMFactoryException.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMFault.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMHeader.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMHeaderBlock.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMNamedNode.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMNamespace.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMNode.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMText.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMXMLParserWrapper.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OutObject.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/SOAPBody.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/SOAPEnvelope.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/SOAPFault.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/SOAPHeader.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/SOAPHeaderBlock.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/StreamingWrapper.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/test/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/test-resources/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/test-resources/OMSerializeBase64Out.txt
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/test-resources/OMSerializeMTOMBaseOut.txt
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/test-resources/OMSerializeMTOMOut.txt
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/test/org/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/test/org/apache/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/test/org/apache/axis/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/test/org/apache/axis/mtom/
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/test/org/apache/axis/mtom/MTOMFileTest.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/test/org/apache/axis/mtom/MTOMOMSerializeTester.java
    webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/test/org/apache/axis/mtom/MtomTesterWhitemesaFile1.java

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

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

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

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

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

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

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

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

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

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

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

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

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/encoding/Base64.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/encoding/Base64.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/encoding/Base64.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/encoding/Base64.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,288 @@
+/*
+ * 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/MTOM/src/java/org/apache/axis/impl/llom/OMAttributeImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMAttributeImpl.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMAttributeImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMAttributeImpl.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,78 @@
+package org.apache.axis.impl.llom;
+
+import org.apache.axis.om.OMAttribute;
+import org.apache.axis.om.OMNamespace;
+
+import javax.xml.namespace.QName;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * <p/>
+ */
+public class OMAttributeImpl implements OMAttribute {
+
+    private String localName;
+    private String value;
+    private OMNamespace namespace;
+
+    private static String QUOTE_ENTITY = "&quot;";
+    private static Matcher matcher = Pattern.compile("\"").matcher(null);
+
+    public OMAttributeImpl(String localName, OMNamespace ns, String value) {
+        setLocalName(localName);
+        setValue(value);
+        setOMNamespace(ns);
+    }
+
+    synchronized static String replaceQuoteWithEntity(String value) {
+        matcher.reset(value);
+        return matcher.replaceAll(QUOTE_ENTITY);
+    }
+
+    public QName getQName() {
+
+
+        String namespaceName = namespace != null ? namespace.getName() : null;
+        return new QName(namespaceName, localName);
+    }
+
+    // -------- Getters and Setters
+    public String getLocalName() {
+        return localName;
+    }
+
+    public void setLocalName(String localName) {
+        this.localName = localName;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    public void setOMNamespace(OMNamespace omNamespace) {
+        this.namespace = omNamespace;
+    }
+
+    public OMNamespace getNamespace() {
+        return namespace;
+    }
+
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMDocument.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMDocument.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMDocument.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMDocument.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,52 @@
+package org.apache.axis.impl.llom;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMXMLParserWrapper;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * <p/>
+ */
+public class OMDocument {
+    private OMElement rootElement;
+    private OMXMLParserWrapper parserWrapper;
+
+    /**
+     * @param rootElement
+     * @param parserWrapper
+     */
+    public OMDocument(OMElement rootElement, OMXMLParserWrapper parserWrapper) {
+        this.rootElement = rootElement;
+        this.parserWrapper = parserWrapper;
+    }
+
+    /**
+     * @param parserWrapper
+     */
+    public OMDocument(OMXMLParserWrapper parserWrapper) {
+        this.parserWrapper = parserWrapper;
+    }
+
+    public OMElement getRootElement() {
+        if (rootElement == null) {
+            parserWrapper.next();
+        }
+        return rootElement;
+    }
+
+    public void setRootElement(OMElement rootElement) {
+        this.rootElement = rootElement;
+    }
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMElementImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMElementImpl.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMElementImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMElementImpl.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,372 @@
+package org.apache.axis.impl.llom;
+
+import org.apache.axis.impl.llom.traverse.OMChildrenIterator;
+import org.apache.axis.impl.llom.traverse.OMChildrenQNameIterator;
+import org.apache.axis.om.*;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.ListIterator;
+
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * <p/>
+ */
+public class OMElementImpl extends OMNamedNodeImpl implements OMElement {
+
+    private OMNode firstChild;
+    private OMXMLParserWrapper builder;
+    private OMAttributeImpl firstAttribute;
+    private ArrayList namespaces;
+    private ArrayList attributes;
+
+    public OMElementImpl(OMElement parent) {
+        super(parent);
+        done = true;
+    }
+
+
+    public OMElementImpl(String localName, OMNamespace ns) {
+        super(localName, ns, null);
+        done = true;
+    }
+
+
+    public OMElementImpl(String localName, OMNamespace ns, OMElement parent, OMXMLParserWrapper builder) {
+        super(localName, ns, parent);
+        this.builder = builder;
+    }
+
+    /**
+     * This will add child to the element. One can decide whether he append the
+     * child or he adds to the front of the children list
+     *
+     * @param child
+     */
+    public void addChild(OMNode child) {
+        addChild((OMNodeImpl) child);
+    }
+
+    /**
+     * This will search for children with a given QName and will return an
+     * iterator to traverse through the OMNodes. This QName can contain any
+     * combination of prefix, localname and URI
+     *
+     * @param elementQName
+     * @return
+     * @throws org.apache.axis.om.OMException
+     */
+    public Iterator getChildrenWithName(QName elementQName) throws OMException {
+        return new OMChildrenQNameIterator((OMNodeImpl) getFirstChild(), elementQName);
+    }
+
+    private void addChild(OMNodeImpl child) {
+        if (firstChild == null && !done)
+            builder.next();
+        child.setPreviousSibling(null);
+        child.setNextSibling(firstChild);
+        if (firstChild != null) {
+            OMNodeImpl firstChildImpl = (OMNodeImpl) firstChild;
+            firstChildImpl.setPreviousSibling(child);
+        }
+        child.setParent(this);
+//        child.setComplete(true);
+        firstChild = child;
+    }
+
+    /**
+     * This will give the next sibling. This can be an OMAttribute for
+     * OMAttribute or OMText or OMELement for others.
+     *
+     * @return
+     * @throws org.apache.axis.om.OMException
+     */
+    public OMNode getNextSibling() throws OMException {
+        while (!done)
+            builder.next();
+        return super.getNextSibling();
+    }
+
+    /**
+     * This returns a collection of this element. Children can be of types
+     * OMElement, OMText.
+     */
+    public Iterator getChildren() {
+        return new OMChildrenIterator(getFirstChild());
+    }
+
+    // --------------------- Namespace Methods ------------------------------------------------------------
+    /**
+     * THis will create a namespace in the current element scope
+     *
+     * @param uri
+     * @param prefix
+     * @return
+     */
+    public OMNamespace declareNamespace(String uri, String prefix) {
+
+        if (namespaces == null) {
+            namespaces = new ArrayList(5);
+            // the default size of the ArrayList is 10. But I think this is too much as on average number of namespaces is
+            // much more than 10. So I selected 5. Hope this is ok as an initial value. -- Eran Chinthaka 13/12/2004
+
+        }
+        OMNamespaceImpl ns = new OMNamespaceImpl(uri, prefix);
+        namespaces.add(ns);
+        return ns;
+    }
+
+    //TODO  correct this
+    public void setValue(String value) {
+        OMText txt = OMFactory.newInstance().createText(value);
+        this.addChild(txt);
+    }
+
+    /**
+     * @param namespace
+     * @return
+     */
+    public OMNamespace declareNamespace(OMNamespace namespace) {
+        if (namespaces == null) {
+            namespaces = new ArrayList(5);
+            // the default size of the ArrayList is 10. But I think this is too much as on average number of namespaces is
+            // much more than 10. So I selected 5. Hope this is ok as an initial value. -- Eran Chinthaka 13/12/2004
+
+        }
+        namespaces.add(namespace);
+        return namespace;
+    }
+
+    /**
+     * This will find a namespace with the given uri and prefix, in the scope of
+     * the docuemnt. This will start to find from the current element and goes
+     * up in the hiararchy until this finds one. If none is found, return null
+     *
+     * @param uri
+     * @param prefix
+     * @return
+     * @throws org.apache.axis.om.OMException
+     */
+    public OMNamespace findInScopeNamespace(String uri, String prefix) throws OMException {
+
+        // check in the current element
+        OMNamespace namespace = findDeclaredNamespace(uri, prefix);
+        if (namespace != null) {
+            return namespace;
+        }
+        // go up to check with ancestors
+        if (parent != null)
+            return parent.findInScopeNamespace(uri, prefix);
+        return null;
+    }
+
+    /**
+     * This will ckeck for the namespace <B>only</B> in the current Element
+     *
+     * @param uri
+     * @param prefix
+     * @return
+     * @throws OMException
+     */
+    public OMNamespace findDeclaredNamespace(String uri, String prefix) throws OMException {
+
+        if (namespaces == null) {
+            return null;
+        }
+        // check in the current element
+        ListIterator namespaceListIterator = namespaces.listIterator();
+        if (prefix == null) {
+            while (namespaceListIterator.hasNext()) {
+                OMNamespace omNamespace = (OMNamespace) namespaceListIterator.next();
+                if (omNamespace.getName().equals(uri)) {
+                    return omNamespace;
+                }
+            }
+        } else {
+            while (namespaceListIterator.hasNext()) {
+                OMNamespace omNamespace = (OMNamespace) namespaceListIterator.next();
+                if (omNamespace.equals(uri, prefix)) {
+                    return omNamespace;
+                }
+            }
+
+        }
+        return null;
+
+    }
+
+    public Iterator getAllDeclaredNamespaces() {
+        if (namespaces == null) {
+
+            // no namespace declared in this element.
+            // return a null iterator
+            // have to look in to this later
+            return new Iterator() {
+                public void remove() {
+                    throw new UnsupportedOperationException();
+                }
+
+                public boolean hasNext() {
+                    return false;
+                }
+
+                public Object next() {
+                    throw new UnsupportedOperationException();
+                }
+            };
+        }
+
+        return namespaces.listIterator();
+    }
+
+    // ---------------------------------------------------------------------------------------------------------------
+
+    /**
+     * This will help to search for an attribute with a given QName within this
+     * Element
+     *
+     * @param qname
+     * @return
+     * @throws org.apache.axis.om.OMException
+     */
+    public OMAttribute getAttributeWithQName(QName qname) throws OMException {
+
+        if (attributes == null) {
+            return null;
+        }
+
+        ListIterator attrIter = attributes.listIterator();
+        OMAttribute omAttribute = null;
+        while (attrIter.hasNext()) {
+            omAttribute = (OMAttribute) attrIter.next();
+            if (omAttribute.getQName().equals(qname)) {
+                return omAttribute;
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * This will return a List of OMAttributes
+     *
+     * @return
+     */
+    public Iterator getAttributes() {
+        if (attributes == null) {
+            attributes = new ArrayList(1);
+        }
+        return attributes.listIterator();
+    }
+
+    /**
+     * This will insert attribute to this element. Implementor can decide as to
+     * insert this in the front or at the end of set of attributes
+     *
+     * @param attr
+     */
+    public void insertAttribute(OMAttribute attr) {
+        if (attributes == null) {
+            attributes = new ArrayList(5);
+        }
+        attributes.add(attr);
+    }
+
+    public void removeAttribute(OMAttribute attr) {
+        if (attributes.indexOf(attr) != -1) {
+            attributes.remove(attr);
+        }
+    }
+
+    public void setBuilder(OMXMLParserWrapper wrapper) {
+        this.builder = wrapper;
+    }
+
+    public OMXMLParserWrapper getBuilder() {
+        return builder;
+    }
+
+    /**
+     * This will force the parser to proceed, if parser has not yet finished
+     * with the XML input
+     */
+    public void buildNext() {
+        builder.next();
+    }
+
+    public OMNode getFirstChild() {
+        if (firstChild == null && !done)
+            buildNext();
+        return firstChild;
+    }
+
+
+    public void setFirstChild(OMNode firstChild) {
+        this.firstChild = firstChild;
+    }
+
+
+    /**
+     * This will remove this information item and its children, from the model
+     * completely
+     *
+     * @throws org.apache.axis.om.OMException
+     */
+    public void detach() throws OMException {
+        if (done)
+            super.detach();
+        else
+            builder.discard(this);
+    }
+
+    public boolean isComplete() {
+        return done;
+    }
+
+    /**
+     * 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 org.apache.axis.om.OMException
+     */
+    public String getValue() throws OMException {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * This is to get the type of node, as this is the super class of all the
+     * nodes
+     *
+     * @return
+     * @throws org.apache.axis.om.OMException
+     */
+    public short getType() throws OMException {
+        return OMNode.ELEMENT_NODE;
+    }
+
+    /**
+     *
+     */
+    public XMLStreamReader getPullParser(boolean cacheOff) {
+        if (builder == null && cacheOff)
+            throw new UnsupportedOperationException("This element was not created in a manner to be switched");
+        return new OMStAXWrapper(builder, this, cacheOff);
+    }
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMNamedNodeImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMNamedNodeImpl.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMNamedNodeImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMNamedNodeImpl.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,94 @@
+package org.apache.axis.impl.llom;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMException;
+import org.apache.axis.om.OMNamedNode;
+import org.apache.axis.om.OMNamespace;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * <p/>
+ */
+public class OMNamedNodeImpl extends OMNodeImpl implements OMNamedNode {
+
+    protected OMNamespace ns;
+    protected String localName;
+
+
+    public OMNamedNodeImpl(String localName, OMNamespace ns, OMElement parent) {
+        super(parent);
+        this.localName = localName;
+        this.ns = ns;
+    }
+
+    public OMNamedNodeImpl(OMElement parent) {
+        super(parent);
+    }
+
+    public String getLocalName() {
+        return localName;
+    }
+
+    public void setLocalName(String localName) {
+        this.localName = localName;
+    }
+
+    public OMNamespace getNamespace() throws OMException {
+        if (ns == null)
+            throw new OMException("all elements in a soap message must be namespace qualified");
+        return ns;
+    }
+
+    public String getNamespaceName() {
+        return ns.getName();
+    }
+
+    /**
+     * @param namespace
+     */
+    public void setNamespace(OMNamespace namespace) {
+        this.ns = namespace;
+    }
+
+
+    public QName getQName() {
+        QName qName = new QName(ns.getName(), localName, ns.getPrefix());
+        return qName;
+    }
+
+//    /**
+//     * Equals method of QName seems doesn't working the way I need in this situation.
+//     * So implementing my own !!
+//     *
+//     * @param qName
+//     * @return
+//     */
+//    public boolean isQNameEquals(QName qName) {
+//        String thatLocalName = qName.getLocalName();
+//
+//        return ((thatLocalName == null && this.localName == null) || (thatLocalName != null && thatLocalName.equalsIgnoreCase(this.localName)))
+//                && ns.equals(qName.getNamespaceURI(), qName.getPrefix());
+//    }
+//
+//    private String getStringValue(String s) {
+//        if (s == null) {
+//            return "null";
+//        }
+//
+//        return s;
+//    }
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMNamespaceImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMNamespaceImpl.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMNamespaceImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMNamespaceImpl.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,51 @@
+package org.apache.axis.impl.llom;
+
+import org.apache.axis.om.OMNamespace;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * <p/>
+ */
+public class OMNamespaceImpl implements OMNamespace {
+    private String prefix;
+    private String uri;
+    //private String value;
+
+    /**
+     * @param uri
+     * @param prefix
+     */
+    public OMNamespaceImpl(String uri, String prefix) {
+        this.uri = uri;
+        this.prefix = prefix;
+    }
+
+
+    public boolean equals(String uri, String prefix) {
+        return ((prefix == null && this.prefix == null) || (prefix != null && prefix.equals(this.prefix)))
+                && uri.equals(uri);
+    }
+
+
+    public String getPrefix() {
+        return prefix;
+    }
+
+    public String getName() {
+        return uri;
+    }
+
+
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMNavigator.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMNavigator.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMNavigator.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMNavigator.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,158 @@
+/*
+* Copyright  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.
+*
+*/
+
+/*
+* Created on Sep 25, 2004
+*
+
+*/
+package org.apache.axis.impl.llom;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMNode;
+
+/**
+ * Refer to the testClass to find out how to use features like isNavigable,
+ * isComplete and step
+ */
+public class OMNavigator {
+
+    protected OMNode node;
+    private boolean visited;
+    private OMNode next;
+
+    //root is the starting element. Once the navigator comes back to the
+    //root, the traversal is terminated
+    private OMNode root;
+    private boolean backtracked;
+
+    //flags that tell the status of the navigator
+    private boolean end = false;
+    private boolean start = true;
+
+    public OMNavigator() {
+    }
+
+    public OMNavigator(OMNode node) {
+        init(node);
+    }
+
+    public void init(OMNode node) {
+        next = node;
+        root = node;
+        backtracked = false;
+    }
+
+    /**
+     * get the next node
+     *
+     * @return OMnode in the sequence of preorder traversal. Note however that
+     *         an element node is treated slightly diffrently. Once the element
+     *         is passed it returns the same element in the next encounter as
+     *         well
+     */
+    public OMNode next() {
+        if (next == null) {
+            return null;
+        }
+        node = next;
+        visited = backtracked;
+        backtracked = false;
+
+        updateNextNode();
+        //set the starting and ending flags
+        if (root.equals(node)) {
+            if (!start) {
+                end = true;
+            } else {
+                start = false;
+            }
+        }
+
+        return node;
+    }
+
+    /**
+     * Private method to encapsulate the searching logic
+     */
+    private void updateNextNode() {
+        if (next instanceof OMElement && !visited) {
+
+            OMElement e = (OMElement) next;
+            if (e.getFirstChild() != null)
+                next = e.getFirstChild();
+            else if (e.isComplete())
+                backtracked = true;
+            else
+                next = null;
+
+        } else {
+            OMNode nextSibling = next.getNextSibling();
+            OMNode parent = next.getParent();
+
+            if (nextSibling != null)
+                next = nextSibling;
+            else if (parent != null && parent.isComplete()) {
+                next = parent;
+                backtracked = true;
+            } else
+                next = null;
+        }
+    }
+
+
+    public boolean visited() {
+        return visited;
+    }
+
+    /**
+     * This is a very special method. This allows the navigator to step once it
+     * has reached the existing om. At this point the isNavigable method will
+     * return false but the isComplete method may return false which means that
+     * the navigating the given element is not complete but the navigator cannot
+     * proceed
+     */
+    public void step() {
+        if (!end) {
+            next = node;
+            updateNextNode();
+        }
+    }
+
+    /**
+     * the navigable status
+     *
+     * @return
+     */
+    public boolean isNavigable() {
+        if (end)
+            return false;
+        else if (next == null)
+            return false;
+        else
+            return true;
+    }
+
+    /**
+     * The completed status
+     *
+     * @return
+     */
+    public boolean isCompleted() {
+        return end;
+    }
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMNodeImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMNodeImpl.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMNodeImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMNodeImpl.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,202 @@
+package org.apache.axis.impl.llom;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMException;
+import org.apache.axis.om.OMNode;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * <p/>
+ */
+public class OMNodeImpl implements OMNode {
+    protected OMElementImpl parent;
+    protected OMNodeImpl nextSibling;
+    protected OMNodeImpl previousSibling;
+    protected String value;
+    protected boolean done = false;
+    protected short nodeType;
+
+    public OMNodeImpl() {
+    }
+
+
+    /**
+     * For a node to exist there must be a parent
+     *
+     * @param parent
+     */
+
+
+    public OMNodeImpl(OMElement parent) {
+        if (parent instanceof OMNodeImpl)
+            this.parent = (OMElementImpl) parent;
+    }
+
+    /**
+     * This method should return the immediate parent of the node. Parent is
+     * always an Element
+     *
+     * @return
+     * @throws org.apache.axis.om.OMException
+     */
+    public OMElement getParent() throws OMException {
+        return parent;
+    }
+
+    public void setParent(OMElement element) {
+        if (element instanceof OMNodeImpl)
+            this.parent = (OMElementImpl) element;
+    }
+
+    /**
+     * This will give the next sibling. This can be an OMAttribute for
+     * OMAttribute or OMText or OMELement for others.
+     *
+     * @return
+     * @throws org.apache.axis.om.OMException
+     */
+    public OMNode getNextSibling() throws OMException {
+        if (nextSibling == null && parent != null && !parent.isComplete())
+            parent.buildNext();
+        return nextSibling;
+    }
+
+    public void setNextSibling(OMNode node) {
+        this.nextSibling = (OMNodeImpl) 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 org.apache.axis.om.OMException
+     */
+    public String getValue() throws OMException {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = 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() {
+        return true;
+    }
+
+    public void setComplete(boolean state) {
+        this.done = state;
+    }
+
+    /**
+     * This will remove this information item and its children, from the model
+     * completely
+     *
+     * @throws org.apache.axis.om.OMException
+     */
+    public void detach() throws OMException {
+        if (parent == null)
+            throw new OMException();
+        OMNodeImpl nextSibling = (OMNodeImpl) getNextSibling();
+        if (previousSibling == null)
+            parent.setFirstChild(nextSibling);
+        else
+            previousSibling.setNextSibling(nextSibling);
+        if (nextSibling != null)
+            nextSibling.setPreviousSibling(previousSibling);
+
+    }
+
+    /**
+     * This will insert a sibling just after the current information item.
+     *
+     * @param sibling
+     * @throws org.apache.axis.om.OMException
+     */
+    public void insertSiblingAfter(OMNode sibling) throws OMException {
+        if (parent == null)
+            throw new OMException();
+        sibling.setParent(parent);
+
+        if (sibling instanceof OMNodeImpl) {
+            OMNodeImpl siblingImpl = (OMNodeImpl) sibling;
+            if (nextSibling == null)
+                getNextSibling();
+            siblingImpl.setPreviousSibling(this);
+            if (nextSibling != null)
+                nextSibling.setPreviousSibling(sibling);
+            sibling.setNextSibling(nextSibling);
+            nextSibling = siblingImpl;
+        }
+
+    }
+
+    /**
+     * This will insert a sibling just before the current information item
+     *
+     * @param sibling
+     * @throws org.apache.axis.om.OMException
+     */
+    public void insertSiblingBefore(OMNode sibling) throws OMException {
+        if (parent == null)
+            throw new OMException();
+        sibling.setParent(parent);
+
+        if (sibling instanceof OMNodeImpl) {
+            OMNodeImpl siblingImpl = (OMNodeImpl) sibling;
+            siblingImpl.setPreviousSibling(previousSibling);
+            siblingImpl.setNextSibling(this);
+            if (previousSibling == null)
+                parent.setFirstChild(siblingImpl);
+            else
+                previousSibling.setNextSibling(siblingImpl);
+            previousSibling = siblingImpl;
+        }
+    }
+
+    /**
+     * This is to get the type of node, as this is the super class of all the
+     * nodes
+     *
+     * @return
+     * @throws org.apache.axis.om.OMException
+     */
+    public short getType() throws OMException {
+        return nodeType;
+    }
+
+    public void setType(short nodeType) throws OMException {
+        this.nodeType = nodeType;
+    }
+
+    public OMNode getPreviousSibling() {
+        return previousSibling;
+    }
+
+    public void setPreviousSibling(OMNode previousSibling) {
+        this.previousSibling = (OMNodeImpl) previousSibling;
+    }
+
+
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMStAXWrapper.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMStAXWrapper.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMStAXWrapper.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/OMStAXWrapper.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,865 @@
+package org.apache.axis.impl.llom;
+
+import org.apache.axis.impl.llom.exception.OMStreamingException;
+import org.apache.axis.om.*;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import java.util.Iterator;
+import java.util.Stack;
+
+/**
+ * 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.
+ */
+
+/**
+ * Note  - This class also implements the streaming constants interface to get
+ * access to the StAX constants
+ */
+public class OMStAXWrapper implements XMLStreamReader, XMLStreamConstants {
+
+
+    private OMNavigator navigator;
+    private OMXMLParserWrapper builder;
+    private XMLStreamReader parser;
+    private OMNode rootNode;
+    private boolean isFirst = true;
+    //the boolean flag that keeps the state of the document!
+    private boolean complete = false;
+
+
+    private int currentEvent = 0;
+    // navigable means the output should be taken from the navigator
+    // as soon as the navigator returns a null navigable will be reset
+    //to false and the subsequent events will be taken from the builder
+    //or the parser directly
+    private boolean navigable = true;
+
+    // SwitchingAllowed is set to false by default
+    // this means that unless the user explicitly states
+    // that he wants things not to be cached, everything will
+    // be cached
+    boolean switchingAllowed = false;
+
+    private Stack elementStack = new Stack();
+
+    //keeps the next event. The parser actually keeps one step ahead to
+    //detect the end of navigation. (at the end of the stream the navigator
+    //returns a null
+    private OMNode nextNode = null;
+
+    //holder for the current node. Needs this to generate events from the current node
+    private OMNode currentNode = null;
+
+    //needs this to refer to the last known node
+    private OMNode lastNode = null;
+
+    private boolean switched = false;
+
+    public void setAllowSwitching(boolean b) {
+        this.switchingAllowed = b;
+    }
+
+    public boolean isAllowSwitching() {
+        return switchingAllowed;
+    }
+
+    /**
+     * When constructing the OMStaxWrapper, the creator must produce the builder
+     * (an instance of the OMXMLparserWrapper of the input) and the Element Node
+     * to start parsing. The wrapper wil parse(proceed) until the end of the
+     * given element. hence care should be taken to pass the root element if the
+     * entire document is needed
+     */
+    OMStAXWrapper(OMXMLParserWrapper builder, OMElement startNode) {
+        this(builder, startNode, false);
+    }
+
+    OMStAXWrapper(OMXMLParserWrapper builder, OMElement startNode, boolean cacheOff) {
+        //create a navigator
+        this.navigator = new OMNavigator(startNode);
+        this.builder = builder;
+        this.rootNode = startNode;
+        //initaite the next and current nodes
+        //Note -  navigator is written in such a way that it first
+        //returns the starting node at the first call to it
+        currentNode = navigator.next();
+        nextNode = navigator.next();
+        switchingAllowed = cacheOff;
+    }
+
+    /**
+     * @see javax.xml.stream.XMLStreamReader#getPrefix()
+     */
+    public String getPrefix() {
+        String returnStr = null;
+        if (currentEvent == START_ELEMENT || currentEvent == END_ELEMENT) {
+            if (navigable) {
+                OMNamespace ns = ((OMElement) lastNode).getNamespace();
+                returnStr = ns == null ? null : ns.getPrefix();
+            } else {
+                returnStr = parser.getPrefix();
+            }
+        }
+        return returnStr;
+    }
+
+    /**
+     * @see javax.xml.stream.XMLStreamReader#getNamespaceURI()
+     */
+    public String getNamespaceURI() {
+        String returnStr = null;
+        if (currentEvent == START_ELEMENT || currentEvent == END_ELEMENT || currentEvent == NAMESPACE) {
+            if (navigable) {
+                OMNamespace ns = ((OMElement) lastNode).getNamespace();
+                returnStr = ns == null ? null : ns.getName();
+            } else {
+                returnStr = parser.getNamespaceURI();
+            }
+        }
+
+        return returnStr;
+    }
+
+    /**
+     * @see javax.xml.stream.XMLStreamReader#hasName()
+     */
+    public boolean hasName() {
+        if (currentEvent == START_ELEMENT || currentEvent == END_ELEMENT) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * @see javax.xml.stream.XMLStreamReader#getLocalName()
+     */
+    public String getLocalName() {
+        String returnStr = null;
+        if (currentEvent == START_ELEMENT || currentEvent == END_ELEMENT || currentEvent == ENTITY_REFERENCE) {
+            if (navigable) {
+                returnStr = ((OMElement) lastNode).getLocalName();
+            } else {
+                returnStr = parser.getLocalName();
+            }
+        }
+        return returnStr;
+    }
+
+    /**
+     * @see javax.xml.stream.XMLStreamReader#getName()
+     */
+    public QName getName() {
+        QName returnName = null;
+        if (currentEvent == START_ELEMENT || currentEvent == END_ELEMENT) {
+            if (navigable) {
+                returnName = getQName((OMNamedNode) lastNode);
+            } else {
+                returnName = parser.getName();
+            }
+        }
+        return returnName;
+    }
+
+
+    /**
+     * @see javax.xml.stream.XMLStreamReader#hasText()
+     */
+    public boolean hasText() {
+        return (currentEvent == CHARACTERS ||
+                currentEvent == DTD ||
+                currentEvent == ENTITY_REFERENCE ||
+                currentEvent == COMMENT ||
+                currentEvent == SPACE);
+    }
+
+    /**
+     * @see javax.xml.stream.XMLStreamReader#getTextLength()
+     */
+    public int getTextLength() {
+        int returnLength = 0;
+        if (hasText()) {
+            if (navigable) {
+                OMText textNode = (OMText) lastNode;
+                returnLength = textNode.getValue().length();
+            } else {
+                returnLength = parser.getTextLength();
+            }
+
+        }
+        return returnLength;
+    }
+
+    /**
+     * @see javax.xml.stream.XMLStreamReader#getTextStart()
+     */
+    public int getTextStart() {
+        int returnLength = 0;
+        if (hasText()) {
+            if (!navigable) {
+                returnLength = parser.getTextStart();
+            }
+            //Note - this has no relevant method in the OM
+        }
+        return returnLength;
+    }
+
+    /**
+     * @see javax.xml.stream.XMLStreamReader#getTextCharacters(int, char[], int,
+            *      int)
+     */
+    public int getTextCharacters(int i, char[] chars, int i1, int i2) throws XMLStreamException {
+        int returnLength = 0;
+        if (hasText()) {
+            if (!navigable) {
+                try {
+                    returnLength = parser.getTextCharacters(i, chars, i1, i2);
+                } catch (XMLStreamException e) {
+                    throw new OMStreamingException(e);
+                }
+            }
+            //Note - this has no relevant method in the OM
+        }
+        return returnLength;
+    }
+
+    /**
+     * @see javax.xml.stream.XMLStreamReader#getTextCharacters()
+     */
+    public char[] getTextCharacters() {
+        char[] returnArray = null;
+        if (hasText()) {
+            if (navigable) {
+                OMText textNode = (OMText) lastNode;
+                String str = textNode.getValue();
+                returnArray = str.toCharArray();
+            } else {
+                returnArray = parser.getTextCharacters();
+            }
+
+        }
+        return returnArray;
+    }
+
+    /**
+     * @see javax.xml.stream.XMLStreamReader#getText()
+     */
+    public String getText() {
+        String returnString = null;
+        if (hasText()) {
+            if (navigable) {
+                OMText textNode = (OMText) lastNode;
+                returnString = textNode.getValue();
+            } else {
+                returnString = parser.getText();
+            }
+        }
+        return returnString;
+    }
+
+    /**
+     * @see javax.xml.stream.XMLStreamReader#getEventType()
+     */
+    //todo this should be improved
+    public int getEventType() {
+        return currentEvent;
+    }
+
+    /**
+     * @see javax.xml.stream.XMLStreamReader#getNamespaceURI
+     */
+    public String getNamespaceURI(int i) {
+        String returnString = null;
+        if (isStartElement() || isEndElement() || currentEvent == NAMESPACE) {
+            if (navigable) {
+                OMNamespace ns = (OMNamespace) getItemFromIterator(((OMElement) lastNode).getAllDeclaredNamespaces(), i);
+                returnString = ns == null ? null : ns.getName();
+            } else {
+                returnString = parser.getNamespaceURI(i);
+            }
+        }
+        return returnString;
+    }
+
+    /**
+     * @see javax.xml.stream.XMLStreamReader#getNamespacePrefix
+     */
+    public String getNamespacePrefix(int i) {
+        String returnString = null;
+        if (isStartElement() || isEndElement() || currentEvent == NAMESPACE) {
+            if (navigable) {
+                OMNamespace ns = (OMNamespace) getItemFromIterator(((OMElement) lastNode).getAllDeclaredNamespaces(), i);
+                returnString = ns == null ? null : ns.getPrefix();
+            } else {
+                returnString = parser.getNamespacePrefix(i);
+            }
+        }
+        return returnString;
+    }
+
+    /**
+     * @see javax.xml.stream.XMLStreamReader#getNamespaceCount()
+     */
+    public int getNamespaceCount() {
+        int returnCount = 0;
+        if (isStartElement() || isEndElement() || currentEvent == NAMESPACE) {
+            if (navigable) {
+                returnCount = getCount(((OMElement) lastNode).getAllDeclaredNamespaces());
+            } else {
+                returnCount = parser.getNamespaceCount();
+            }
+        }
+        return returnCount;
+    }
+
+    /**
+     * @see javax.xml.stream.XMLStreamReader#isAttributeSpecified
+     */
+    public boolean isAttributeSpecified(int i) {
+        boolean returnValue = false;
+        if (isStartElement() || currentEvent == ATTRIBUTE) {
+            if (navigable) {
+                //theres nothing to be returned here
+            } else {
+                returnValue = parser.isAttributeSpecified(i);
+            }
+        } else {
+            throw new IllegalStateException("attribute type accessed in illegal event!");
+        }
+        return returnValue;
+    }
+
+    /**
+     * @see javax.xml.stream.XMLStreamReader#getAttributeValue
+     */
+    public String getAttributeValue(int i) {
+        String returnString = null;
+        if (isStartElement() || currentEvent == ATTRIBUTE) {
+            if (navigable) {
+                OMAttribute attrib = getAttribute((OMElement) lastNode, i);
+                if (attrib != null) {
+                    returnString = attrib.getValue();
+                }
+            } else {
+                returnString = parser.getAttributeValue(i);
+            }
+        } else {
+            throw new IllegalStateException("attribute type accessed in illegal event!");
+        }
+        return returnString;
+    }
+
+    /**
+     * @see javax.xml.stream.XMLStreamReader#getAttributeType
+     */
+    public String getAttributeType(int i) {
+        String returnString = null;
+        if (isStartElement() || currentEvent == ATTRIBUTE) {
+            if (navigable) {
+                //todo implement this
+            } else {
+                returnString = parser.getAttributeType(i);
+            }
+        } else {
+            throw new IllegalStateException("attribute type accessed in illegal event!");
+        }
+        return returnString;
+    }
+
+    /**
+     * @see javax.xml.stream.XMLStreamReader#getAttributePrefix
+     */
+    public String getAttributePrefix(int i) {
+        String returnString = null;
+        if (isStartElement() || currentEvent == ATTRIBUTE) {
+            if (navigable) {
+                OMAttribute attrib = getAttribute((OMElement) lastNode, i);
+                if (attrib != null) {
+                    OMNamespace nameSpace = attrib.getNamespace();
+                    if (nameSpace != null) {
+                        returnString = nameSpace.getPrefix();
+                    }
+                }
+            } else {
+                returnString = parser.getAttributePrefix(i);
+            }
+        } else {
+            throw new IllegalStateException("attribute prefix accessed in illegal event!");
+        }
+        return returnString;
+    }
+
+    /**
+     * @see javax.xml.stream.XMLStreamReader#getAttributeLocalName
+     */
+    public String getAttributeLocalName(int i) {
+        String returnString = null;
+        if (isStartElement() || currentEvent == ATTRIBUTE) {
+            if (navigable) {
+                OMAttribute attrib = getAttribute((OMElement) lastNode, i);
+                if (attrib != null)
+                    returnString = attrib.getLocalName();
+
+            } else {
+                returnString = parser.getAttributeLocalName(i);
+            }
+        } else {
+            throw new IllegalStateException("attribute localName accessed in illegal event!");
+        }
+        return returnString;
+    }
+
+    /**
+     * @see javax.xml.stream.XMLStreamReader#getAttributeNamespace
+     */
+    public String getAttributeNamespace(int i) {
+        String returnString = null;
+        if (isStartElement() || currentEvent == ATTRIBUTE) {
+            if (navigable) {
+                OMAttribute attrib = getAttribute((OMElement) lastNode, i);
+                if (attrib != null) {
+                    OMNamespace nameSpace = attrib.getNamespace();
+                    if (nameSpace != null) {
+                        returnString = nameSpace.getName();
+                    }
+                }
+            } else {
+                returnString = parser.getAttributeNamespace(i);
+            }
+        } else {
+            throw new IllegalStateException("attribute nameSpace accessed in illegal event!");
+        }
+        return returnString;
+    }
+
+    /**
+     * @see javax.xml.stream.XMLStreamReader#getAttributeName
+     */
+    public QName getAttributeName(int i) {
+        QName returnQName = null;
+        if (isStartElement() || currentEvent == ATTRIBUTE) {
+            if (navigable) {
+                returnQName = getAttribute((OMElement) lastNode, i).getQName();
+            } else {
+                returnQName = parser.getAttributeName(i);
+            }
+        } else {
+            throw new IllegalStateException("attribute count accessed in illegal event!");
+        }
+        return returnQName;
+    }
+
+    /**
+     * @return
+     * @see javax.xml.stream.XMLStreamReader#getAttributeCount
+     */
+    public int getAttributeCount() {
+        int returnCount = 0;
+        if (isStartElement() || currentEvent == ATTRIBUTE) {
+            if (navigable) {
+                OMElement elt = (OMElement) lastNode;
+                returnCount = getCount(elt.getAttributes());
+            } else {
+                returnCount = parser.getAttributeCount();
+            }
+
+        } else {
+            throw new IllegalStateException("attribute count accessed in illegal event!");
+        }
+
+        return returnCount;
+    }
+
+
+    //todo
+    public String getAttributeValue(String s, String s1) {
+        throw new UnsupportedOperationException();
+    }
+
+    public boolean isWhiteSpace() {
+        boolean b;
+        if (navigable) {
+            b = (currentEvent == SPACE);
+        } else {
+            b = parser.isWhiteSpace();
+        }
+
+        return b;
+    }
+
+    public boolean isCharacters() {
+        boolean b;
+        if (navigable) {
+            b = (currentEvent == CHARACTERS);
+        } else {
+            b = parser.isCharacters();
+        }
+        return b;
+    }
+
+    public boolean isEndElement() {
+        boolean b;
+        if (navigable) {
+            b = (currentEvent == END_ELEMENT);
+        } else {
+            b = parser.isEndElement();
+        }
+        return b;
+    }
+
+    /**
+     * @param i
+     * @param s
+     * @param s1
+     * @throws XMLStreamException
+     * @see javax.xml.stream.XMLStreamReader#require(int, String, String)
+     */
+    public void require(int i, String s, String s1) throws XMLStreamException {
+        throw new XMLStreamException();
+    }
+
+    public boolean isStartElement() {
+        boolean b;
+        if (navigable) {
+            b = (currentEvent == START_ELEMENT);
+        } else {
+            b = parser.isStartElement();
+        }
+        return b;
+    }
+
+    public String getNamespaceURI(String s) {
+        String returnString = null;
+        if (isStartElement() || isEndElement() || currentEvent == NAMESPACE) {
+            if (navigable) {
+                //Nothing to do here! How to get the namespacace references
+            } else {
+                returnString = parser.getNamespaceURI(s);
+            }
+        }
+        return returnString;
+    }
+
+    public void close() throws XMLStreamException {
+        //this doesnot mean anything with respect to the OM
+        if (!navigable) {
+            parser.close();
+
+        }
+
+    }
+
+    public boolean hasNext() throws XMLStreamException {
+        return !complete;
+    }
+
+    /**
+     * Not implemented yet
+     *
+     * @return
+     * @throws org.apache.axis.impl.llom.exception.OMStreamingException
+     *
+     */
+    public int nextTag() throws XMLStreamException {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * @see javax.xml.stream.XMLStreamReader#getElementText()
+     */
+    public String getElementText() throws XMLStreamException {
+
+        String returnText = "";
+
+        if (navigable) {
+            if (currentNode.getType() == OMNode.ELEMENT_NODE) {
+                //todo complete this
+                return null;
+            }
+        } else {
+            try {
+                returnText = parser.getElementText();
+            } catch (XMLStreamException e) {
+                throw new OMStreamingException(e);
+            }
+        }
+        return returnText;
+    }
+
+    public int next() throws XMLStreamException {
+
+        if (complete) {
+            throw new OMStreamingException("Parser completed!");
+        }
+
+        if (switched) {
+            //set navigable to false.Now the subsequent requests will be directed to
+            //the parser
+            navigable = false;
+        }
+        if (navigable) {
+            currentEvent = generateEvents(currentNode);
+            updateCompleteStatus();
+            updateNextNode();
+        } else {
+            currentEvent = builder.next();
+            updateCompleteStatus();
+        }
+        return currentEvent;
+    }
+
+    public Object getProperty(String s) throws IllegalArgumentException {
+        throw new UnsupportedOperationException();
+    }
+
+
+    /**
+     * This is a very important method. this keeps the navigator one step ahead
+     * and pushes the navigator one event ahead. If the nextNode is null then
+     * navigable is set to false; At the same time the parser and builder are
+     * set up for the upcoming event generation
+     */
+    private void updateNextNode() throws XMLStreamException {
+        lastNode = currentNode;
+        currentNode = nextNode;
+
+        if (navigator.isNavigable()) {
+            nextNode = navigator.next();
+        } else {
+            if (!switchingAllowed) {
+                if (navigator.isCompleted()) {
+                    nextNode = null;
+                } else {
+                    builder.next();
+                    navigator.step();
+                    nextNode = navigator.next();
+                }
+            } else {
+                //reset caching (the default is ON so it was not needed in the
+                //earlier case!
+                builder.setCache(false);
+                //load the parser
+                try {
+                    parser = (XMLStreamReader) builder.getParser();
+                } catch (ClassCastException e) {
+                    throw new XMLStreamException("incompatible parser found!", e);
+                }
+
+                switched = true;
+
+
+            }
+        }
+    }
+
+    private void updateCompleteStatus() {
+
+        if (!navigable) {
+            complete = (currentEvent == END_DOCUMENT);
+        } else {
+            if (rootNode.equals(currentNode))
+                if (isFirst)
+                    isFirst = false;
+                else
+                    complete = true;
+        }
+    }
+
+
+    public NamespaceContext getNamespaceContext() {
+        throw new UnsupportedOperationException();
+    }
+
+    public String getEncoding() {
+        throw new UnsupportedOperationException();
+    }
+
+    public Location getLocation() {
+        throw new UnsupportedOperationException();
+    }
+
+    public String getVersion() {
+        throw new UnsupportedOperationException();
+    }
+
+    public boolean isStandalone() {
+        throw new UnsupportedOperationException();
+    }
+
+    public boolean standaloneSet() {
+        throw new UnsupportedOperationException();
+    }
+
+    public String getCharacterEncodingScheme() {
+        throw new UnsupportedOperationException();
+    }
+
+    public String getPITarget() {
+        throw new UnsupportedOperationException();
+    }
+
+    public String getPIData() {
+        throw new UnsupportedOperationException();
+    }
+
+    /*
+
+    ################################################################
+    Generator methods for the OMNodes returned by the navigator
+    ################################################################
+
+    */
+
+    private int generateEvents(OMNode node) {
+        int returnEvent = 0;
+
+        int nodeType = node.getType();
+        switch (nodeType) {
+            case OMNode.ELEMENT_NODE:
+                returnEvent = generateElementEvents((OMElement) node);
+                break;
+            case OMNode.TEXT_NODE:
+                returnEvent = generateTextEvents();
+                break;
+            case OMNode.COMMENT_NODE:
+                returnEvent = generateCommentEvents();
+                break;
+            case OMNode.CDATA_SECTION_NODE:
+                returnEvent = generateCdataEvents();
+                break;
+            default:
+                break; //just ignore any other nodes
+        }
+
+        return returnEvent;
+    }
+
+
+    private int generateElementEvents(OMElement elt) {
+        int returnValue = START_ELEMENT;
+        if (!elementStack.isEmpty() && elementStack.peek().equals(elt)) {
+            returnValue = END_ELEMENT;
+            elementStack.pop();
+        } else {
+            elementStack.push(elt);
+        }
+        return returnValue;
+    }
+
+
+    private int generateTextEvents() {
+        return CHARACTERS;
+    }
+
+    private int generateCommentEvents() {
+        return COMMENT;
+    }
+
+    private int generateCdataEvents() {
+        return CDATA;
+    }
+
+    /*
+    ####################################################################
+    Other helper methods
+    ####################################################################
+    */
+
+    /**
+     * helper method
+     *
+     * @param it
+     * @return
+     */
+    private int getCount(Iterator it) {
+        int count = 0;
+        if (it != null) {
+            while (it.hasNext()) {
+                it.next();
+                count++;
+            }
+        }
+        return count;
+    }
+
+    /**
+     * Helper method
+     *
+     * @param it
+     * @param index
+     * @return
+     */
+    private Object getItemFromIterator(Iterator it, int index) {
+        int count = 0;
+        Object returnObject = null;
+        boolean found = false;
+        if (it != null) {
+            while (it.hasNext()) {
+                returnObject = it.next();
+                if (index == count++) {
+                    found = true;
+                    break;
+                }
+            }
+        }
+
+        if (found) {
+            return returnObject;
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * Helper method
+     *
+     * @param namedNode
+     * @return
+     */
+    private QName getQName(OMNamedNode namedNode) {
+        QName returnName;
+        OMNamespace ns = namedNode.getNamespace();
+        String localPart = namedNode.getLocalName();
+        if (ns != null) {
+            String prefix = ns.getPrefix();
+            String uri = ns.getName();
+            if (prefix == null || prefix.equals(""))
+                returnName = new QName(uri, localPart);
+            else
+                returnName = new QName(uri, localPart, prefix);
+        } else {
+            returnName = new QName(localPart);
+        }
+        return returnName;
+    }
+
+    /**
+     * @param elt
+     * @param index
+     * @return
+     */
+    private OMAttribute getAttribute(OMElement elt, int index) {
+        OMAttribute returnAttrib = null;
+        if (elt != null) {
+            returnAttrib = (OMAttribute) getItemFromIterator(elt.getAttributes(), index);
+        }
+        return returnAttrib;
+    }
+}



Mime
View raw message