You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ch...@apache.org on 2005/03/08 09:56:29 UTC

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

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MTOMXMLStreamWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MTOMXMLStreamWriter.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MTOMXMLStreamWriter.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MTOMXMLStreamWriter.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,436 @@
+package org.apache.axis.impl.llom.mtom;
+
+import javax.activation.DataHandler;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMultipart;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Properties;
+import java.util.Random;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * <p/>
+ */
+
+/**
+ * @author Thilina Gunarathne
+ */
+public class MTOMXMLStreamWriter implements XMLStreamWriter {
+
+    OutputStream outStream;
+
+    BufferedOutputStream soapStream;
+
+    XMLStreamWriter writer;
+
+    Random rnd;
+
+    LinkedList partList;
+
+    ByteArrayOutputStream byteStream;
+    public static String[] filter = new String[]{"Message-ID"};
+
+    public MTOMXMLStreamWriter(OutputStream out) throws XMLStreamException,
+            FactoryConfigurationError {
+        super();
+        this.outStream = out;
+
+        byteStream = new ByteArrayOutputStream();
+        //soapStream = new BufferedOutputStream(byteStream);
+        writer = XMLOutputFactory.newInstance().createXMLStreamWriter(byteStream);
+        rnd = new Random();
+        partList = new LinkedList();
+    }
+
+    public String createPart(OMBlob blob) {
+        String cid = "http://example.org/my.hsh" + (rnd.nextInt());
+        AttachmentPart part = new AttachmentPart(cid, blob);
+        partList.add(part);
+        return cid;
+    }
+
+    public MimeBodyPart createMimePart(String cid, OMBlob blob) throws Exception {
+        MimeBodyPart mb = new MimeBodyPart();
+        mb.setDataHandler(blob.getDataHandler());
+        mb.addHeader("Content-Transfer-Encoding", "binary");
+        mb.addHeader("Content-ID", "<" + cid + ">");
+        return mb;
+
+    }
+
+    public void complete() throws Exception {
+        DataHandler dh = new DataHandler(byteStream.toString(), "text/xml");
+        MimeBodyPart mb = new MimeBodyPart();
+        mb.setDataHandler(dh);
+        mb.addHeader("Content-Type", "application/xop+xml");
+        mb.addHeader("Content-Transfer-Encoding", "8bit");
+        String cid = "<http://example.org/my.hsh>";
+        mb.addHeader("Content-ID", cid);
+
+        //MimeMessage message = new MimeMessage(Session.getDefaultInstance(new java.util.Properties()));
+
+        Properties props = new Properties();
+        javax.mail.Session session = javax.mail.Session.getInstance(props, null);
+        javax.mail.internet.MimeMessage message = new javax.mail.internet.MimeMessage(session);
+        MimeMultipart mes = new MimeMultipart("Related");
+        mes.addBodyPart(mb);
+        Iterator partIterator = partList.iterator();
+        while (partIterator.hasNext()) {
+            AttachmentPart part = (AttachmentPart) partIterator.next();
+            mes.addBodyPart(createMimePart(part.getCid(), part.getBlob()));
+        }
+        mes.writeTo(System.out);
+        System.out.println("----------------------------");
+        message.setContent(mes);
+        message.removeHeader("Message-Id");
+        message.writeTo(System.out);
+        message.writeTo(outStream, filter);
+    }
+
+    public void writeStartElement(String localName) throws XMLStreamException {
+        writer.writeStartElement(localName);
+    }
+
+    public void writeStartElement(String namespaceURI, String localName)
+            throws XMLStreamException {
+        writer.writeStartElement(namespaceURI, localName);
+
+    }
+
+    public void writeStartElement(String prefix, String localName,
+                                  String namespaceURI) throws XMLStreamException {
+        writer.writeStartElement(prefix, localName, namespaceURI);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#writeEmptyElement(java.lang.String,
+     *      java.lang.String)
+     */
+    public void writeEmptyElement(String namespaceURI, String localName)
+            throws XMLStreamException {
+        writer.writeEmptyElement(namespaceURI, localName);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#writeEmptyElement(java.lang.String,
+     *      java.lang.String, java.lang.String)
+     */
+    public void writeEmptyElement(String prefix, String localName,
+                                  String namespaceURI) throws XMLStreamException {
+        writer.writeEmptyElement(prefix, localName, namespaceURI);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#writeEmptyElement(java.lang.String)
+     */
+    public void writeEmptyElement(String localName) throws XMLStreamException {
+        writer.writeEmptyElement(localName);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#writeEndElement()
+     */
+    public void writeEndElement() throws XMLStreamException {
+        writer.writeEndElement();
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#writeEndDocument()
+     */
+    public void writeEndDocument() throws XMLStreamException {
+        writer.writeEndDocument();
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#close()
+     */
+    public void close() throws XMLStreamException {
+        writer.close();
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#flush()
+     */
+    public void flush() throws XMLStreamException {
+        writer.flush();
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#writeAttribute(java.lang.String,
+     *      java.lang.String)
+     */
+    public void writeAttribute(String localName, String value)
+            throws XMLStreamException {
+        writer.writeAttribute(localName, value);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#writeAttribute(java.lang.String,
+     *      java.lang.String, java.lang.String, java.lang.String)
+     */
+    public void writeAttribute(String prefix, String namespaceURI,
+                               String localName, String value) throws XMLStreamException {
+        writer.writeAttribute(prefix, namespaceURI, localName, value);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#writeAttribute(java.lang.String,
+     *      java.lang.String, java.lang.String)
+     */
+    public void writeAttribute(String namespaceURI, String localName,
+                               String value) throws XMLStreamException {
+        writer.writeAttribute(namespaceURI, localName, value);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#writeNamespace(java.lang.String,
+     *      java.lang.String)
+     */
+    public void writeNamespace(String prefix, String namespaceURI)
+            throws XMLStreamException {
+        writer.writeNamespace(prefix, namespaceURI);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#writeDefaultNamespace(java.lang.String)
+     */
+    public void writeDefaultNamespace(String namespaceURI)
+            throws XMLStreamException {
+        writer.writeDefaultNamespace(namespaceURI);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#writeComment(java.lang.String)
+     */
+    public void writeComment(String data) throws XMLStreamException {
+        writer.writeComment(data);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#writeProcessingInstruction(java.lang.String)
+     */
+    public void writeProcessingInstruction(String target)
+            throws XMLStreamException {
+        writer.writeProcessingInstruction(target);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#writeProcessingInstruction(java.lang.String,
+     *      java.lang.String)
+     */
+    public void writeProcessingInstruction(String target, String data)
+            throws XMLStreamException {
+        writer.writeProcessingInstruction(target, data);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#writeCData(java.lang.String)
+     */
+    public void writeCData(String data) throws XMLStreamException {
+        writer.writeCData(data);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#writeDTD(java.lang.String)
+     */
+    public void writeDTD(String dtd) throws XMLStreamException {
+        writer.writeDTD(dtd);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#writeEntityRef(java.lang.String)
+     */
+    public void writeEntityRef(String name) throws XMLStreamException {
+        writer.writeEntityRef(name);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#writeStartDocument()
+     */
+    public void writeStartDocument() throws XMLStreamException {
+        writer.writeStartDocument();
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#writeStartDocument(java.lang.String)
+     */
+    public void writeStartDocument(String version) throws XMLStreamException {
+        writer.writeStartDocument(version);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#writeStartDocument(java.lang.String,
+     *      java.lang.String)
+     */
+    public void writeStartDocument(String encoding, String version)
+            throws XMLStreamException {
+        writer.writeStartDocument(encoding, version);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#writeCharacters(java.lang.String)
+     */
+    public void writeCharacters(String text) throws XMLStreamException {
+        writer.writeCharacters(text);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#writeCharacters(char[], int, int)
+     */
+    public void writeCharacters(char[] text, int start, int len)
+            throws XMLStreamException {
+        writer.writeCharacters(text, start, len);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#getPrefix(java.lang.String)
+     */
+    public String getPrefix(String uri) throws XMLStreamException {
+
+        return writer.getPrefix(uri);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#setPrefix(java.lang.String,
+     *      java.lang.String)
+     */
+    public void setPrefix(String prefix, String uri) throws XMLStreamException {
+        writer.setPrefix(prefix, uri);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#setDefaultNamespace(java.lang.String)
+     */
+    public void setDefaultNamespace(String uri) throws XMLStreamException {
+        writer.setDefaultNamespace(uri);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#setNamespaceContext(javax.xml.namespace.NamespaceContext)
+     */
+    public void setNamespaceContext(NamespaceContext context)
+            throws XMLStreamException {
+        writer.setNamespaceContext(context);
+
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#getNamespaceContext()
+     */
+    public NamespaceContext getNamespaceContext() {
+
+        return writer.getNamespaceContext();
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.xml.stream.XMLStreamWriter#getProperty(java.lang.String)
+     */
+    public Object getProperty(String name) throws IllegalArgumentException {
+
+        return writer.getProperty(name);
+    }
+}
\ No newline at end of file

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/OMBlob.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/OMBlob.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/OMBlob.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/OMBlob.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,215 @@
+package org.apache.axis.impl.llom.mtom;
+
+import org.apache.axis.impl.llom.OMNodeImpl;
+import org.apache.axis.impl.llom.exception.MTOMException;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMException;
+import org.apache.axis.om.OMNode;
+
+import javax.activation.DataHandler;
+import java.io.*;
+
+//import javax.xml.transform.stream.StreamSource;
+//import javax.xml.soap.SOAPException;
+//import javax.xml.transform.stream.StreamSource;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * <p/>
+ */
+
+/**
+ * @author Thilina Gunarathne thil747@yahoo.com
+ */
+
+public class OMBlob extends OMNodeImpl {
+
+    String cid = null;
+
+    Object binaryObject = null;
+
+    MTOMBuilder mimeParser;
+
+    DataHandler DH = null;
+
+    boolean MTOMable = true;
+
+    public OMBlob(Object object, boolean MTOMable) {
+        this.MTOMable = MTOMable;
+        this.binaryObject = object;
+    }
+
+    public OMBlob(String cid, OMElement parent, MTOMBuilder mimeParser) {
+        super(parent);
+        this.cid = cid;
+        this.mimeParser = mimeParser;
+    }
+
+    public void setMTOMable(boolean MTOMable) {
+        this.MTOMable = MTOMable;
+    }
+
+    public boolean isMTOMable() {
+        return MTOMable;
+    }
+
+    public/*Serializable*/Object getObject() throws Exception {
+        if ((binaryObject == null) & (cid != null)) {
+            if (DH == null) {
+                getDataHandler();
+            }
+            //
+            /*
+
+
+            javax.activation.DataSource ds = datahandler.getDataSource();
+            InputStream is = null;
+            try {
+                is = ds.getInputStream();;
+            } catch (java.io.IOException io) {
+                log.error(Messages.getMessage("javaIOException00"), io);
+                throw new SOAPException(io);
+            }
+            if (ds.getContentType().equals("text/plain")) {
+                try {
+                    byte[] bytes = new byte[is.available()];
+                    IOUtils.readFully(is, bytes);
+                    return new String(bytes);
+                } catch (java.io.IOException io) {
+                    log.error(Messages.getMessage("javaIOException00"), io);
+                    throw new SOAPException(io);
+                }
+            } else if (ds.getContentType().equals("text/xml")) {
+                return new StreamSource(is);
+            } else if (ds.getContentType().equals("image/gif") ||
+                       ds.getContentType().equals("image/jpeg")) {
+                try {
+                    return ImageIOFactory.getImageIO().loadImage(is);
+                } catch (Exception ex) {
+                    log.error(Messages.getMessage("javaIOException00"), ex);
+                    throw new SOAPException(ex);
+                }
+            }
+            return is;
+            //
+            */
+            Object in = DH.getContent();
+            if (in instanceof InputStream) {
+                ObjectInputStream ois = new ObjectInputStream((InputStream) in);
+                binaryObject = ois.readObject();
+            } else
+                binaryObject = in;
+            return binaryObject;
+        } else if ((binaryObject == null) & (cid == null)) {
+            throw new MTOMException("OMBlob not initialised Properly");
+        }
+        return binaryObject;
+    }
+
+    public java.io.OutputStream getStream() throws Exception {
+        ObjectOutputStream outStream;
+        ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
+        if ((binaryObject == null) & (cid != null)) {
+            binaryObject = getObject();
+        } else if ((binaryObject == null) & (cid == null)) {
+            throw new MTOMException("OMBlob not initialised Properly");
+        }
+        try {
+
+            outStream = new ObjectOutputStream(byteStream);
+            outStream.writeObject(binaryObject);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return byteStream;
+    }
+
+    public String getValue() throws OMException {
+        throw new OMException("Blob returns objects only");
+    }
+
+    public DataHandler getDataHandler() throws Exception {
+        if ((DH == null) & (binaryObject == null)) {
+            DH = mimeParser.getDataHandler(cid);
+        } else if (DH == null) {
+            ByteArrayOutputStream out = (ByteArrayOutputStream) getStream();
+            ByteArrayDataSource bads = new ByteArrayDataSource(out
+                    .toByteArray(), null);
+            DH = new DataHandler(bads);
+        }
+/*
+  ManagedMemoryDataSource source = null;
+        setMimeHeader(HTTPConstants.HEADER_CONTENT_TYPE, contentType);
+        if (object instanceof String) {
+            try {
+                String s = (String) object;
+                java.io.ByteArrayInputStream bais =
+                        new java.io.ByteArrayInputStream(s.getBytes());
+                source = new ManagedMemoryDataSource(bais,
+                        ManagedMemoryDataSource.MAX_MEMORY_DISK_CACHED,
+                        contentType, true);
+                extractFilename(source);
+                datahandler = new DataHandler(source);
+                contentObject = object;
+                return;
+            } catch (java.io.IOException io) {
+                log.error(Messages.getMessage("javaIOException00"), io);
+                throw new java.lang.IllegalArgumentException(
+                        Messages.getMessage("illegalArgumentException00"));
+            }
+        } else if (object instanceof java.io.InputStream) {
+            try {
+                source = new ManagedMemoryDataSource((java.io.InputStream) object,
+                        ManagedMemoryDataSource.MAX_MEMORY_DISK_CACHED,
+                        contentType, true);
+                extractFilename(source);
+                datahandler = new DataHandler(source);
+                contentObject = null; // the stream has been consumed
+                return;
+            } catch (java.io.IOException io) {
+                log.error(Messages.getMessage("javaIOException00"), io);
+                throw new java.lang.IllegalArgumentException(Messages.getMessage
+                        ("illegalArgumentException00"));
+            }
+        } else if (object instanceof StreamSource) {
+            try {
+                source = new ManagedMemoryDataSource(((StreamSource)object).getInputStream(),
+                        ManagedMemoryDataSource.MAX_MEMORY_DISK_CACHED,
+                        contentType, true);
+                extractFilename(source);
+                datahandler = new DataHandler(source);
+                contentObject = null; // the stream has been consumed
+                return;
+            } catch (java.io.IOException io) {
+                log.error(Messages.getMessage("javaIOException00"), io);
+                throw new java.lang.IllegalArgumentException(Messages.getMessage
+                        ("illegalArgumentException00"));
+            }
+        } else {
+            throw new java.lang.IllegalArgumentException(
+                    Messages.getMessage("illegalArgumentException00"));
+        }
+ */
+        return DH;
+    }
+
+    public short getType() throws OMException {
+        return OMNode.BLOB_NODE;
+    }
+
+    public boolean isComplete() {
+        return done;
+    }
+}
\ No newline at end of file

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/serialize/SimpleOMSerializer.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/serialize/SimpleOMSerializer.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/serialize/SimpleOMSerializer.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/serialize/SimpleOMSerializer.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,228 @@
+package org.apache.axis.impl.llom.serialize;
+
+import org.apache.axis.encoding.Base64;
+import org.apache.axis.impl.llom.OMAttributeImpl;
+import org.apache.axis.impl.llom.OMNamespaceImpl;
+import org.apache.axis.impl.llom.mtom.MTOMXMLStreamWriter;
+import org.apache.axis.impl.llom.mtom.OMBlob;
+import org.apache.axis.om.*;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.io.ByteArrayOutputStream;
+import java.util.Iterator;
+import java.util.Vector;
+
+/**
+ * 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.
+ */
+public class SimpleOMSerializer {
+
+    private Vector prefixList = new Vector();
+
+    public void serialize(Object omNode, XMLStreamWriter writer)
+            throws XMLStreamException {
+
+        if (!(omNode instanceof OMNode)) {
+            throw new UnsupportedOperationException("Unsupported input object. Must be of the the type OMNode");
+        }
+
+        OMNode node = (OMNode) omNode;
+        serializeNode(node, writer);
+    }
+
+    protected void serializeNode(OMNode node, XMLStreamWriter writer)
+            throws XMLStreamException {
+        short nodeType = node.getType();
+        if (nodeType == OMNode.ELEMENT_NODE) {
+            serializeElement((OMElement) node, writer);
+        } else if (nodeType == OMNode.ATTRIBUTE_NODE) {
+            serializeAttribute((OMAttribute) node, writer);
+        } else if (nodeType == OMNode.TEXT_NODE) {
+            serializeText((OMText) node, writer);
+        } else if (nodeType == OMNode.COMMENT_NODE) {
+            serializeComment((OMText) node, writer);
+        } else if (nodeType == OMNode.CDATA_SECTION_NODE) {
+            serializeCData((OMText) node, writer);
+            // added by Thilina
+        } else if (nodeType == OMNode.BLOB_NODE) {
+            serializeBlob((OMBlob) node, writer);
+        }
+        writer.flush();
+    }
+
+    /**
+     * @param element
+     */
+    protected void serializeElement(OMElement element, XMLStreamWriter writer)
+            throws XMLStreamException {
+
+        OMNamespace ns = element.getNamespace();
+        String prefix = null;
+        String nameSpaceName = null;
+        if (ns != null) {
+            prefix = ns.getPrefix();
+            nameSpaceName = ns.getName();
+            if (prefix != null) {
+                writer.writeStartElement(prefix, element.getLocalName(),
+                        nameSpaceName);
+                if (!prefixList.contains(prefix)) {
+                    writer.writeNamespace(prefix, nameSpaceName);
+                    prefixList.add(prefix);
+                }
+            } else {
+                writer.writeStartElement(nameSpaceName, element.getLocalName());
+                //add the own namespace
+                writer.writeDefaultNamespace(nameSpaceName);
+
+            }
+        }
+
+        //add the elements attributes
+        Iterator attributes = element.getAttributes();
+        while (attributes.hasNext()) {
+            serializeAttribute((OMAttribute) attributes.next(), writer);
+        }
+
+        //add the namespaces
+        Iterator namespaces = element.getAllDeclaredNamespaces();
+        if (namespaces != null) {
+            while (namespaces.hasNext()) {
+                serializeNamespace((OMNamespace) namespaces.next(), writer);
+            }
+        }
+
+        //add the children
+        Iterator children = element.getChildren();
+
+        while (children.hasNext()) {
+            Object node = children.next();
+            if (node != null) {
+                serializeNode((OMNode) node, writer);
+            }
+        }
+
+        writer.writeEndElement();
+
+    }
+
+    /*
+     * Edited by Thilina Gunarathne
+     */
+    protected void serializeBlob(OMBlob blob, XMLStreamWriter xmlWriter)
+            throws XMLStreamException {
+
+        if (xmlWriter instanceof MTOMXMLStreamWriter & blob.isMTOMable()) {
+            MTOMXMLStreamWriter writer = (MTOMXMLStreamWriter) xmlWriter;
+            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) {
+                    writer.writeStartElement(prefix, "Include", nameSpaceName);
+                    //if (!prefixList.contains(prefix)) {
+                    writer.writeNamespace(prefix, nameSpaceName);
+                    //	prefixList.add(prefix);
+                    //}
+                }
+            }
+
+            //get the Cid from the MTOMwriter
+            String cid;
+            try {
+                cid = writer.createPart(blob);
+                OMAttribute href = new OMAttributeImpl("href",
+                        new OMNamespaceImpl("", ""), "cid:" + cid.trim());
+                serializeAttribute(href, writer);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            writer.writeEndElement();
+        } else {
+            ByteArrayOutputStream byteStream;
+            try {
+                byteStream = (ByteArrayOutputStream) blob.getStream();
+                xmlWriter.writeCharacters(Base64.encode(byteStream
+                        .toByteArray()));
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+
+        }
+
+    }
+
+    /*
+     * Edit over
+     */
+
+    protected void serializeText(OMText text, XMLStreamWriter writer)
+            throws XMLStreamException {
+        writer.writeCharacters(text.getValue());
+    }
+
+    protected void serializeCData(OMText text, XMLStreamWriter writer)
+            throws XMLStreamException {
+        writer.writeCData(text.getValue());
+    }
+
+    protected void serializeComment(OMText text, XMLStreamWriter writer)
+            throws XMLStreamException {
+        writer.writeComment(text.getValue());
+    }
+
+    /**
+     * @param attr
+     * @param writer
+     * @throws XMLStreamException
+     */
+
+    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());
+        }
+
+    }
+
+    protected void serializeNamespace(OMNamespace namespace,
+                                      XMLStreamWriter writer) throws XMLStreamException {
+        if (namespace != null) {
+            String prefix = namespace.getPrefix();
+            if (!prefixList.contains(prefix))
+                writer.writeNamespace(prefix, namespace.getName());
+
+        }
+    }
+
+}
\ No newline at end of file

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/serialize/StreamingOMSerializer.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/serialize/StreamingOMSerializer.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/serialize/StreamingOMSerializer.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/serialize/StreamingOMSerializer.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,149 @@
+package org.apache.axis.impl.llom.serialize;
+
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import java.util.Vector;
+
+
+/**
+ * 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.
+ */
+public class StreamingOMSerializer implements XMLStreamConstants {
+
+    private Vector prefixList = new Vector();
+
+    public void serialize(Object obj, XMLStreamWriter writer) throws XMLStreamException {
+
+        if (!(obj instanceof XMLStreamReader)) {
+            throw new UnsupportedOperationException("Unsupported input object. Must be of the the type XMLStreamReader");
+        }
+
+        XMLStreamReader node = (XMLStreamReader) obj;
+        serializeNode(node, writer);
+    }
+
+    protected void serializeNode(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+        while (reader.hasNext()) {
+            int event = reader.next();
+            if (event == START_ELEMENT) {
+                serializeElement(reader, writer);
+            } else if (event == ATTRIBUTE) {
+                serializeAttributes(reader, writer);
+            } else if (event == CHARACTERS) {
+                serializeText(reader, writer);
+            } else if (event == COMMENT) {
+                serializeComment(reader, writer);
+            } else if (event == CDATA) {
+                serializeCData(reader, writer);
+            } else if (event == END_ELEMENT) {
+                serializeEndElement(writer);
+            }
+            writer.flush();
+        }
+    }
+
+    /**
+
+     */
+    protected void serializeElement(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+
+        String prefix = reader.getPrefix();
+        String nameSpaceName = reader.getNamespaceURI();
+        if (prefix != null) {
+            writer.writeStartElement(prefix, reader.getLocalName(), nameSpaceName);
+            //add the own namespace
+            if (!prefixList.contains(prefix)) {
+                writer.writeNamespace(prefix, nameSpaceName);
+                prefixList.add(prefix);
+            }
+        } else {
+            writer.writeStartElement(nameSpaceName, reader.getLocalName());
+            //add the own namespace
+            writer.writeDefaultNamespace(nameSpaceName);
+
+        }
+
+
+
+        //add attributes
+        serializeAttributes(reader, writer);
+        //add the namespaces
+        serializeNamespaces(reader, writer);
+
+
+    }
+
+    protected void serializeEndElement(XMLStreamWriter writer) throws XMLStreamException {
+        writer.writeEndElement();
+    }
+
+    /**
+     */
+    protected void serializeText(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+        writer.writeCharacters(reader.getText());
+    }
+
+    protected void serializeCData(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+        writer.writeCData(reader.getText());
+    }
+
+
+    protected void serializeComment(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+        writer.writeComment(reader.getText());
+    }
+
+    /**
+     * @param writer
+     * @throws XMLStreamException
+     */
+
+
+    protected void serializeAttributes(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+
+        int count = reader.getAttributeCount();
+        String prefix = null;
+        String namespaceName = null;
+        for (int i = 0; i < count; i++) {
+            prefix = reader.getAttributePrefix(i);
+            namespaceName = reader.getAttributeNamespace(i);
+            if (prefix != null && !namespaceName.equals("")) {
+                writer.writeAttribute(prefix,
+                        namespaceName,
+                        reader.getAttributeLocalName(i),
+                        reader.getAttributeValue(i));
+            } else {
+                writer.writeAttribute(reader.getAttributeLocalName(i),
+                        reader.getAttributeValue(i));
+            }
+        }
+    }
+
+
+    protected void serializeNamespaces(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+        int count = reader.getNamespaceCount();
+        String namespacePrefix;
+        for (int i = 0; i < count; i++) {
+            namespacePrefix = reader.getNamespacePrefix(i);
+            if (!prefixList.contains(namespacePrefix)) {
+                writer.writeNamespace(namespacePrefix, reader.getNamespaceURI(i));
+                prefixList.add(namespacePrefix);
+            }
+        }
+
+    }
+
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/serialize/XMLSerilazer.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/serialize/XMLSerilazer.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/serialize/XMLSerilazer.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/serialize/XMLSerilazer.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,145 @@
+package org.apache.axis.impl.llom.serialize;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.StreamingWrapper;
+
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation Date: Nov 18, 2004 Time:
+ * 11:29:48 AM
+ */
+public class XMLSerilazer {
+    private static StringBuffer b;
+    private StreamingWrapper streamingWrapper;
+    private OMElement startingElement;
+
+    public XMLSerilazer(StreamingWrapper streamingWrapper) {
+        this.streamingWrapper = streamingWrapper;
+
+    }
+
+    public StringBuffer serialize(OMElement element) {
+
+        return b;
+    }
+
+
+    public static String printEvent(StreamingWrapper streamingWrapper) {
+
+        switch (streamingWrapper.getEventType()) {
+            case XMLStreamReader.START_ELEMENT:
+                b.append("<");
+                printName(streamingWrapper, b);
+                for (int i = 0; i < streamingWrapper.getNamespaceCount(); i++) {
+                    b.append(" ");
+                    String n = streamingWrapper.getNamespacePrefix(i);
+                    if ("xmlns".equals(n)) {
+                        b.append("xmlns=\"" + streamingWrapper.getNamespaceURI(i) + "\"");
+                    } else {
+                        b.append("xmlns:" + n);
+                        b.append("=\"");
+                        b.append(streamingWrapper.getNamespaceURI(i));
+                        b.append("\"");
+                    }
+                }
+
+                for (int i = 0; i < streamingWrapper.getAttributeCount(); i++) {
+                    b.append(" ");
+                    printName(streamingWrapper.getAttributePrefix(i),
+                            streamingWrapper.getAttributeNamespace(i),
+                            streamingWrapper.getAttributeLocalName(i),
+                            b);
+                    b.append("=\"");
+                    b.append(streamingWrapper.getAttributeValue(i));
+                    b.append("\"");
+                }
+
+                b.append(">");
+                break;
+            case XMLStreamReader.END_ELEMENT:
+                b.append("</");
+                printName(streamingWrapper, b);
+                for (int i = 0; i < streamingWrapper.getNamespaceCount(); i++) {
+                    b.append(" ");
+                    String n = streamingWrapper.getNamespacePrefix(i);
+                    if ("xmlns".equals(n)) {
+                        b.append("xmlns=\"" + streamingWrapper.getNamespaceURI(i) + "\"");
+                    } else {
+                        b.append("xmlns:" + n);
+                        b.append("=\"");
+                        b.append(streamingWrapper.getNamespaceURI(i));
+                        b.append("\"");
+                    }
+                }
+                b.append(">");
+                break;
+            case XMLStreamReader.SPACE:
+            case XMLStreamReader.CHARACTERS:
+                int start = streamingWrapper.getTextStart();
+                int length = streamingWrapper.getTextLength();
+                b.append(new String(streamingWrapper.getTextCharacters(),
+                        start,
+                        length));
+                break;
+            case XMLStreamReader.CDATA:
+                b.append("<![CDATA[");
+                if (streamingWrapper.hasText())
+                    b.append(streamingWrapper.getText());
+                b.append("]]>");
+                break;
+
+            case XMLStreamReader.COMMENT:
+                b.append("<!--");
+                if (streamingWrapper.hasText())
+                    b.append(streamingWrapper.getText());
+                b.append("-->");
+                break;
+            case XMLStreamReader.START_DOCUMENT:
+//                b.append("<?xml");
+//                b.append(" version='" + streamingWrapper.getVersion() + "'");
+//                b.append(" encoding='" + streamingWrapper.getCharacterEncodingScheme() + "'");
+//                if (streamingWrapper.isStandalone())
+//                    b.append(" standalone='yes'");
+//                else
+//                    b.append(" standalone='no'");
+//                b.append("?>");
+                break;
+
+        }
+        return b.toString();
+    }
+
+    private static void printName(String prefix,
+                                  String uri,
+                                  String localName,
+                                  StringBuffer b) {
+        if (uri != null && !("".equals(uri))) b.append("['" + uri + "']:");
+        if (prefix != null && !("".equals(prefix))) b.append(prefix + ":");
+        if (localName != null) b.append(localName);
+    }
+
+    private static void printName(StreamingWrapper streamingWrapper, StringBuffer b) {
+        if (streamingWrapper.hasName()) {
+            String prefix = streamingWrapper.getPrefix();
+            String uri = streamingWrapper.getNamespaceURI();
+            String localName = streamingWrapper.getLocalName();
+            printName(prefix, uri, localName, b);
+        }
+    }
+
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/traverse/OMChildrenIterator.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/traverse/OMChildrenIterator.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/traverse/OMChildrenIterator.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/traverse/OMChildrenIterator.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,98 @@
+package org.apache.axis.impl.llom.traverse;
+
+import org.apache.axis.om.OMException;
+import org.apache.axis.om.OMNode;
+
+import java.util.Iterator;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * <p/>
+ */
+public class OMChildrenIterator implements Iterator {
+
+    protected OMNode currentChild;
+    protected OMNode lastChild;
+    protected boolean nextCalled = false;
+    protected boolean removeCalled = false;
+
+
+    public OMChildrenIterator(OMNode currentChild) {
+        this.currentChild = currentChild;
+    }
+
+    /**
+     * Removes from the underlying collection the last element returned by the
+     * iterator (optional operation).  This method can be called only once per
+     * call to <tt>next</tt>.  The behavior of an iterator is unspecified if the
+     * underlying collection is modified while the iteration is in progress in
+     * any way other than by calling this method.
+     *
+     * @throws UnsupportedOperationException if the <tt>remove</tt> operation is
+     *                                       not supported by this Iterator.
+     * @throws IllegalStateException         if the <tt>next</tt> method has not
+     *                                       yet been called, or the <tt>remove</tt>
+     *                                       method has already been called
+     *                                       after the last call to the
+     *                                       <tt>next</tt> method.
+     */
+    public void remove() {
+
+        if (!nextCalled) {
+            throw new IllegalStateException("next method has not yet being called");
+        }
+        if (removeCalled) {
+            throw new IllegalStateException("remove has already being called");
+        }
+
+        removeCalled = true;
+
+        //since this acts on the last child there is no need to mess with the current child
+        if (lastChild == null) {
+            throw new OMException("cannot remove a child at this stage!");
+        }
+        lastChild.detach();
+    }
+
+    /**
+     * Returns <tt>true</tt> if the iteration has more elements. (In other
+     * words, returns <tt>true</tt> if <tt>next</tt> would return an element
+     * rather than throwing an exception.)
+     *
+     * @return <tt>true</tt> if the iterator has more elements.
+     */
+    public boolean hasNext() {
+        return (currentChild != null);
+    }
+
+    /**
+     * Returns the next element in the iteration.
+     *
+     * @return the next element in the iteration.
+     * @throws java.util.NoSuchElementException
+     *          iteration has no more elements.
+     */
+    public Object next() {
+        nextCalled = true;
+        removeCalled = false;
+        if (hasNext()) {
+            lastChild = currentChild;
+            currentChild = currentChild.getNextSibling();
+            return lastChild;
+        }
+        return null;
+
+    }
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/traverse/OMChildrenQNameIterator.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/traverse/OMChildrenQNameIterator.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/traverse/OMChildrenQNameIterator.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/traverse/OMChildrenQNameIterator.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,115 @@
+package org.apache.axis.impl.llom.traverse;
+
+import org.apache.axis.impl.llom.OMNamedNodeImpl;
+import org.apache.axis.om.OMNode;
+
+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 OMChildrenQNameIterator extends OMChildrenIterator {
+
+
+    private QName givenQName;
+
+    private boolean needToMoveForward = true;
+    private boolean isMatchingNodeFound = false;
+
+    public OMChildrenQNameIterator(OMNode currentChild, QName givenQName) {
+        super(currentChild);
+        this.givenQName = givenQName;
+    }
+
+
+    /**
+     * Returns <tt>true</tt> if the iteration has more elements. (In other
+     * words, returns <tt>true</tt> if <tt>next</tt> would return an element
+     * rather than throwing an exception.)
+     *
+     * @return <tt>true</tt> if the iterator has more elements.
+     */
+    public boolean hasNext() {
+        while (needToMoveForward) {
+            if (currentChild != null) {
+                // check the current node for the criteria
+                if ((currentChild instanceof OMNamedNodeImpl) &&
+                        (isQNamesMatch(((OMNamedNodeImpl) currentChild).getQName(), this.givenQName))) {
+                    isMatchingNodeFound = true;
+                    needToMoveForward = false;
+                } else {
+                    // get the next named node
+                    currentChild = currentChild.getNextSibling();
+                    isMatchingNodeFound = needToMoveForward = !(currentChild == null);
+                }
+            } else {
+                needToMoveForward = false;
+            }
+        }
+        return isMatchingNodeFound;
+    }
+
+    /**
+     * Returns the next element in the iteration.
+     *
+     * @return the next element in the iteration.
+     * @throws java.util.NoSuchElementException
+     *          iteration has no more elements.
+     */
+    public Object next() {
+        //reset the flags
+        needToMoveForward = true;
+        isMatchingNodeFound = false;
+        nextCalled = true;
+        removeCalled = false;
+
+        lastChild = currentChild;
+        currentChild = currentChild.getNextSibling();
+        return lastChild;
+    }
+
+    /**
+     * Here I can not use the overriden equals method of QName, as one might
+     * want to get some element just by giving the localname, even though a
+     * matching element has a namespace uri as well. This will not be supported
+     * in the equals method of the QName
+     *
+     * @param elementQName
+     * @param qNameToBeMatched
+     * @return
+     */
+    private boolean isQNamesMatch(QName elementQName, QName qNameToBeMatched) {
+
+        // if no QName was given, that means one needs all
+        if (qNameToBeMatched == null) {
+            return true;
+        }
+
+        // if the given localname is null, whatever value this.qname has, its a match
+        boolean localNameMatch = qNameToBeMatched.getLocalPart() == null ||
+                qNameToBeMatched.getLocalPart() == "" ||
+                (elementQName != null && elementQName.getLocalPart().equalsIgnoreCase(qNameToBeMatched.getLocalPart()));
+        boolean namespaceURIMatch = qNameToBeMatched.getNamespaceURI() == null ||
+                qNameToBeMatched.getNamespaceURI() == "" ||
+                (elementQName != null && elementQName.getNamespaceURI().equalsIgnoreCase(qNameToBeMatched.getNamespaceURI()));
+
+        return localNameMatch && namespaceURIMatch;
+
+
+    }
+
+
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/FactoryFinder.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/FactoryFinder.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/FactoryFinder.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/FactoryFinder.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,50 @@
+package org.apache.axis.om;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * <p/>
+ * This is the static factory finder. It searches for the relevant class Note -
+ * It has only package access!!!
+ */
+class FactoryFinder {
+
+    private static final String defaultClassName = "org.apache.axis.impl.llom.factory.OMLinkedListImplFactory";
+
+    /**
+     * This needs to be improved. Currently the factory is loaded only from the
+     * default implementation However provisions should be made to load a custom
+     * factory depending on the users setting Say an environment variable
+     *
+     * @param loader
+     * @return
+     */
+    public static OMFactory findFactory(ClassLoader loader) throws OMFactoryException {
+        Object factory = null;
+
+        try {
+            if (loader == null) {
+                factory = Class.forName(defaultClassName).newInstance();
+            } else {
+                factory = loader.loadClass(defaultClassName).newInstance();
+            }
+
+        } catch (Exception e) {
+            throw new OMFactoryException(e);
+        }
+
+        return (OMFactory) factory;
+
+    }
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMAttribute.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMAttribute.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMAttribute.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMAttribute.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,41 @@
+package org.apache.axis.om;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * <p/>
+ * One must implement relevant constructors for the class implementing this
+ * interface all the things like namespace, parent, value, etc., that should
+ * come in this are defined in base classes
+ */
+public interface OMAttribute {
+
+    public String getLocalName();
+
+    public void setLocalName(String localName);
+
+    public String getValue();
+
+    public void setValue(String value);
+
+    public void setOMNamespace(OMNamespace omNamespace);
+
+    public OMNamespace getNamespace();
+
+    public QName getQName();
+
+
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMBody.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMBody.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMBody.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMBody.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,63 @@
+/*   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.
+ */
+
+package org.apache.axis.om;
+
+
+/**
+ * An object that represents the contents of the SOAP body element in a SOAP
+ * message. B SOAP body element consists of XML data that affects the way the
+ * application-specific content is processed. <P> B <code>OMBody</code> object
+ * contains <code>OMBodyBlock</code> objects, which have the content for the
+ * SOAP body. B <code>OMFault</code> object, which carries status and/or error
+ * information, is an example of a <code>OMBodyBlock</code> object.
+ */
+public interface OMBody extends OMElement {
+
+    /**
+     * Creates a new <code>OMFault</code> object and adds it to this
+     * <code>OMBody</code> object.
+     *
+     * @return the new <code>OMFault</code> object
+     * @throws org.apache.axis.om.OMException if there is a SOAP error
+     */
+    public abstract OMFault addFault() throws OMException;
+
+    /**
+     * Indicates whether a <code>OMFault</code> object exists in this
+     * <code>OMBody</code> object.
+     *
+     * @return <code>true</code> if a <code>OMFault</code> object exists in this
+     *         <code>OMBody</code> object; <code>false</code> otherwise
+     */
+    public abstract boolean hasFault();
+
+    /**
+     * Returns the <code>OMFault</code> object in this <code>OMBody</code>
+     * object.
+     *
+     * @return the <code>OMFault</code> object in this <code>OMBody</code>
+     *         object
+     */
+    public abstract OMFault getFault();
+
+    /**
+     * @param soapFault
+     * @throws OMException
+     */
+    public abstract void addFault(OMFault soapFault) throws OMException;
+
+
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMConstants.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMConstants.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMConstants.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,42 @@
+package org.apache.axis.om;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * <p/>
+ */
+public interface OMConstants {
+
+    public static final String SOAP_ENVELOPE_NAMESPACE_URI = "http://schemas.xmlsoap.org/soap/envelope/";
+    public static final String SOAPENVELOPE_NAMESPACE_PREFIX = "soapenv";
+    public static final String SOAPENVELOPE_LOCAL_NAME = "Envelope";
+
+    // Header constants
+    public static final String HEADER_NAMESPACEURI = SOAP_ENVELOPE_NAMESPACE_URI;
+    public static final String HEADER_LOCAL_NAME = "Header";
+    public static final String HEADER_NAMESPACE_PREFIX = SOAPENVELOPE_NAMESPACE_PREFIX;
+
+    // Body Constants
+    public static final String BODY_NAMESPACE_URI = SOAP_ENVELOPE_NAMESPACE_URI;
+    public static final String BODY_LOCAL_NAME = "Body";
+    public static final String BODY_NAMESPACE_PREFIX = SOAPENVELOPE_NAMESPACE_PREFIX;
+
+    // Attribute names of a SOAP Envelope
+    public static final String ATTR_ACTOR = "actor";
+    public static final String ATTR_MUSTUNDERSTAND = "mustUnderstand";
+
+    public static final String SOAPFAULT_LOCAL_NAME = "Fault";
+    public static final String SOAPFAULT_NAMESPACE_URI = SOAP_ENVELOPE_NAMESPACE_URI;
+    public static final String SOAPFAULT_NAMESPACE_PREFIX = SOAPENVELOPE_NAMESPACE_PREFIX;
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMElement.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMElement.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMElement.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMElement.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,153 @@
+package org.apache.axis.om;
+
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import java.util.Iterator;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * <p/>
+ * One must make sure to insert relevant constructors for the classes that are
+ * implementing this interface
+ */
+public interface OMElement extends OMNamedNode {
+
+    /**
+     * This will add child to the element. One must preserve the order of
+     * children, in this operation Tip : appending the new child is prefered
+     *
+     * @param omNode
+     */
+    public void addChild(OMNode omNode);
+
+    /**
+     * 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 OMException
+     */
+    public Iterator getChildrenWithName(QName elementQName) throws OMException;
+
+    /**
+     * This returns a collection of this element. Children can be of types
+     * OMElement, OMText.
+     */
+    public Iterator getChildren();
+
+    /**
+     * THis will create a namespace in the current element scope
+     *
+     * @param uri
+     * @param prefix
+     * @return
+     */
+    public OMNamespace declareNamespace(String uri, String prefix);
+
+    /**
+     * @param namespace
+     * @return
+     */
+    public OMNamespace declareNamespace(OMNamespace 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 OMException
+     */
+    public OMNamespace findInScopeNamespace(String uri, String prefix) throws OMException;
+
+    /**
+     * 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;
+
+    /**
+     * This will provide a list of namespace defined within this Element
+     * <B>only</B>
+     *
+     * @return
+     * @throws OMException
+     */
+    public Iterator getAllDeclaredNamespaces();
+
+    /**
+     * This will help to search for an attribute with a given QName within this
+     * Element
+     *
+     * @param qname
+     * @return
+     * @throws OMException
+     */
+    public OMAttribute getAttributeWithQName(QName qname) throws OMException;
+
+    /**
+     * This will return a List of OMAttributes
+     *
+     * @return
+     */
+    public Iterator getAttributes();
+
+    /**
+     * 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);
+
+    public void removeAttribute(OMAttribute attr);
+
+    public void setBuilder(OMXMLParserWrapper wrapper);
+
+    public OMXMLParserWrapper getBuilder();
+
+    /**
+     * Set the first child
+     *
+     * @param node
+     */
+    public void setFirstChild(OMNode node);
+
+    /**
+     * Get the first child
+     *
+     * @return
+     */
+    public OMNode getFirstChild();
+
+    /**
+     * Returns the pull parser that will generate the pull events relevant to
+     * THIS element
+     *
+     * @param cacheOff
+     * @return
+     */
+
+    public XMLStreamReader getPullParser(boolean cacheOff);
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMEnvelope.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMEnvelope.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMEnvelope.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMEnvelope.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,76 @@
+/*   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.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation
+ * Date: Oct 28, 2004
+ * Time: 11:52:18 AM
+ * <p/>
+ *
+ */
+
+
+package org.apache.axis.om;
+
+
+public interface OMEnvelope extends OMElement {
+
+    /**
+     * Creates a new <CODE>Name</CODE> object initialized with the given local
+     * name, namespace prefix, and namespace URI.
+     * <p/>
+     * <P>This factory method creates <CODE>Name</CODE> objects for use in the
+     * SOAP/XML envelope.
+     *
+     * @param localName a <CODE>String</CODE> giving the local name
+     * @param prefix    a <CODE>String</CODE> giving the prefix of the
+     *                  namespace
+     * @param uri       a <CODE>String</CODE> giving the URI of the namespace
+     * @return a <CODE>OMNamespace</CODE> object initialized with the given
+     *         local name, namespace prefix, and namespace URI
+     * @throws OMException if there is a SOAP error
+     */
+    public abstract OMNamespace createNamespace(String localName, String prefix, String uri)
+            throws OMException;
+
+
+    /**
+     * Returns the <CODE>OMHeader</CODE> object for this <CODE>
+     * OMEnvelope</CODE> object.
+     * <p/>
+     * <P> This OMHeader will just be a container for all the headers in the
+     * <CODE>OMMessage</CODE> </P>
+     *
+     * @return the <CODE>OMHeader</CODE> object or <CODE> null</CODE> if there
+     *         is none
+     * @throws OMException if there is a problem obtaining the <CODE>OMHeader</CODE>
+     *                     object
+     */
+    public abstract OMHeader getHeader() throws OMException;
+
+    /**
+     * Returns the <CODE>OMBody</CODE> object associated with this
+     * <CODE>OMEnvelope</CODE> object.
+     * <p/>
+     * <P> This OMBody will just be a container for all the BodyElements in the
+     * <CODE>OMMessage</CODE> </P>
+     *
+     * @return the <CODE>OMBody</CODE> object for this <CODE> OMEnvelope</CODE>
+     *         object or <CODE>null</CODE> if there is none
+     * @throws OMException if there is a problem obtaining the <CODE>OMBody</CODE>
+     *                     object
+     */
+    public abstract OMBody getBody() throws OMException;
+
+
+}

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

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMFactory.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMFactory.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMFactory.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,174 @@
+package org.apache.axis.om;
+
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * <p/>
+ * This will help to create OM API object. This will ease the switching from one
+ * OM impl to another.
+ */
+public abstract class OMFactory {
+
+    /**
+     * @param localName
+     * @param ns
+     * @param value
+     * @return
+     */
+    public abstract OMAttribute createOMAttribute(String localName, OMNamespace ns, String value);
+
+    /**
+     * @param parent
+     * @return
+     */
+    public abstract OMElement createOMElement(OMElement parent);
+
+    /**
+     * @param localName
+     * @param ns
+     * @return
+     */
+    public abstract OMElement createOMElement(String localName, OMNamespace ns);
+
+    /**
+     * @param localName
+     * @param ns
+     * @param parent
+     * @param builder
+     * @return
+     */
+    public abstract OMElement createOMElement(String localName, OMNamespace ns, OMElement parent, OMXMLParserWrapper builder);
+
+
+    /**
+     * @param localName
+     * @param ns
+     * @param parent
+     * @return
+     */
+    public abstract OMNamedNode createOMNamedNode(String localName, OMNamespace ns, OMElement parent);
+
+    /**
+     * @param parent
+     * @return
+     */
+    public abstract OMNamedNode createOMNamedNode(OMElement parent);
+
+    public abstract OMNamespace createOMNamespace(String uri, String prefix);
+
+
+    public abstract OMNode createOMNode(OMElement parent);
+
+    /**
+     * @param parent
+     * @param text
+     * @return
+     */
+    public abstract OMText createText(OMElement parent, String text);
+
+    /**
+     * @param s
+     * @return
+     */
+    public abstract OMText createText(String s);
+
+    /**
+     * @param envelope
+     * @return
+     */
+    public abstract SOAPBody createSOAPBody(SOAPEnvelope envelope);
+
+    /**
+     * @param localName
+     * @param ns
+     * @param parent
+     * @param builder
+     * @return
+     */
+    public abstract SOAPBody createSOAPBody(String localName, OMNamespace ns, OMElement parent, OMXMLParserWrapper builder);
+
+
+    /**
+     * @param localName
+     * @param ns
+     * @param parent
+     * @param builder
+     * @return
+     */
+    public abstract SOAPEnvelope createSOAPEnvelope(String localName, OMNamespace ns, OMElement parent, OMXMLParserWrapper builder);
+
+    /**
+     * @param localName
+     * @param ns
+     */
+    public abstract SOAPEnvelope createSOAPEnvelope(String localName, OMNamespace ns);
+
+    /**
+     * @param envelope
+     */
+    public abstract SOAPHeader createSOAPHeader(SOAPEnvelope envelope);
+
+    /**
+     * @param localName
+     * @param ns
+     * @param parent
+     * @param builder
+     * @return
+     */
+    public abstract SOAPHeader createSOAPHeader(String localName, OMNamespace ns, OMElement parent, OMXMLParserWrapper builder);
+
+
+    /**
+     * @param localName
+     * @param ns
+     */
+    public abstract SOAPHeaderBlock createSOAPHeaderBlock(String localName, OMNamespace ns);
+
+    /**
+     * @param localName
+     * @param ns
+     * @param parent
+     * @param builder
+     * @return
+     */
+    public abstract SOAPHeaderBlock createSOAPHeaderBlock(String localName, OMNamespace ns, OMElement parent, OMXMLParserWrapper builder);
+
+    /**
+     * @param parent
+     * @return
+     */
+    public abstract SOAPFault createSOAPFault(SOAPBody parent, Exception e);
+
+
+    /**
+     * @param ns
+     * @param parent
+     * @param builder
+     * @return
+     */
+    public abstract SOAPFault createSOAPFault(OMNamespace ns, SOAPBody parent, OMXMLParserWrapper builder);
+
+
+    //make the constructor protected
+    protected OMFactory() {
+    }
+
+    public static OMFactory newInstance() {
+        return FactoryFinder.findFactory(null);
+    }
+
+    public abstract SOAPEnvelope getDefaultEnvelope();
+
+}
\ No newline at end of file

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMFactoryException.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMFactoryException.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMFactoryException.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMFactoryException.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,36 @@
+package org.apache.axis.om;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * <p/>
+ * Exception thrown when the factory returns an error
+ */
+public class OMFactoryException extends OMException {
+
+    public OMFactoryException() {
+    }
+
+    public OMFactoryException(String message) {
+        super(message);
+    }
+
+    public OMFactoryException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public OMFactoryException(Throwable cause) {
+        super(cause);
+    }
+}

Added: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMFault.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMFault.java?view=auto&rev=156512
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMFault.java (added)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/om/OMFault.java Tue Mar  8 00:56:12 2005
@@ -0,0 +1,125 @@
+/*   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.
+ */
+
+package org.apache.axis.om;
+
+import java.util.Locale;
+
+
+/**
+ * An element in the <CODE>OMBody</CODE> object that contains error and/or
+ * status information. This information may relate to errors in the
+ * <CODE>OMMessage</CODE> object or to problems that are not related to the
+ * content in the message itself. Problems not related to the message itself are
+ * generally errors in processing, such as the inability to communicate with an
+ * upstream server. <P> The <CODE>OMFault</CODE> interface provides methods for
+ * retrieving the information contained in a <CODE> OMFault</CODE> object and
+ * for setting the fault code, the fault actor, and a string describing the
+ * fault. B fault code is one of the codes defined in the SOAP 1.1 specification
+ * that describe the fault. An actor is an intermediate recipient to whom a
+ * message was routed. The message path may include one or more actors, or, if
+ * no actors are specified, the message goes only to the default actor, which is
+ * the final intended recipient.
+ */
+public interface OMFault extends OMElement {
+
+    /**
+     * Sets this <CODE>OMFault</CODE> object with the given fault code.
+     * <p/>
+     * <P>Fault codes, which given information about the fault, are defined in
+     * the SOAP 1.1 specification.</P>
+     *
+     * @param faultCode a <CODE>String</CODE> giving the fault code to be set;
+     *                  must be one of the fault codes defined in the SOAP 1.1
+     *                  specification
+     * @throws OMException if there was an error in adding the <CODE>faultCode</CODE>
+     *                     to the underlying XML tree.
+     * @see #getFaultCode() getFaultCode()
+     */
+    public abstract void setFaultCode(String faultCode) throws OMException;
+
+    /**
+     * Gets the fault code for this <CODE>OMFault</CODE> object.
+     *
+     * @return a <CODE>String</CODE> with the fault code
+     * @see #setFaultCode(String) setFaultCode(java.lang.String)
+     */
+    public abstract String getFaultCode();
+
+    /**
+     * Sets this <CODE>OMFault</CODE> object with the given fault actor.
+     * <p/>
+     * <P>The fault actor is the recipient in the message path who caused the
+     * fault to happen.</P>
+     *
+     * @param faultActor a <CODE>String</CODE> identifying the actor that caused
+     *                   this <CODE> OMFault</CODE> object
+     * @throws OMException if there was an error in adding the <CODE>faultActor</CODE>
+     *                     to the underlying XML tree.
+     * @see #getFaultActor() getFaultActor()
+     */
+    public abstract void setFaultActor(String faultActor) throws OMException;
+
+    /**
+     * Gets the fault actor for this <CODE>OMFault</CODE> object.
+     *
+     * @return a <CODE>String</CODE> giving the actor in the message path that
+     *         caused this <CODE>OMFault</CODE> object
+     * @see #setFaultActor(String) setFaultActor(java.lang.String)
+     */
+    public abstract String getFaultActor();
+
+    /**
+     * Sets the fault string for this <CODE>OMFault</CODE> object to the given
+     * string.
+     *
+     * @param faultString a <CODE>String</CODE> giving an explanation of the
+     *                    fault
+     * @throws OMException if there was an error in adding the <CODE>faultString</CODE>
+     *                     to the underlying XML tree.
+     * @see #getFaultString() getFaultString()
+     */
+    public abstract void setFaultString(String faultString)
+            throws OMException;
+
+    /**
+     * Gets the fault string for this <CODE>OMFault</CODE> object.
+     *
+     * @return a <CODE>String</CODE> giving an explanation of the fault
+     */
+    public abstract String getFaultString();
+
+    /**
+     * Sets the fault string for this <code>OMFault</code> object to the given
+     * string and localized to the given locale.
+     *
+     * @param faultString a <code>String</code> giving an explanation of the
+     *                    fault
+     * @param locale      a <code>Locale</code> object indicating the native
+     *                    language of the <code>faultString</code>
+     * @throws OMException if there was an error in adding the <code>faultString</code>
+     *                     to the underlying XML tree
+     */
+    public abstract void setFaultString(String faultString, Locale locale) throws OMException;
+
+    /**
+     * Returns the optional detail element for this <code>OMFault</code>
+     * object.
+     *
+     * @return a <code>Locale</code> object indicating the native language of
+     *         the fault string or <code>null</code> if no locale was specified
+     */
+    public abstract Locale getFaultStringLocale();
+}