abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r630324 - in /incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax: FOMDocument.java FOMElement.java
Date Fri, 22 Feb 2008 21:09:49 GMT
Author: jmsnell
Date: Fri Feb 22 13:09:48 2008
New Revision: 630324

URL: http://svn.apache.org/viewvc?rev=630324&view=rev
Log:
per https://issues.apache.org/jira/browse/ABDERA-128, add toFormattedString support to FOMElement
and FOMDocument, which adds pretty print capabilities for debugging

Modified:
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDocument.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDocument.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDocument.java?rev=630324&r1=630323&r2=630324&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDocument.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDocument.java
Fri Feb 22 13:09:48 2008
@@ -17,6 +17,7 @@
 */
 package org.apache.abdera.parser.stax;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
@@ -397,5 +398,15 @@
     WriterOptions options)
       throws IOException {
     writeTo(getFactory().getAbdera().getWriterFactory().getWriter(writer),out,options);
+  }
+  
+  public String toFormattedString() {
+    try {
+      ByteArrayOutputStream out = new ByteArrayOutputStream();
+      writeTo("prettyxml",out);
+      return new String(out.toByteArray(),"UTF-8");
+    } catch (Exception e) {
+      return toString();
+    }
   }
 }

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java?rev=630324&r1=630323&r2=630324&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
Fri Feb 22 13:09:48 2008
@@ -18,6 +18,7 @@
 package org.apache.abdera.parser.stax;
 
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
@@ -876,4 +877,13 @@
     writeTo(getFactory().getAbdera().getWriterFactory().getWriter(writer),out,options);
   }
 
+  public String toFormattedString() {
+    try {
+      ByteArrayOutputStream out = new ByteArrayOutputStream();
+      writeTo("prettyxml",out);
+      return new String(out.toByteArray(),"UTF-8");
+    } catch (Exception e) {
+      return toString();
+    }
+  }
 }



Mime
View raw message