You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by ve...@apache.org on 2009/08/15 12:17:17 UTC

svn commit: r804448 - in /webservices/commons/trunk/modules/axiom/modules: axiom-api/src/main/java/org/apache/axiom/om/ axiom-api/src/test/java/org/apache/axiom/om/ axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/

Author: veithen
Date: Sat Aug 15 10:17:17 2009
New Revision: 804448

URL: http://svn.apache.org/viewvc?rev=804448&view=rev
Log:
WSCOMMONS-480: Declared the serialize and serializeAndConsume methods (taking an OutputStream or Writer as argument) on OMContainer and deprecated them on OMNode. Rationale:
* These methods don't make sense (and even don't work) on an OMNode in general, but only on an OMElement.
* These methods make sense on OMDocument as well (which already declared some of them), so OMContainer is the right place.

Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMDocument.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMNode.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMDocumentSerilizationTestBase.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNodeImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSerializableImpl.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java?rev=804448&r1=804447&r2=804448&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java Sat Aug 15 10:17:17 2009
@@ -20,6 +20,10 @@
 package org.apache.axiom.om;
 
 import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import java.io.OutputStream;
+import java.io.Writer;
 import java.util.Iterator;
 
 /**
@@ -96,5 +100,78 @@
      */
     OMNode getFirstOMChild();
 
+    /**
+     * Serializes the node with caching.
+     *
+     * @param output
+     * @throws XMLStreamException
+     */
+    void serialize(OutputStream output) throws XMLStreamException;
+
+    /**
+     * Serializes the node with caching.
+     *
+     * @param writer
+     * @throws XMLStreamException
+     */
+    void serialize(Writer writer) throws XMLStreamException;
+
+    /**
+     * Serializes the node with caching.
+     *
+     * @param output
+     * @param format
+     * @throws XMLStreamException
+     */
+    void serialize(OutputStream output, OMOutputFormat format)
+            throws XMLStreamException;
+
+    /**
+     * Serializes the node with caching.
+     *
+     * @param writer
+     * @param format
+     * @throws XMLStreamException
+     */
+    void serialize(Writer writer, OMOutputFormat format)
+            throws XMLStreamException;
+
+    /**
+     * Serializes the node without caching.
+     *
+     * @param output
+     * @throws XMLStreamException
+     */
+    void serializeAndConsume(OutputStream output)
+            throws XMLStreamException;
+
+    /**
+     * Serializes the node without caching.
+     *
+     * @param writer
+     * @throws XMLStreamException
+     */
+    void serializeAndConsume(Writer writer) throws XMLStreamException;
+
+    /**
+     * Serializes the node without caching.
+     *
+     * @param output
+     * @param format
+     * @throws XMLStreamException
+     */
+    void serializeAndConsume(OutputStream output, OMOutputFormat format)
+            throws XMLStreamException;
+
+    /**
+     * Serializes the node without caching.
+     *
+     * @param writer
+     * @param format
+     * @throws XMLStreamException
+     */
+    void serializeAndConsume(Writer writer, OMOutputFormat format)
+            throws XMLStreamException;
+
     void buildNext();
 }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMDocument.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMDocument.java?rev=804448&r1=804447&r2=804448&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMDocument.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMDocument.java Sat Aug 15 10:17:17 2009
@@ -19,10 +19,6 @@
 
 package org.apache.axiom.om;
 
-import javax.xml.stream.XMLStreamException;
-import java.io.OutputStream;
-
-
 public interface OMDocument extends OMContainer {
 
     /** Field XML_10 XML Version 1.0 */
@@ -43,6 +39,10 @@
      *
      * @param rootElement
      */
+    // TODO: this method and its implementations need review:
+    //        - LLOM doesn't add the element as a child (!!!)
+    //        - Neither LLOM nor DOOM updates the parent of the element
+    // Note that OMSourcedElementImpl seems to depend on this behavior
     void setOMDocumentElement(OMElement rootElement);
 
     /**
@@ -83,39 +83,4 @@
     String isStandalone();
 
     void setStandalone(String isStandalone);
-
-    /**
-     * Serializes the OMDocument.
-     *
-     * @param output
-     * @param format
-     * @throws XMLStreamException
-     */
-    void serializeAndConsume(OutputStream output, OMOutputFormat format)
-            throws XMLStreamException;
-
-    /**
-     * Builds the OM node/tree and then serializes the document.
-     *
-     * @param output
-     * @param format
-     * @throws XMLStreamException
-     */
-    void serialize(OutputStream output, OMOutputFormat format) throws XMLStreamException;
-
-    /**
-     * Serializes the OMDocument.
-     *
-     * @param output
-     * @throws XMLStreamException
-     */
-    void serializeAndConsume(OutputStream output) throws XMLStreamException;
-
-    /**
-     * Serializes the document with cache on.
-     *
-     * @param output
-     * @throws XMLStreamException
-     */
-    void serialize(OutputStream output) throws XMLStreamException;
 }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java?rev=804448&r1=804447&r2=804448&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java Sat Aug 15 10:17:17 2009
@@ -22,6 +22,9 @@
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
+
+import java.io.OutputStream;
+import java.io.Writer;
 import java.util.Iterator;
 
 /**
@@ -362,4 +365,101 @@
     void setLineNumber(int lineNumber);
 
     int getLineNumber();
+
+    /**
+     * Serializes the node with caching.
+     *
+     * @param output
+     * @throws XMLStreamException
+     */
+    // Note: This method is inherited from both OMNode and OMContainer, but it is deprecated in
+    //       OMNode. We redeclare it here to make sure that people don't get a deprecation
+    //       warning when using the method on an OMElement.
+    void serialize(OutputStream output) throws XMLStreamException;
+
+    /**
+     * Serializes the node with caching.
+     *
+     * @param writer
+     * @throws XMLStreamException
+     */
+    // Note: This method is inherited from both OMNode and OMContainer, but it is deprecated in
+    //       OMNode. We redeclare it here to make sure that people don't get a deprecation
+    //       warning when using the method on an OMElement.
+    void serialize(Writer writer) throws XMLStreamException;
+
+    /**
+     * Serializes the node with caching.
+     *
+     * @param output
+     * @param format
+     * @throws XMLStreamException
+     */
+    // Note: This method is inherited from both OMNode and OMContainer, but it is deprecated in
+    //       OMNode. We redeclare it here to make sure that people don't get a deprecation
+    //       warning when using the method on an OMElement.
+    void serialize(OutputStream output, OMOutputFormat format)
+            throws XMLStreamException;
+
+    /**
+     * Serializes the node with caching.
+     *
+     * @param writer
+     * @param format
+     * @throws XMLStreamException
+     */
+    // Note: This method is inherited from both OMNode and OMContainer, but it is deprecated in
+    //       OMNode. We redeclare it here to make sure that people don't get a deprecation
+    //       warning when using the method on an OMElement.
+    void serialize(Writer writer, OMOutputFormat format)
+            throws XMLStreamException;
+
+    /**
+     * Serializes the node without caching.
+     *
+     * @param output
+     * @throws XMLStreamException
+     */
+    // Note: This method is inherited from both OMNode and OMContainer, but it is deprecated in
+    //       OMNode. We redeclare it here to make sure that people don't get a deprecation
+    //       warning when using the method on an OMElement.
+    void serializeAndConsume(OutputStream output)
+            throws XMLStreamException;
+
+    /**
+     * Serializes the node without caching.
+     *
+     * @param writer
+     * @throws XMLStreamException
+     */
+    // Note: This method is inherited from both OMNode and OMContainer, but it is deprecated in
+    //       OMNode. We redeclare it here to make sure that people don't get a deprecation
+    //       warning when using the method on an OMElement.
+    void serializeAndConsume(Writer writer) throws XMLStreamException;
+
+    /**
+     * Serializes the node without caching.
+     *
+     * @param output
+     * @param format
+     * @throws XMLStreamException
+     */
+    // Note: This method is inherited from both OMNode and OMContainer, but it is deprecated in
+    //       OMNode. We redeclare it here to make sure that people don't get a deprecation
+    //       warning when using the method on an OMElement.
+    void serializeAndConsume(OutputStream output, OMOutputFormat format)
+            throws XMLStreamException;
+
+    /**
+     * Serializes the node without caching.
+     *
+     * @param writer
+     * @param format
+     * @throws XMLStreamException
+     */
+    // Note: This method is inherited from both OMNode and OMContainer, but it is deprecated in
+    //       OMNode. We redeclare it here to make sure that people don't get a deprecation
+    //       warning when using the method on an OMElement.
+    void serializeAndConsume(Writer writer, OMOutputFormat format)
+            throws XMLStreamException;
 }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMNode.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMNode.java?rev=804448&r1=804447&r2=804448&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMNode.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMNode.java Sat Aug 15 10:17:17 2009
@@ -172,74 +172,54 @@
     OMNode getPreviousOMSibling();
 
     /**
-     * Serializes the node with caching.
-     *
-     * @param output
-     * @throws XMLStreamException
+     * @deprecated This method is not meaningful on a node in general, but only on an
+     *             {@link OMElement}.
      */
     void serialize(OutputStream output) throws XMLStreamException;
 
     /**
-     * Serializes the node with caching.
-     *
-     * @param writer
-     * @throws XMLStreamException
+     * @deprecated This method is not meaningful on a node in general, but only on an
+     *             {@link OMElement}.
      */
     void serialize(Writer writer) throws XMLStreamException;
 
     /**
-     * Serializes the node with caching.
-     *
-     * @param output
-     * @param format
-     * @throws XMLStreamException
+     * @deprecated This method is not meaningful on a node in general, but only on an
+     *             {@link OMElement}.
      */
     void serialize(OutputStream output, OMOutputFormat format)
             throws XMLStreamException;
 
     /**
-     * Serializes the node with caching.
-     *
-     * @param writer
-     * @param format
-     * @throws XMLStreamException
+     * @deprecated This method is not meaningful on a node in general, but only on an
+     *             {@link OMElement}.
      */
     void serialize(Writer writer, OMOutputFormat format)
             throws XMLStreamException;
 
     /**
-     * Serializes the node without caching.
-     *
-     * @param output
-     * @throws XMLStreamException
+     * @deprecated This method is not meaningful on a node in general, but only on an
+     *             {@link OMElement}.
      */
     void serializeAndConsume(OutputStream output)
             throws XMLStreamException;
 
     /**
-     * Serializes the node without caching.
-     *
-     * @param writer
-     * @throws XMLStreamException
+     * @deprecated This method is not meaningful on a node in general, but only on an
+     *             {@link OMElement}.
      */
     void serializeAndConsume(Writer writer) throws XMLStreamException;
 
     /**
-     * Serializes the node without caching.
-     *
-     * @param output
-     * @param format
-     * @throws XMLStreamException
+     * @deprecated This method is not meaningful on a node in general, but only on an
+     *             {@link OMElement}.
      */
     void serializeAndConsume(OutputStream output, OMOutputFormat format)
             throws XMLStreamException;
 
     /**
-     * Serializes the node without caching.
-     *
-     * @param writer
-     * @param format
-     * @throws XMLStreamException
+     * @deprecated This method is not meaningful on a node in general, but only on an
+     *             {@link OMElement}.
      */
     void serializeAndConsume(Writer writer, OMOutputFormat format)
             throws XMLStreamException;

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMDocumentSerilizationTestBase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMDocumentSerilizationTestBase.java?rev=804448&r1=804447&r2=804448&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMDocumentSerilizationTestBase.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMDocumentSerilizationTestBase.java Sat Aug 15 10:17:17 2009
@@ -60,7 +60,7 @@
         documentElement.addChild(child1);
 
         document = factory.createOMDocument();
-        document.setOMDocumentElement(documentElement);
+        document.addChild(documentElement);
 
     }
 

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java?rev=804448&r1=804447&r2=804448&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java Sat Aug 15 10:17:17 2009
@@ -24,7 +24,6 @@
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.OMOutputFormat;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.MTOMXMLStreamWriter;
 import org.apache.axiom.om.impl.OMContainerEx;
@@ -38,7 +37,6 @@
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
-import java.io.OutputStream;
 import java.util.Iterator;
 
 /** Class OMDocumentImpl */
@@ -311,57 +309,6 @@
         this.xmlVersion = xmlVersion;
     }
 
-    /**
-     * Serializes the document directly to the output stream with caching disabled.
-     *
-     * @param output
-     * @throws XMLStreamException
-     */
-    public void serializeAndConsume(OutputStream output) throws XMLStreamException {
-        MTOMXMLStreamWriter writer = new MTOMXMLStreamWriter(output, new OMOutputFormat());
-        internalSerialize(writer, false);
-        writer.flush();
-    }
-
-    /**
-     * Serializes the document directly to the output stream with caching enabled.
-     *
-     * @param output
-     * @throws XMLStreamException
-     */
-    public void serialize(OutputStream output) throws XMLStreamException {
-        MTOMXMLStreamWriter writer = new MTOMXMLStreamWriter(output, new OMOutputFormat());
-        internalSerialize(writer, true);
-        writer.flush();
-    }
-
-    /**
-     * Serializes the document directly to the output stream with caching disabled.
-     *
-     * @param output
-     * @param format
-     * @throws XMLStreamException
-     */
-    public void serializeAndConsume(OutputStream output, OMOutputFormat format)
-            throws XMLStreamException {
-        MTOMXMLStreamWriter writer = new MTOMXMLStreamWriter(output, format);
-        internalSerialize(writer, false);
-        writer.flush();
-    }
-
-    /**
-     * Serializes the document directly to the output stream with caching enabled.
-     *
-     * @param output
-     * @param format
-     * @throws XMLStreamException
-     */
-    public void serialize(OutputStream output, OMOutputFormat format) throws XMLStreamException {
-        MTOMXMLStreamWriter writer = new MTOMXMLStreamWriter(output, format);
-        internalSerialize(writer, true);
-        writer.flush();
-    }
-
     public void internalSerialize(XMLStreamWriter writer, boolean cache) throws XMLStreamException {
         internalSerialize(writer, cache, !((MTOMXMLStreamWriter) writer).isIgnoreXMLDeclaration());
     }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNodeImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNodeImpl.java?rev=804448&r1=804447&r2=804448&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNodeImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNodeImpl.java Sat Aug 15 10:17:17 2009
@@ -26,20 +26,12 @@
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.OMOutputFormat;
 import org.apache.axiom.om.OMProcessingInstruction;
 import org.apache.axiom.om.OMText;
-import org.apache.axiom.om.impl.MTOMXMLStreamWriter;
 import org.apache.axiom.om.impl.OMContainerEx;
 import org.apache.axiom.om.impl.OMNodeEx;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.om.impl.llom.factory.OMLinkedListImplFactory;
-import org.apache.axiom.om.util.StAXUtils;
-
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-import java.io.OutputStream;
-import java.io.Writer;
 
 /** Class OMNodeImpl */
 public abstract class OMNodeImpl extends OMSerializableImpl implements OMNode, OMNodeEx {
@@ -309,92 +301,6 @@
         }
     }
 
-    public void serialize(OutputStream output) throws XMLStreamException {
-        XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(output);
-        try {
-            serialize(xmlStreamWriter);
-        } finally {
-            xmlStreamWriter.close();
-        }
-    }
-
-    public void serialize(Writer writer) throws XMLStreamException {
-        XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(writer);
-        try {
-            serialize(xmlStreamWriter);
-        } finally {
-            xmlStreamWriter.close();
-        }
-    }
-
-    public void serializeAndConsume(OutputStream output) throws XMLStreamException {
-        XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(output);
-        try {
-            serializeAndConsume(xmlStreamWriter);
-        } finally {
-            xmlStreamWriter.close();
-        }
-    }
-
-    public void serializeAndConsume(Writer writer) throws XMLStreamException {
-        XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(writer);
-        try {
-            serializeAndConsume(xmlStreamWriter);
-        } finally {
-            xmlStreamWriter.close();
-        }
-    }
-
-    public void serialize(OutputStream output, OMOutputFormat format) throws XMLStreamException {
-        MTOMXMLStreamWriter writer = new MTOMXMLStreamWriter(output, format);
-        try {
-            internalSerialize(writer, true);
-            // TODO: the flush is necessary because of an issue with the lifecycle of MTOMXMLStreamWriter
-            writer.flush();
-        } finally {
-            writer.close();
-        }
-    }
-
-    public void serialize(Writer writer2, OMOutputFormat format) throws XMLStreamException {
-        MTOMXMLStreamWriter writer =
-                new MTOMXMLStreamWriter(StAXUtils.createXMLStreamWriter(writer2));
-        writer.setOutputFormat(format);
-        try {
-            internalSerialize(writer, true);
-            // TODO: the flush is necessary because of an issue with the lifecycle of MTOMXMLStreamWriter
-            writer.flush();
-        } finally {
-            writer.close();
-        }
-    }
-
-    public void serializeAndConsume(OutputStream output, OMOutputFormat format)
-            throws XMLStreamException {
-        MTOMXMLStreamWriter writer = new MTOMXMLStreamWriter(output, format);
-        try {
-            internalSerialize(writer, false);
-            // TODO: the flush is necessary because of an issue with the lifecycle of MTOMXMLStreamWriter
-            writer.flush();
-        } finally {
-            writer.close();
-        }
-    }
-
-    public void serializeAndConsume(Writer writer2, OMOutputFormat format)
-            throws XMLStreamException {
-        MTOMXMLStreamWriter writer =
-                new MTOMXMLStreamWriter(StAXUtils.createXMLStreamWriter(writer2));
-        writer.setOutputFormat(format);
-        try {
-            internalSerialize(writer, false);
-            // TODO: the flush is necessary because of an issue with the lifecycle of MTOMXMLStreamWriter
-            writer.flush();
-        } finally {
-            writer.close();
-        }
-    }
-
     /**
      * This method is intended only to be used by Axiom intenals when merging Objects from different
      * Axiom implementations to the LLOM implementation.

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSerializableImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSerializableImpl.java?rev=804448&r1=804447&r2=804448&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSerializableImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSerializableImpl.java Sat Aug 15 10:17:17 2009
@@ -19,15 +19,20 @@
 
 package org.apache.axiom.om.impl.llom;
 
+import java.io.OutputStream;
+import java.io.Writer;
+
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMOutputFormat;
 import org.apache.axiom.om.OMSerializable;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.MTOMXMLStreamWriter;
 import org.apache.axiom.om.impl.builder.StAXBuilder;
+import org.apache.axiom.om.util.StAXUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -116,4 +121,90 @@
         internalSerialize(writer, cache);
         writer.flush();
     }
+
+    public void serialize(OutputStream output) throws XMLStreamException {
+        XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(output);
+        try {
+            serialize(xmlStreamWriter);
+        } finally {
+            xmlStreamWriter.close();
+        }
+    }
+
+    public void serialize(Writer writer) throws XMLStreamException {
+        XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(writer);
+        try {
+            serialize(xmlStreamWriter);
+        } finally {
+            xmlStreamWriter.close();
+        }
+    }
+
+    public void serializeAndConsume(OutputStream output) throws XMLStreamException {
+        XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(output);
+        try {
+            serializeAndConsume(xmlStreamWriter);
+        } finally {
+            xmlStreamWriter.close();
+        }
+    }
+
+    public void serializeAndConsume(Writer writer) throws XMLStreamException {
+        XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(writer);
+        try {
+            serializeAndConsume(xmlStreamWriter);
+        } finally {
+            xmlStreamWriter.close();
+        }
+    }
+
+    public void serialize(OutputStream output, OMOutputFormat format) throws XMLStreamException {
+        MTOMXMLStreamWriter writer = new MTOMXMLStreamWriter(output, format);
+        try {
+            internalSerialize(writer, true);
+            // TODO: the flush is necessary because of an issue with the lifecycle of MTOMXMLStreamWriter
+            writer.flush();
+        } finally {
+            writer.close();
+        }
+    }
+
+    public void serialize(Writer writer2, OMOutputFormat format) throws XMLStreamException {
+        MTOMXMLStreamWriter writer =
+                new MTOMXMLStreamWriter(StAXUtils.createXMLStreamWriter(writer2));
+        writer.setOutputFormat(format);
+        try {
+            internalSerialize(writer, true);
+            // TODO: the flush is necessary because of an issue with the lifecycle of MTOMXMLStreamWriter
+            writer.flush();
+        } finally {
+            writer.close();
+        }
+    }
+
+    public void serializeAndConsume(OutputStream output, OMOutputFormat format)
+            throws XMLStreamException {
+        MTOMXMLStreamWriter writer = new MTOMXMLStreamWriter(output, format);
+        try {
+            internalSerialize(writer, false);
+            // TODO: the flush is necessary because of an issue with the lifecycle of MTOMXMLStreamWriter
+            writer.flush();
+        } finally {
+            writer.close();
+        }
+    }
+
+    public void serializeAndConsume(Writer writer2, OMOutputFormat format)
+            throws XMLStreamException {
+        MTOMXMLStreamWriter writer =
+                new MTOMXMLStreamWriter(StAXUtils.createXMLStreamWriter(writer2));
+        writer.setOutputFormat(format);
+        try {
+            internalSerialize(writer, false);
+            // TODO: the flush is necessary because of an issue with the lifecycle of MTOMXMLStreamWriter
+            writer.flush();
+        } finally {
+            writer.close();
+        }
+    }
 }