maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbout...@apache.org
Subject svn commit: r712516 - in /maven/doxia/doxia/trunk: doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/ doxia-core/src/main/java/org/apache/maven/doxia/sink/ doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/...
Date Sun, 09 Nov 2008 17:04:23 GMT
Author: hboutemy
Date: Sun Nov  9 09:04:22 2008
New Revision: 712516

URL: http://svn.apache.org/viewvc?rev=712516&view=rev
Log:
DOXIA-185: modified SinkFactory API as discussed on the dev list to better accomodate non-text-only
Sinks

Added:
    maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/AbstractBinarySinkFactory.java
  (with props)
    maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/AbstractTextSinkFactory.java
  (with props)
Modified:
    maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/AbstractITextBookRenderer.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptSinkFactory.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceSinkFactory.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocbookSinkFactory.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSinkFactory.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSinkFactory.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/main/java/org/apache/maven/doxia/module/latex/LatexSinkFactory.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-rtf/src/main/java/org/apache/maven/doxia/module/rtf/RtfSinkFactory.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiSinkFactory.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSinkFactory.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkFactory.java
    maven/doxia/doxia/trunk/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/SinkFactory.java

Modified: maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/AbstractITextBookRenderer.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/AbstractITextBookRenderer.java?rev=712516&r1=712515&r2=712516&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/AbstractITextBookRenderer.java
(original)
+++ maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/AbstractITextBookRenderer.java
Sun Nov  9 09:04:22 2008
@@ -257,6 +257,7 @@
 
         try
         {
+            // TODO: fix encoding while reading the file (platform encoding used actually)
             doxia.parse( new FileReader( bookFile.getFile() ), bookFile.getParserId(), sink
);
         }
         catch ( ParserNotFoundException e )

Added: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/AbstractBinarySinkFactory.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/AbstractBinarySinkFactory.java?rev=712516&view=auto
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/AbstractBinarySinkFactory.java
(added)
+++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/AbstractBinarySinkFactory.java
Sun Nov  9 09:04:22 2008
@@ -0,0 +1,77 @@
+package org.apache.maven.doxia.sink;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.codehaus.plexus.util.WriterFactory;
+
+/**
+ * An abstract <code>SinkFactory</code> for binary output.
+ *
+ * @author <a href="mailto:hboutemy@apache.org">Hervé Boutemy</a>
+ * @version $Id$
+ */
+public abstract class AbstractBinarySinkFactory
+    implements SinkFactory
+{
+    /** {@inheritDoc} */
+    public Sink createSink( File outputDir, String outputName )
+        throws IOException
+    {
+        return createSink( outputDir, outputName, WriterFactory.UTF_8 );
+    }
+
+    /** {@inheritDoc} */
+    public Sink createSink( File outputDir, String outputName, String encoding )
+        throws IOException
+    {
+        if ( outputDir == null )
+        {
+            throw new IllegalArgumentException( "outputDir cannot be null." );
+        }
+
+        if ( !outputDir.exists() )
+        {
+            outputDir.mkdirs();
+        }
+        else
+        {
+            if ( !outputDir.isDirectory() )
+            {
+                throw new IllegalArgumentException( "The dir '" + outputDir + "' is not a
directory." );
+            }
+        }
+
+        OutputStream out = new FileOutputStream( new File( outputDir, outputName ) );
+
+        return createSink( out, encoding );
+    }
+
+    /** {@inheritDoc} */
+    public Sink createSink( OutputStream out )
+        throws IOException
+    {
+        return createSink( out, WriterFactory.UTF_8 );
+    }
+}

Propchange: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/AbstractBinarySinkFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/AbstractBinarySinkFactory.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/AbstractTextSinkFactory.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/AbstractTextSinkFactory.java?rev=712516&view=auto
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/AbstractTextSinkFactory.java
(added)
+++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/AbstractTextSinkFactory.java
Sun Nov  9 09:04:22 2008
@@ -0,0 +1,93 @@
+package org.apache.maven.doxia.sink;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+
+import org.codehaus.plexus.util.WriterFactory;
+
+/**
+ * An abstract <code>SinkFactory</code> for text markup syntax. <code>UTF-8</code>
is used
+ * when no encoding is specified.
+ *
+ * @author Hervé Boutemy
+ * @author Benjamin Bentmann
+ * @version $Id$
+ */
+public abstract class AbstractTextSinkFactory
+    implements SinkFactory
+{
+    /**
+     * @param writer The writer for the sink output, never <code>null</code>.
+     * @param encoding The character encoding used by the writer.
+     */
+    protected abstract Sink createSink( Writer writer, String encoding );
+
+    /** {@inheritDoc} */
+    public Sink createSink( File outputDir, String outputName )
+        throws IOException
+    {
+        return createSink( outputDir, outputName, WriterFactory.UTF_8 );
+    }
+
+    /** {@inheritDoc} */
+    public Sink createSink( File outputDir, String outputName, String encoding )
+        throws IOException
+    {
+        if ( outputDir == null )
+        {
+            throw new IllegalArgumentException( "outputDir cannot be null." );
+        }
+
+        if ( !outputDir.exists() )
+        {
+            outputDir.mkdirs();
+        }
+        else
+        {
+            if ( !outputDir.isDirectory() )
+            {
+                throw new IllegalArgumentException( "The dir '" + outputDir + "' is not a
directory." );
+            }
+        }
+
+        Writer writer = WriterFactory.newWriter( new File( outputDir, outputName ), encoding
);
+
+        return createSink( writer, encoding );
+    }
+
+    /** {@inheritDoc} */
+    public Sink createSink( OutputStream out )
+        throws IOException
+    {
+        return createSink( out, WriterFactory.UTF_8 );
+    }
+
+    /** {@inheritDoc} */
+    public Sink createSink( OutputStream out, String encoding )
+        throws IOException
+    {
+        return createSink( new OutputStreamWriter( out, encoding ), encoding );
+    }
+}

Propchange: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/AbstractTextSinkFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/AbstractTextSinkFactory.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptSinkFactory.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptSinkFactory.java?rev=712516&r1=712515&r2=712516&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptSinkFactory.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptSinkFactory.java
Sun Nov  9 09:04:22 2008
@@ -19,13 +19,10 @@
  * under the License.
  */
 
-import java.io.File;
-import java.io.IOException;
 import java.io.Writer;
 
+import org.apache.maven.doxia.sink.AbstractTextSinkFactory;
 import org.apache.maven.doxia.sink.Sink;
-import org.apache.maven.doxia.sink.SinkFactory;
-import org.codehaus.plexus.util.WriterFactory;
 
 /**
  * APT implementation of the Sink factory.
@@ -36,48 +33,12 @@
  * @plexus.component role="org.apache.maven.doxia.sink.SinkFactory" role-hint="apt"
  */
 public class AptSinkFactory
-    implements SinkFactory
+    extends AbstractTextSinkFactory
 {
     /** {@inheritDoc} */
-    public Sink createSink( File outputDir, String outputName )
-        throws IOException
-    {
-        if ( outputDir == null )
-        {
-            throw new IllegalArgumentException( "outputDir could not be null." );
-        }
-
-        if ( !outputDir.exists() )
-        {
-            outputDir.mkdirs();
-        }
-        else
-        {
-            if ( !outputDir.isDirectory() )
-            {
-                throw new IllegalArgumentException( "The dir '" + outputDir + "' is not a
directory." );
-            }
-        }
-
-        Writer writer = WriterFactory.newWriter( new File( outputDir, outputName ), WriterFactory.UTF_8
);
-
-        return new AptSink( writer );
-    }
-
-    /**
-     * @deprecated since 1.0, the encoding parameter has no effect, always use the UTF-8
encoding.
-     *
-     * {@inheritDoc}
-     */
-    public Sink createSink( File outputDir, String outputName, String encoding )
-        throws IOException
-    {
-        return createSink( outputDir, outputName );
-    }
-
-    /** {@inheritDoc} */
-    public Sink createSink( Writer writer )
+    public Sink createSink( Writer writer, String encoding )
     {
+        // encoding can safely be ignored since it isn't written into the generated APT source
         return new AptSink( writer );
     }
 }

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceSinkFactory.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceSinkFactory.java?rev=712516&r1=712515&r2=712516&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceSinkFactory.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceSinkFactory.java
Sun Nov  9 09:04:22 2008
@@ -19,13 +19,10 @@
  * under the License.
  */
 
-import java.io.File;
-import java.io.IOException;
 import java.io.Writer;
 
+import org.apache.maven.doxia.sink.AbstractTextSinkFactory;
 import org.apache.maven.doxia.sink.Sink;
-import org.apache.maven.doxia.sink.SinkFactory;
-import org.codehaus.plexus.util.WriterFactory;
 
 /**
  * Confluence implementation of the Sink factory.
@@ -36,48 +33,12 @@
  * @plexus.component role="org.apache.maven.doxia.sink.SinkFactory" role-hint="confluence"
  */
 public class ConfluenceSinkFactory
-    implements SinkFactory
+    extends AbstractTextSinkFactory
 {
     /** {@inheritDoc} */
-    public Sink createSink( File outputDir, String outputName )
-        throws IOException
-    {
-        if ( outputDir == null )
-        {
-            throw new IllegalArgumentException( "outputDir could not be null." );
-        }
-
-        if ( !outputDir.exists() )
-        {
-            outputDir.mkdirs();
-        }
-        else
-        {
-            if ( !outputDir.isDirectory() )
-            {
-                throw new IllegalArgumentException( "The dir '" + outputDir + "' is not a
directory." );
-            }
-        }
-
-        Writer writer = WriterFactory.newWriter( new File( outputDir, outputName ), WriterFactory.UTF_8
);
-
-        return new ConfluenceSink( writer );
-    }
-
-    /**
-     * @deprecated since 1.0, the encoding parameter has no effect, always use the UTF-8
encoding.
-     *
-     * {@inheritDoc}
-     */
-    public Sink createSink( File outputDir, String outputName, String encoding )
-        throws IOException
-    {
-        return createSink( outputDir, outputName );
-    }
-
-    /** {@inheritDoc} */
-    public Sink createSink( Writer writer )
+    public Sink createSink( Writer writer, String encoding )
     {
+        // encoding can safely be ignored since it isn't written into the generated Confluence
source
         return new ConfluenceSink( writer );
     }
 }

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocbookSinkFactory.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocbookSinkFactory.java?rev=712516&r1=712515&r2=712516&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocbookSinkFactory.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocbookSinkFactory.java
Sun Nov  9 09:04:22 2008
@@ -19,13 +19,10 @@
  * under the License.
  */
 
-import java.io.File;
-import java.io.IOException;
 import java.io.Writer;
 
+import org.apache.maven.doxia.sink.AbstractTextSinkFactory;
 import org.apache.maven.doxia.sink.Sink;
-import org.apache.maven.doxia.sink.SinkFactory;
-import org.codehaus.plexus.util.WriterFactory;
 
 /**
  * Docbook implementation of the Sink factory.
@@ -36,48 +33,12 @@
  * @plexus.component role="org.apache.maven.doxia.sink.SinkFactory" role-hint="docbook"
  */
 public class DocbookSinkFactory
-    implements SinkFactory
+    extends AbstractTextSinkFactory
 {
     /** {@inheritDoc} */
-    public Sink createSink( File outputDir, String outputName )
-        throws IOException
-    {
-        if ( outputDir == null )
-        {
-            throw new IllegalArgumentException( "outputDir could not be null." );
-        }
-
-        if ( !outputDir.exists() )
-        {
-            outputDir.mkdirs();
-        }
-        else
-        {
-            if ( !outputDir.isDirectory() )
-            {
-                throw new IllegalArgumentException( "The dir '" + outputDir + "' is not a
directory." );
-            }
-        }
-
-        Writer writer = WriterFactory.newXmlWriter( new File( outputDir, outputName ) );
-
-        return new DocBookSink( writer );
-    }
-
-    /**
-     * @deprecated since 1.0, the encoding parameter has no effect, always use the UTF-8
encoding.
-     *
-     * {@inheritDoc}
-     */
-    public Sink createSink( File outputDir, String outputName, String encoding )
-        throws IOException
-    {
-        return createSink( outputDir, outputName );
-    }
-
-    /** {@inheritDoc} */
-    public Sink createSink( Writer writer )
+    public Sink createSink( Writer writer, String encoding )
     {
+        // TODO: don't ignore encoding parameter
         return new DocBookSink( writer );
     }
 }

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSinkFactory.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSinkFactory.java?rev=712516&r1=712515&r2=712516&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSinkFactory.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSinkFactory.java
Sun Nov  9 09:04:22 2008
@@ -19,13 +19,10 @@
  * under the License.
  */
 
-import java.io.File;
-import java.io.IOException;
 import java.io.Writer;
 
+import org.apache.maven.doxia.sink.AbstractTextSinkFactory;
 import org.apache.maven.doxia.sink.Sink;
-import org.apache.maven.doxia.sink.SinkFactory;
-import org.codehaus.plexus.util.WriterFactory;
 
 /**
  * FO implementation of the Sink factory.
@@ -36,48 +33,12 @@
  * @plexus.component role="org.apache.maven.doxia.sink.SinkFactory" role-hint="fo"
  */
 public class FoSinkFactory
-    implements SinkFactory
+    extends AbstractTextSinkFactory
 {
     /** {@inheritDoc} */
-    public Sink createSink( File outputDir, String outputName )
-        throws IOException
-    {
-        if ( outputDir == null )
-        {
-            throw new IllegalArgumentException( "outputDir could not be null." );
-        }
-
-        if ( !outputDir.exists() )
-        {
-            outputDir.mkdirs();
-        }
-        else
-        {
-            if ( !outputDir.isDirectory() )
-            {
-                throw new IllegalArgumentException( "The dir '" + outputDir + "' is not a
directory." );
-            }
-        }
-
-        Writer writer = WriterFactory.newXmlWriter( new File( outputDir, outputName ) );
-
-        return new FoSink( writer );
-    }
-
-    /**
-     * @deprecated since 1.0, the encoding parameter has no effect, always use the UTF-8
encoding.
-     *
-     * {@inheritDoc}
-     */
-    public Sink createSink( File outputDir, String outputName, String encoding )
-        throws IOException
-    {
-        return createSink( outputDir, outputName );
-    }
-
-    /** {@inheritDoc} */
-    public Sink createSink( Writer writer )
+    public Sink createSink( Writer writer, String encoding )
     {
+        // TODO: don't ignore encoding parameter
         return new FoSink( writer );
     }
 }

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSinkFactory.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSinkFactory.java?rev=712516&r1=712515&r2=712516&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSinkFactory.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSinkFactory.java
Sun Nov  9 09:04:22 2008
@@ -19,12 +19,10 @@
  * under the License.
  */
 
-import java.io.File;
-import java.io.IOException;
 import java.io.Writer;
 
+import org.apache.maven.doxia.sink.AbstractTextSinkFactory;
 import org.apache.maven.doxia.sink.Sink;
-import org.apache.maven.doxia.sink.SinkFactory;
 import org.codehaus.plexus.util.WriterFactory;
 import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
 
@@ -37,49 +35,19 @@
  * @plexus.component role="org.apache.maven.doxia.sink.SinkFactory" role-hint="itext"
  */
 public class ITextSinkFactory
-    implements SinkFactory
+    extends AbstractTextSinkFactory
 {
     /** {@inheritDoc} */
-    public Sink createSink( File outputDir, String outputName )
-        throws IOException
+    public Sink createSink( Writer writer, String encoding )
     {
-        if ( outputDir == null )
-        {
-            throw new IllegalArgumentException( "outputDir could not be null." );
-        }
-
-        if ( !outputDir.exists() )
-        {
-            outputDir.mkdirs();
-        }
-        else
-        {
-            if ( !outputDir.isDirectory() )
-            {
-                throw new IllegalArgumentException( "The dir '" + outputDir + "' is not a
directory." );
-            }
-        }
-
-        Writer writer = WriterFactory.newXmlWriter( new File( outputDir, outputName ) );
-
+        // TODO: don't ignore encoding parameter
         return new ITextSink( writer );
     }
 
-    /**
-     * @deprecated since 1.0, the encoding parameter has no effect, always use the UTF-8
encoding.
-     *
-     * {@inheritDoc}
-     */
-    public Sink createSink( File outputDir, String outputName, String encoding )
-        throws IOException
-    {
-        return createSink( outputDir, outputName );
-    }
-
-    /** {@inheritDoc} */
     public Sink createSink( Writer writer )
     {
-        return new ITextSink( writer );
+        // TODO: should this method be deprecated?
+        return createSink( writer, WriterFactory.UTF_8 );
     }
 
     /**

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/main/java/org/apache/maven/doxia/module/latex/LatexSinkFactory.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/main/java/org/apache/maven/doxia/module/latex/LatexSinkFactory.java?rev=712516&r1=712515&r2=712516&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/main/java/org/apache/maven/doxia/module/latex/LatexSinkFactory.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/main/java/org/apache/maven/doxia/module/latex/LatexSinkFactory.java
Sun Nov  9 09:04:22 2008
@@ -19,13 +19,10 @@
  * under the License.
  */
 
-import java.io.File;
-import java.io.IOException;
 import java.io.Writer;
 
+import org.apache.maven.doxia.sink.AbstractTextSinkFactory;
 import org.apache.maven.doxia.sink.Sink;
-import org.apache.maven.doxia.sink.SinkFactory;
-import org.codehaus.plexus.util.WriterFactory;
 
 /**
  * Latex implementation of the Sink factory.
@@ -36,48 +33,13 @@
  * @plexus.component role="org.apache.maven.doxia.sink.SinkFactory" role-hint="latex"
  */
 public class LatexSinkFactory
-    implements SinkFactory
+    extends AbstractTextSinkFactory
 {
     /** {@inheritDoc} */
-    public Sink createSink( File outputDir, String outputName )
-        throws IOException
-    {
-        if ( outputDir == null )
-        {
-            throw new IllegalArgumentException( "outputDir could not be null." );
-        }
-
-        if ( !outputDir.exists() )
-        {
-            outputDir.mkdirs();
-        }
-        else
-        {
-            if ( !outputDir.isDirectory() )
-            {
-                throw new IllegalArgumentException( "The dir '" + outputDir + "' is not a
directory." );
-            }
-        }
-
-        Writer writer = WriterFactory.newWriter( new File( outputDir, outputName ), WriterFactory.UTF_8
);
-
-        return new LatexSink( writer );
-    }
-
-    /**
-     * @deprecated since 1.0, the encoding parameter has no effect, always use the UTF-8
encoding.
-     *
-     * {@inheritDoc}
-     */
-    public Sink createSink( File outputDir, String outputName, String encoding )
-        throws IOException
-    {
-        return createSink( outputDir, outputName );
-    }
-
-    /** {@inheritDoc} */
-    public Sink createSink( Writer writer )
+    public Sink createSink( Writer writer, String encoding )
     {
+        // TODO: can encoding safely be ignored? Shouldn't it be written into the generated
Latex source
+        // as inputenc package parameter?
         return new LatexSink( writer );
     }
 }

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-rtf/src/main/java/org/apache/maven/doxia/module/rtf/RtfSinkFactory.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-rtf/src/main/java/org/apache/maven/doxia/module/rtf/RtfSinkFactory.java?rev=712516&r1=712515&r2=712516&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-rtf/src/main/java/org/apache/maven/doxia/module/rtf/RtfSinkFactory.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-rtf/src/main/java/org/apache/maven/doxia/module/rtf/RtfSinkFactory.java
Sun Nov  9 09:04:22 2008
@@ -19,15 +19,11 @@
  * under the License.
  */
 
-import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.io.Writer;
 
+import org.apache.maven.doxia.sink.AbstractBinarySinkFactory;
 import org.apache.maven.doxia.sink.Sink;
-import org.apache.maven.doxia.sink.SinkFactory;
-import org.codehaus.plexus.util.WriterFactory;
 
 /**
  * Rtf implementation of the Sink factory.
@@ -38,44 +34,12 @@
  * @plexus.component role="org.apache.maven.doxia.sink.SinkFactory" role-hint="rtf"
  */
 public class RtfSinkFactory
-    implements SinkFactory
+    extends AbstractBinarySinkFactory
 {
     /** {@inheritDoc} */
-    public Sink createSink( File outputDir, String outputName )
+    public Sink createSink( OutputStream out, String encoding )
         throws IOException
     {
-        return createSink( outputDir, outputName, WriterFactory.UTF_8 );
-    }
-
-    /** {@inheritDoc} */
-    public Sink createSink( File outputDir, String outputName, String encoding )
-        throws IOException
-    {
-        if ( outputDir == null )
-        {
-            throw new IllegalArgumentException( "outputDir could not be null." );
-        }
-
-        if ( !outputDir.exists() )
-        {
-            outputDir.mkdirs();
-        }
-        else
-        {
-            if ( !outputDir.isDirectory() )
-            {
-                throw new IllegalArgumentException( "The dir '" + outputDir + "' is not a
directory." );
-            }
-        }
-
-        OutputStream os = new FileOutputStream( new File( outputDir, outputName ) );
-
-        return new RtfSink( os );
-    }
-
-    /** {@inheritDoc} */
-    public Sink createSink( Writer writer )
-    {
-        throw new UnsupportedOperationException( "createSink( Writer writer ) is not implemented."
);
+        return new RtfSink( out, encoding );
     }
 }

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiSinkFactory.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiSinkFactory.java?rev=712516&r1=712515&r2=712516&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiSinkFactory.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiSinkFactory.java
Sun Nov  9 09:04:22 2008
@@ -19,13 +19,10 @@
  * under the License.
  */
 
-import java.io.File;
-import java.io.IOException;
 import java.io.Writer;
 
+import org.apache.maven.doxia.sink.AbstractTextSinkFactory;
 import org.apache.maven.doxia.sink.Sink;
-import org.apache.maven.doxia.sink.SinkFactory;
-import org.codehaus.plexus.util.WriterFactory;
 
 /**
  * TWiki implementation of the Sink factory.
@@ -36,48 +33,12 @@
  * @plexus.component role="org.apache.maven.doxia.sink.SinkFactory" role-hint="twiki"
  */
 public class TWikiSinkFactory
-    implements SinkFactory
+    extends AbstractTextSinkFactory
 {
     /** {@inheritDoc} */
-    public Sink createSink( File outputDir, String outputName )
-        throws IOException
-    {
-        if ( outputDir == null )
-        {
-            throw new IllegalArgumentException( "outputDir could not be null." );
-        }
-
-        if ( !outputDir.exists() )
-        {
-            outputDir.mkdirs();
-        }
-        else
-        {
-            if ( !outputDir.isDirectory() )
-            {
-                throw new IllegalArgumentException( "The dir '" + outputDir + "' is not a
directory." );
-            }
-        }
-
-        Writer writer = WriterFactory.newWriter( new File( outputDir, outputName ), WriterFactory.UTF_8
);
-
-        return new TWikiSink( writer );
-    }
-
-    /**
-     * @deprecated since 1.0, the encoding parameter has no effect, always use the UTF-8
encoding.
-     *
-     * {@inheritDoc}
-     */
-    public Sink createSink( File outputDir, String outputName, String encoding )
-        throws IOException
-    {
-        return createSink( outputDir, outputName );
-    }
-
-    /** {@inheritDoc} */
-    public Sink createSink( Writer writer )
+    public Sink createSink( Writer writer, String encoding )
     {
+        // encoding can safely be ignored since it isn't written into the generated TWiki
source
         return new TWikiSink( writer );
     }
 }

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java?rev=712516&r1=712515&r2=712516&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java
Sun Nov  9 09:04:22 2008
@@ -405,7 +405,7 @@
             att.addAttribute( Attribute.TARGET, target );
         }
 
-            att.addAttribute( Attribute.HREF, HtmlTools.escapeHTML( name ) );
+        att.addAttribute( Attribute.HREF, HtmlTools.escapeHTML( name ) );
 
         writeStartTag( Tag.A, att );
     }

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSinkFactory.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSinkFactory.java?rev=712516&r1=712515&r2=712516&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSinkFactory.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSinkFactory.java
Sun Nov  9 09:04:22 2008
@@ -19,13 +19,10 @@
  * under the License.
  */
 
-import java.io.File;
-import java.io.IOException;
 import java.io.Writer;
 
+import org.apache.maven.doxia.sink.AbstractTextSinkFactory;
 import org.apache.maven.doxia.sink.Sink;
-import org.apache.maven.doxia.sink.SinkFactory;
-import org.codehaus.plexus.util.WriterFactory;
 
 /**
  * Xdoc implementation of the Sink factory.
@@ -36,48 +33,12 @@
  * @plexus.component role="org.apache.maven.doxia.sink.SinkFactory" role-hint="xdoc"
  */
 public class XdocSinkFactory
-    implements SinkFactory
+    extends AbstractTextSinkFactory
 {
     /** {@inheritDoc} */
-    public Sink createSink( File outputDir, String outputName )
-        throws IOException
-    {
-        if ( outputDir == null )
-        {
-            throw new IllegalArgumentException( "outputDir could not be null." );
-        }
-
-        if ( !outputDir.exists() )
-        {
-            outputDir.mkdirs();
-        }
-        else
-        {
-            if ( !outputDir.isDirectory() )
-            {
-                throw new IllegalArgumentException( "The dir '" + outputDir + "' is not a
directory." );
-            }
-        }
-
-        Writer writer = WriterFactory.newXmlWriter( new File( outputDir, outputName ) );
-
-        return new XdocSink( writer );
-    }
-
-    /**
-     * @deprecated since 1.0, the encoding parameter has no effect, always use the UTF-8
encoding.
-     *
-     * {@inheritDoc}
-     */
-    public Sink createSink( File outputDir, String outputName, String encoding )
-        throws IOException
-    {
-        return createSink( outputDir, outputName );
-    }
-
-    /** {@inheritDoc} */
-    public Sink createSink( Writer writer )
+    public Sink createSink( Writer writer, String encoding )
     {
+        // TODO: don't ignore encoding parameter
         return new XdocSink( writer );
     }
 }

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkFactory.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkFactory.java?rev=712516&r1=712515&r2=712516&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkFactory.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkFactory.java
Sun Nov  9 09:04:22 2008
@@ -19,13 +19,10 @@
  * under the License.
  */
 
-import java.io.File;
-import java.io.IOException;
 import java.io.Writer;
 
+import org.apache.maven.doxia.sink.AbstractTextSinkFactory;
 import org.apache.maven.doxia.sink.Sink;
-import org.apache.maven.doxia.sink.SinkFactory;
-import org.codehaus.plexus.util.WriterFactory;
 
 /**
  * Xhtml implementation of the Sink factory.
@@ -36,48 +33,12 @@
  * @plexus.component role="org.apache.maven.doxia.sink.SinkFactory" role-hint="xhtml"
  */
 public class XhtmlSinkFactory
-    implements SinkFactory
+    extends AbstractTextSinkFactory
 {
     /** {@inheritDoc} */
-    public Sink createSink( File outputDir, String outputName )
-        throws IOException
-    {
-        if ( outputDir == null )
-        {
-            throw new IllegalArgumentException( "outputDir could not be null." );
-        }
-
-        if ( !outputDir.exists() )
-        {
-            outputDir.mkdirs();
-        }
-        else
-        {
-            if ( !outputDir.isDirectory() )
-            {
-                throw new IllegalArgumentException( "The dir '" + outputDir + "' is not a
directory." );
-            }
-        }
-
-        Writer writer = WriterFactory.newXmlWriter( new File( outputDir, outputName ) );
-
-        return new XhtmlSink( writer );
-    }
-
-    /**
-     * @deprecated since 1.0, the encoding parameter has no effect, always use the UTF-8
encoding.
-     *
-     * {@inheritDoc}
-     */
-    public Sink createSink( File outputDir, String outputName, String encoding )
-        throws IOException
-    {
-        return createSink( outputDir, outputName );
-    }
-
-    /** {@inheritDoc} */
-    public Sink createSink( Writer writer )
+    public Sink createSink( Writer writer, String encoding )
     {
+        // TODO: don't ignore encoding parameter
         return new XhtmlSink( writer );
     }
 }

Modified: maven/doxia/doxia/trunk/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/SinkFactory.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/SinkFactory.java?rev=712516&r1=712515&r2=712516&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/SinkFactory.java
(original)
+++ maven/doxia/doxia/trunk/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/SinkFactory.java
Sun Nov  9 09:04:22 2008
@@ -21,7 +21,7 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.io.Writer;
+import java.io.OutputStream;
 
 /**
  * A factory that creates a <code>Sink</code> object.
@@ -36,25 +36,24 @@
     String ROLE = SinkFactory.class.getName();
 
     /**
-     * Create a <code>Sink</code> into a file using an UTF-8 encoding.
+     * Create a <code>Sink</code> into a file.
      *
      * @param outputDir the not-null output dir.
      * @param outputName the not-null output name.
-     * @return a <code>Sink</code> instance with a file as output and using UTF-8
as encoding.
+     * @return a <code>Sink</code> instance with a file as output.
      * @throws IOException if any
      */
     Sink createSink( File outputDir, String outputName )
         throws IOException;
 
     /**
-     * Create a <code>Sink</code> into a file using an UTF-8 encoding.
+     * Create a <code>Sink</code> into a file using a specified encoding.
      *
      * @param outputDir the not-null output dir.
      * @param outputName the not-null output name.
-     * @param encoding the output encoding (not used anymore).
-     * @return a <code>Sink</code> instance with a file as output and using UTF-8
as encoding.
+     * @param encoding the output encoding.
+     * @return a <code>Sink</code> instance with a file as output and using specified
encoding.
      * @throws IOException if any
-     * @deprecated since 1.0-beta-1, the encoding parameter has no effect, always use the
UTF-8 encoding.
      * @see #createSink(File, String)
      * @since 1.0-beta-1
      */
@@ -62,12 +61,23 @@
         throws IOException;
 
     /**
-     * Create a <code>Sink</code> into a Writer.
+     * Create a <code>Sink</code> into an OutputStream.
      *
-     * @param writer not null writer to write the result. <b>Should</b> be an
UTF-8 Writer.
-     * You could use wrapper methods from {@link org.codehaus.plexus.util.WriterFactory}.
+     * @param out not null OutputStream to write the result.
      * @return a <code>Sink</code> instance.
      * @since 1.0-beta-1
      */
-    Sink createSink( Writer writer );
+    Sink createSink( OutputStream out )
+        throws IOException;
+
+    /**
+     * Create a <code>Sink</code> into an OutputStream using a specified encoding.
+     *
+     * @param out not null OutputStream to write the result.
+     * @param encoding the output encoding.
+     * @return a <code>Sink</code> instance using specified encoding.
+     * @since 1.0-beta-1
+     */
+    Sink createSink( OutputStream out, String encoding )
+        throws IOException;
 }



Mime
View raw message