abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r634390 - in /incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax: FOMDocument.java FOMElement.java
Date Thu, 06 Mar 2008 19:46:23 GMT
Author: jmsnell
Date: Thu Mar  6 11:46:22 2008
New Revision: 634390

URL: http://svn.apache.org/viewvc?rev=634390&view=rev
Log:
Use the configured writer.  Previously, the code was always assuming use of the default FOMWriter

Per https://issues.apache.org/jira/browse/ABDERA-131

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=634390&r1=634389&r2=634390&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
Thu Mar  6 11:46:22 2008
@@ -128,7 +128,7 @@
     OutputStream out, 
     WriterOptions options) 
       throws IOException {
-    FOMWriter writer = new FOMWriter();
+    Writer writer = this.getFactory().getAbdera().getWriter();
     writer.writeTo(this,out,options);
   }
   
@@ -136,7 +136,7 @@
     java.io.Writer out, 
     WriterOptions options)
       throws IOException {
-    FOMWriter writer = new FOMWriter();
+    Writer writer = this.getFactory().getAbdera().getWriter();
     writer.writeTo(this,out,options);
   }
   
@@ -173,22 +173,28 @@
   public void writeTo(OutputStream out) throws IOException {
     String charset = getCharset();
     if (charset == null) charset = "UTF-8";
-    writeTo(new OutputStreamWriter(out, charset));
+    Writer writer = getFactory().getAbdera().getWriter();
+    writeTo(writer,new OutputStreamWriter(out, charset));
   }
 
   public void writeTo(java.io.Writer writer) throws IOException {
-    try {      
-      OMOutputFormat outputFormat = new OMOutputFormat();
-      if (this.getCharsetEncoding() != null)
-        outputFormat.setCharSetEncoding(this.getCharsetEncoding());
-      MTOMXMLStreamWriter omwriter = 
-        new MTOMXMLStreamWriter(
-          StAXUtils.createXMLStreamWriter(writer));
-      omwriter.setOutputFormat(outputFormat);
-      this.internalSerialize(omwriter);
-      omwriter.flush();    
-    } catch (XMLStreamException e) {
-      throw new FOMException(e);
+    Writer out = getFactory().getAbdera().getWriter();
+    if (!(out instanceof FOMWriter)) {
+      out.writeTo(this,writer);
+    } else {
+      try {      
+        OMOutputFormat outputFormat = new OMOutputFormat();
+        if (this.getCharsetEncoding() != null)
+          outputFormat.setCharSetEncoding(this.getCharsetEncoding());
+        MTOMXMLStreamWriter omwriter = 
+          new MTOMXMLStreamWriter(
+            StAXUtils.createXMLStreamWriter(writer));
+        omwriter.setOutputFormat(outputFormat);
+        this.internalSerialize(omwriter);
+        omwriter.flush();    
+      } catch (XMLStreamException e) {
+        throw new FOMException(e);
+      }
     }
   }
   

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=634390&r1=634389&r2=634390&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
Thu Mar  6 11:46:22 2008
@@ -342,7 +342,7 @@
     OutputStream out, 
     WriterOptions options) 
       throws IOException {
-    FOMWriter writer = new FOMWriter();
+    Writer writer = this.getFactory().getAbdera().getWriter();
     writer.writeTo(this,out,options);
   }
   
@@ -350,7 +350,7 @@
     java.io.Writer out, 
     WriterOptions options)
       throws IOException {
-    FOMWriter writer = new FOMWriter();
+    Writer writer = this.getFactory().getAbdera().getWriter();
     writer.writeTo(this,out,options);
   }
   
@@ -387,17 +387,23 @@
   public void writeTo(OutputStream out) throws IOException {
     Document doc = getDocument();
     String charset = doc != null ? doc.getCharset() : "UTF-8";
-    writeTo(new OutputStreamWriter(out,charset));
+    Writer writer = this.getFactory().getAbdera().getWriter();
+    writeTo(writer,new OutputStreamWriter(out,charset));
   }
 
   public void writeTo(java.io.Writer writer) throws IOException {
-    try { 
-      OMOutputFormat outputFormat = new OMOutputFormat();
-      if (getDocument() != null && getDocument().getCharset() != null)
-        outputFormat.setCharSetEncoding(getDocument().getCharset());
-      serialize(writer, outputFormat);
-    } catch (XMLStreamException e) {
-      throw new FOMException(e);
+    Writer out = getFactory().getAbdera().getWriter();
+    if (!(out instanceof FOMWriter)) {
+      out.writeTo(this,writer);
+    } else {
+      try { 
+        OMOutputFormat outputFormat = new OMOutputFormat();
+        if (getDocument() != null && getDocument().getCharset() != null)
+          outputFormat.setCharSetEncoding(getDocument().getCharset());
+        serialize(writer, outputFormat);
+      } catch (XMLStreamException e) {
+        throw new FOMException(e);
+      }
     }
   }
   



Mime
View raw message