maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r392144 - in /maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer: DefaultSiteRenderer.java DocumentRenderer.java DoxiaDocumentRenderer.java Renderer.java SiteRenderingContext.java
Date Fri, 07 Apr 2006 01:08:39 GMT
Author: brett
Date: Thu Apr  6 18:08:36 2006
New Revision: 392144

URL: http://svn.apache.org/viewcvs?rev=392144&view=rev
Log:
[MSITE-104] accept different input encodings
Submitted by: Trustin Lee

Modified:
    maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
    maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DocumentRenderer.java
    maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DoxiaDocumentRenderer.java
    maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/Renderer.java
    maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SiteRenderingContext.java

Modified: maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
URL: http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java?rev=392144&r1=392143&r2=392144&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
(original)
+++ maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
Thu Apr  6 18:08:36 2006
@@ -38,14 +38,16 @@
 import org.codehaus.plexus.velocity.VelocityComponent;
 
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
-import java.io.FileReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.LineNumberReader;
 import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.UnsupportedEncodingException;
 import java.io.Writer;
 import java.net.MalformedURLException;
 import java.net.URL;
@@ -73,8 +75,6 @@
     extends AbstractLogEnabled
     implements Renderer
 {
-    private static final String DEFAULT_OUTPUT_ENCODING = "UTF-8";
-
     // ----------------------------------------------------------------------
     // Requirements
     // ----------------------------------------------------------------------
@@ -112,15 +112,7 @@
     public void render( Collection documents, SiteRenderingContext siteRenderingContext,
File outputDirectory )
         throws RendererException, IOException
     {
-        render( documents, siteRenderingContext, outputDirectory, DEFAULT_OUTPUT_ENCODING
);
-    }
-
-    // TODO [IMPORTART] fix sigs
-    public void render( Collection documents, SiteRenderingContext siteRenderingContext,
File outputDirectory,
-                        String outputEncoding )
-        throws RendererException, IOException
-    {
-        renderModule( documents, siteRenderingContext, outputDirectory, outputEncoding );
+        renderModule( documents, siteRenderingContext, outputDirectory );
 
         for ( Iterator i = siteRenderingContext.getSiteDirectories().iterator(); i.hasNext();
)
         {
@@ -212,8 +204,7 @@
         }
     }
 
-    private void renderModule( Collection docs, SiteRenderingContext siteRenderingContext,
File outputDirectory,
-                               String outputEncoding )
+    private void renderModule( Collection docs, SiteRenderingContext siteRenderingContext,
File outputDirectory )
         throws IOException, RendererException
     {
         for ( Iterator i = docs.iterator(); i.hasNext(); )
@@ -233,8 +224,8 @@
                     outputFile.getParentFile().mkdirs();
                 }
 
-                OutputStreamWriter writer =
-                    new OutputStreamWriter( new FileOutputStream( outputFile ), outputEncoding
);
+                OutputStreamWriter writer = new OutputStreamWriter( new FileOutputStream(
outputFile ),
+                                                                    siteRenderingContext.getOutputEncoding()
);
 
                 try
                 {
@@ -253,7 +244,7 @@
     }
 
     public void renderDocument( Writer writer, RenderingContext renderingContext, SiteRenderingContext
context )
-        throws RendererException, FileNotFoundException
+        throws RendererException, FileNotFoundException, UnsupportedEncodingException
     {
         SiteRendererSink sink = new SiteRendererSink( renderingContext );
 
@@ -261,7 +252,7 @@
 
         try
         {
-            FileReader reader = new FileReader( fullPathDoc );
+            Reader reader = new InputStreamReader( new FileInputStream( fullPathDoc ), context.getInputEncoding()
);
 
             doxia.parse( reader, renderingContext.getParserId(), sink );
 

Modified: maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DocumentRenderer.java
URL: http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DocumentRenderer.java?rev=392144&r1=392143&r2=392144&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DocumentRenderer.java
(original)
+++ maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DocumentRenderer.java
Thu Apr  6 18:08:36 2006
@@ -19,6 +19,7 @@
 import org.apache.maven.doxia.module.xhtml.decoration.render.RenderingContext;
 
 import java.io.FileNotFoundException;
+import java.io.UnsupportedEncodingException;
 import java.io.Writer;
 
 /**
@@ -29,7 +30,7 @@
 public interface DocumentRenderer
 {
     void renderDocument( Writer writer, Renderer renderer, SiteRenderingContext siteRenderingContext
)
-        throws RendererException, FileNotFoundException;
+        throws RendererException, FileNotFoundException, UnsupportedEncodingException;
 
     String getOutputName();
 

Modified: maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DoxiaDocumentRenderer.java
URL: http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DoxiaDocumentRenderer.java?rev=392144&r1=392143&r2=392144&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DoxiaDocumentRenderer.java
(original)
+++ maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DoxiaDocumentRenderer.java
Thu Apr  6 18:08:36 2006
@@ -19,6 +19,7 @@
 import org.apache.maven.doxia.module.xhtml.decoration.render.RenderingContext;
 
 import java.io.FileNotFoundException;
+import java.io.UnsupportedEncodingException;
 import java.io.Writer;
 
 /**
@@ -37,7 +38,7 @@
     }
 
     public void renderDocument( Writer writer, Renderer renderer, SiteRenderingContext siteRenderingContext
)
-        throws RendererException, FileNotFoundException
+        throws RendererException, FileNotFoundException, UnsupportedEncodingException
     {
         renderer.renderDocument( writer, renderingContext, siteRenderingContext );
     }

Modified: maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/Renderer.java
URL: http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/Renderer.java?rev=392144&r1=392143&r2=392144&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/Renderer.java
(original)
+++ maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/Renderer.java
Thu Apr  6 18:08:36 2006
@@ -23,6 +23,7 @@
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.io.Writer;
 import java.net.MalformedURLException;
 import java.util.Collection;
@@ -40,10 +41,6 @@
     void render( Collection documents, SiteRenderingContext siteRenderingContext, File outputDirectory
)
         throws RendererException, IOException;
 
-    void render( Collection documents, SiteRenderingContext siteRenderingContext, File outputDirectory,
-                 String outputEncoding )
-        throws RendererException, IOException;
-
     void generateDocument( Writer writer, SiteRendererSink sink, SiteRenderingContext siteRenderingContext
)
         throws RendererException;
 
@@ -63,5 +60,5 @@
         throws IOException, RendererException;
 
     void renderDocument( Writer writer, RenderingContext renderingContext, SiteRenderingContext
context )
-        throws RendererException, FileNotFoundException;
+        throws RendererException, FileNotFoundException, UnsupportedEncodingException;
 }

Modified: maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SiteRenderingContext.java
URL: http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SiteRenderingContext.java?rev=392144&r1=392143&r2=392144&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SiteRenderingContext.java
(original)
+++ maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SiteRenderingContext.java
Thu Apr  6 18:08:36 2006
@@ -31,6 +31,14 @@
  */
 public class SiteRenderingContext
 {
+    private static final String DEFAULT_INPUT_ENCODING = "UTF-8";
+
+    private static final String DEFAULT_OUTPUT_ENCODING = "UTF-8";
+
+    private String inputEncoding = DEFAULT_INPUT_ENCODING;
+
+    private String outputEncoding = DEFAULT_OUTPUT_ENCODING;
+
     private String templateName;
 
     private ClassLoader templateClassLoader;
@@ -161,5 +169,25 @@
     public void setModuleExcludes( Map moduleExcludes )
     {
         this.moduleExcludes = moduleExcludes;
+    }
+
+    public String getInputEncoding()
+    {
+        return inputEncoding;
+    }
+
+    public void setInputEncoding( String inputEncoding )
+    {
+        this.inputEncoding = inputEncoding;
+    }
+
+    public String getOutputEncoding()
+    {
+        return outputEncoding;
+    }
+
+    public void setOutputEncoding( String outputEncoding )
+    {
+        this.outputEncoding = outputEncoding;
     }
 }



Mime
View raw message