You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2015/06/21 01:02:24 UTC

svn commit: r1686675 - in /webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom: OMElementImpl.java OMSourcedElementImpl.java

Author: veithen
Date: Sat Jun 20 23:02:24 2015
New Revision: 1686675

URL: http://svn.apache.org/r1686675
Log:
Let OMElementImpl handle serialization to String.

Modified:
    webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
    webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java

Modified: webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java?rev=1686675&r1=1686674&r2=1686675&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java (original)
+++ webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java Sat Jun 20 23:02:24 2015
@@ -174,7 +174,7 @@ public class OMElementImpl extends OMNod
         setNamespace(namespace, true);
     }
 
-    public String toStringWithConsume() throws XMLStreamException {
+    public final String toStringWithConsume() throws XMLStreamException {
         StringWriter writer = new StringWriter();
         XMLStreamWriter writer2 = StAXUtils.createXMLStreamWriter(writer);
         try {
@@ -186,7 +186,7 @@ public class OMElementImpl extends OMNod
         return writer.toString();
     }
 
-    public String toString() {
+    public final String toString() {
         StringWriter writer = new StringWriter();
         try {
             XMLStreamWriter writer2 = StAXUtils.createXMLStreamWriter(writer);

Modified: webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java?rev=1686675&r1=1686674&r2=1686675&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java (original)
+++ webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java Sat Jun 20 23:02:24 2015
@@ -38,7 +38,6 @@ import org.apache.axiom.om.impl.common.O
 import org.apache.axiom.om.impl.common.OMNamespaceImpl;
 import org.apache.axiom.om.impl.common.serializer.push.OutputException;
 import org.apache.axiom.om.impl.common.serializer.push.Serializer;
-import org.apache.axiom.om.util.StAXUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -46,10 +45,7 @@ import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
 
-import java.io.IOException;
-import java.io.StringWriter;
 import java.util.Iterator;
 
 /**
@@ -437,18 +433,6 @@ public class OMSourcedElementImpl extend
         }
     }
 
-    public String toStringWithConsume() throws XMLStreamException {
-        if (isExpanded()) {
-            return super.toStringWithConsume();
-        } else {
-            StringWriter writer = new StringWriter();
-            XMLStreamWriter writer2 = StAXUtils.createXMLStreamWriter(writer);
-            dataSource.serialize(writer2);  // dataSource.serialize consumes the data
-            writer2.flush();
-            return writer.toString();
-        }
-    }
-    
     OMNode clone(OMCloneOptions options, OMContainer targetParent) {
         // If already expanded or this is not an OMDataSourceExt, then
         // create a copy of the OM Tree
@@ -548,28 +532,6 @@ public class OMSourcedElementImpl extend
         }
     }
 
-    public String toString() {
-        if (isExpanded) {
-            return super.toString();
-        } else if (OMDataSourceUtil.isDestructiveWrite(dataSource)) {
-            forceExpand();
-            return super.toString();
-        } else {
-            try {
-                StringWriter writer = new StringWriter();
-                OMOutputFormat format = new OMOutputFormat();
-                dataSource.serialize(writer, format);
-                String text = writer.toString();
-                writer.close();
-                return text;
-            } catch (XMLStreamException e) {
-                throw new RuntimeException("Cannot serialize OM Element " + this.getLocalName(), e);
-            } catch (IOException e) {
-                throw new RuntimeException("Cannot serialize OM Element " + this.getLocalName(), e);
-            }
-        }
-    }
-
     public void buildWithAttachments() {
         
         // If not done, force the parser to build the elements