maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vsive...@apache.org
Subject svn commit: r693840 - in /maven/doxia/doxia-tools/trunk/doxia-converter/src: main/java/org/apache/maven/doxia/ main/java/org/apache/maven/doxia/cli/ main/java/org/apache/maven/doxia/wrapper/ test/java/org/apache/maven/doxia/
Date Wed, 10 Sep 2008 13:22:19 GMT
Author: vsiveton
Date: Wed Sep 10 06:22:19 2008
New Revision: 693840

URL: http://svn.apache.org/viewvc?rev=693840&view=rev
Log:
o added input/output encoding for the cli

Modified:
    maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/DefaultConverter.java
    maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/cli/CLIManager.java
    maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/cli/ConverterCli.java
    maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/AbstractFileWrapper.java
    maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/InputFileWrapper.java
    maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/OutputFileWrapper.java
    maven/doxia/doxia-tools/trunk/doxia-converter/src/test/java/org/apache/maven/doxia/ConverterTest.java

Modified: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/DefaultConverter.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/DefaultConverter.java?rev=693840&r1=693839&r2=693840&view=diff
==============================================================================
--- maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/DefaultConverter.java
(original)
+++ maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/DefaultConverter.java
Wed Sep 10 06:22:19 2008
@@ -22,7 +22,6 @@
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.Reader;
-import java.io.StringWriter;
 import java.io.Writer;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -68,9 +67,6 @@
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.WriterFactory;
 
-import com.ibm.icu.text.CharsetDetector;
-import com.ibm.icu.text.CharsetMatch;
-
 /**
  * Default implementation of <code>Converter</code>
  *
@@ -209,7 +205,7 @@
 
             if ( input.getFile().isFile() )
             {
-                parse( input.getFile(), output, parser );
+                parse( input.getFile(), input.getEncoding(), output, parser );
             }
             else
             {
@@ -228,7 +224,7 @@
                 {
                     File f = (File) it.next();
 
-                    parse( f, output, parser );
+                    parse( f, input.getEncoding(), output, parser );
                 }
             }
         }
@@ -425,19 +421,21 @@
     }
 
     /**
-     * @param inputFile
-     * @param output
-     * @param parser
+     * @param inputFile not null
+     * @param inputEncoding could be null
+     * @param output not null
+     * @param parser not null
      * @throws ConverterException if any
      */
-    private void parse( File inputFile, OutputFileWrapper output, Parser parser )
+    private void parse( File inputFile, String inputEncoding, OutputFileWrapper output, Parser
parser )
         throws ConverterException
     {
         if ( getLog().isDebugEnabled() )
         {
             getLog().debug(
-                            "Parsing file from '" + inputFile.getAbsolutePath() + "' to '"
-                                + output.getFile().getAbsolutePath() + "'" );
+                            "Parsing file from '" + inputFile.getAbsolutePath() + "' with
the encoding '"
+                                + inputEncoding + "' to '" + output.getFile().getAbsolutePath()
+                                + "' with the encoding '" + output.getEncoding() + "'" );
         }
 
         File outputFile;
@@ -466,29 +464,13 @@
         {
             is = new FileInputStream( inputFile );
 
-            StringWriter w = new StringWriter();
-            IOUtil.copy( is, w );
-            String content = w.toString();
-
-            if ( content.startsWith( "<?xml" ) )
+            if ( inputEncoding != null )
             {
-                reader = ReaderFactory.newXmlReader( inputFile );
+                reader = ReaderFactory.newReader( inputFile, inputEncoding );
             }
             else
             {
-                CharsetDetector detector = new CharsetDetector();
-                detector.setText( content.getBytes() );
-                CharsetMatch match = detector.detect();
-
-                String detectedInputEncoding = match.getName().toUpperCase( Locale.ENGLISH
);
-                if ( detectedInputEncoding != null )
-                {
-                    reader = ReaderFactory.newReader( inputFile, detectedInputEncoding );
-                }
-                else
-                {
-                    reader = ReaderFactory.newPlatformReader( inputFile );
-                }
+                reader = ReaderFactory.newPlatformReader( inputFile );
             }
         }
         catch ( IOException e )
@@ -503,13 +485,23 @@
         Writer writer;
         try
         {
+            String outputEncoding;
+            if ( StringUtils.isEmpty( output.getEncoding() ) )
+            {
+                outputEncoding = inputEncoding;
+            }
+            else
+            {
+                outputEncoding = output.getEncoding();
+            }
+
             if ( parser.getType() == Parser.XML_TYPE )
             {
                 writer = WriterFactory.newXmlWriter( outputFile );
             }
             else
             {
-                writer = WriterFactory.newPlatformWriter( outputFile );
+                writer = WriterFactory.newWriter( outputFile, outputEncoding );
             }
         }
         catch ( IOException e )

Modified: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/cli/CLIManager.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/cli/CLIManager.java?rev=693840&r1=693839&r2=693840&view=diff
==============================================================================
--- maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/cli/CLIManager.java
(original)
+++ maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/cli/CLIManager.java
Wed Sep 10 06:22:19 2008
@@ -57,6 +57,12 @@
     /** to String */
     public static final String TO = "to";
 
+    /** inEncoding String */
+    public static final String INENCODING = "inEncoding";
+
+    /** outEncoding String */
+    public static final String OUTENCODING = "outEncoding";
+
     /** X character */
     public static final char DEBUG = 'X';
 
@@ -76,10 +82,16 @@
 
         options.addOption( OptionBuilder.withLongOpt( "input" ).withDescription( "Input file
or directory" ).hasArg()
             .create( IN ) );
-        options.addOption( OptionBuilder.withLongOpt( "output" ).withDescription( "Output
directory" ).hasArg()
+        options.addOption( OptionBuilder.withLongOpt( "output" ).withDescription( "Output
file or directory" ).hasArg()
             .create( OUT ) );
         options.addOption( OptionBuilder.withDescription( "From format" ).hasArg().create(
FROM ) );
         options.addOption( OptionBuilder.withDescription( "To format" ).hasArg().create(
TO ) );
+        options.addOption( OptionBuilder.withLongOpt( "inputEncoding" ).withDescription(
"Input file encoding. " +
+                "If not specified, autodetect the input encoding." )
+            .hasArg().create( INENCODING ) );
+        options.addOption( OptionBuilder.withLongOpt( "outputEncoding" ).withDescription(
"Output file encoding. " +
+                "If not specified, use the input encoding (or detected)." )
+            .hasArg().create( OUTENCODING ) );
 
         options.addOption( OptionBuilder.withLongOpt( "debug" ).withDescription( "Produce
execution debug output" )
             .create( DEBUG ) );
@@ -107,8 +119,8 @@
         System.out.println();
 
         HelpFormatter formatter = new HelpFormatter();
-        formatter.printHelp( "doxia [options] [-in <arg>] [-from <arg>] [-out
<arg>] [-to <arg>]\n", "\nOptions:",
-                             options, getSupportedFormat() );
+        formatter.printHelp( "doxia [options] [-in <arg>] [-from <arg>] [-inEncoding
<arg>] [-out <arg>] "
+            + "[-to <arg>] [-outEncoding <arg>]\n", "\nOptions:", options, getSupportedFormat()
);
     }
 
     protected static void displaySupportedFormat()

Modified: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/cli/ConverterCli.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/cli/ConverterCli.java?rev=693840&r1=693839&r2=693840&view=diff
==============================================================================
--- maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/cli/ConverterCli.java
(original)
+++ maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/cli/ConverterCli.java
Wed Sep 10 06:22:19 2008
@@ -129,9 +129,11 @@
         try
         {
             input = InputFileWrapper.valueOf( commandLine.getOptionValue( CLIManager.IN ),
commandLine
-                .getOptionValue( CLIManager.FROM ), converter.getInputFormats() );
+                .getOptionValue( CLIManager.FROM ), commandLine.getOptionValue( CLIManager.INENCODING
), converter
+                .getInputFormats() );
             output = OutputFileWrapper.valueOf( commandLine.getOptionValue( CLIManager.OUT
), commandLine
-                .getOptionValue( CLIManager.TO ), converter.getOutputFormats() );
+                .getOptionValue( CLIManager.TO ), commandLine.getOptionValue( CLIManager.OUTENCODING
), converter
+                .getOutputFormats() );
         }
         catch ( IllegalArgumentException e )
         {

Modified: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/AbstractFileWrapper.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/AbstractFileWrapper.java?rev=693840&r1=693839&r2=693840&view=diff
==============================================================================
--- maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/AbstractFileWrapper.java
(original)
+++ maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/AbstractFileWrapper.java
Wed Sep 10 06:22:19 2008
@@ -19,7 +19,24 @@
  * under the License.
  */
 
+import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
+import java.util.Locale;
+
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.ReaderFactory;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.XmlStreamReader;
+
+import com.ibm.icu.text.CharsetDetector;
+import com.ibm.icu.text.CharsetMatch;
 
 /**
  * Abstract File wrapper for Doxia converter.
@@ -32,6 +49,8 @@
 {
     private File file;
 
+    private String encoding;
+
     /**
      * @return the file
      */
@@ -48,6 +67,91 @@
         this.file = file;
     }
 
+    /**
+     * @return the encoding used for the file or <code>null</code> if not specified.
+     */
+    public String getEncoding()
+    {
+        return encoding;
+    }
+
+    /**
+     * @param encoding new encoding.
+     */
+    void setEncoding( String encoding )
+    {
+        this.encoding = encoding;
+    }
+
+    /**
+     * Validate if a charset is supported on this platform.
+     *
+     * @param charsetName the charsetName to be checked.
+     * @return <code>true</code> if the charset is supported by the JVM, <code>false</code>
otherwise.
+     */
+    static boolean validateEncoding( String charsetName )
+    {
+        if ( StringUtils.isEmpty( charsetName ) )
+        {
+            return false;
+        }
+
+        OutputStream ost = new ByteArrayOutputStream();
+        OutputStreamWriter osw = null;
+        try
+        {
+            osw = new OutputStreamWriter( ost, charsetName );
+        }
+        catch ( UnsupportedEncodingException exc )
+        {
+            return false;
+        }
+        finally
+        {
+            IOUtil.close( osw );
+        }
+        return true;
+    }
+
+    /**
+     * @param f not null
+     * @return the detected encoding from f or <code>null</code> if an IOException
occurred.
+     */
+    static String autoDetectEncoding( File f )
+    {
+        Reader reader = null;
+        FileInputStream is = null;
+        try
+        {
+            is = new FileInputStream( f );
+
+            StringWriter w = new StringWriter();
+            IOUtil.copy( is, w );
+            String content = w.toString();
+
+            if ( content.startsWith( "<?xml" ) )
+            {
+                reader = ReaderFactory.newXmlReader( f );
+                return ((XmlStreamReader)reader).getEncoding();
+            }
+
+            CharsetDetector detector = new CharsetDetector();
+            detector.setText( w.toString().getBytes() );
+            CharsetMatch match = detector.detect();
+
+            return match.getName().toUpperCase( Locale.ENGLISH );
+        }
+        catch ( IOException e )
+        {
+            return null;
+        }
+        finally
+        {
+            IOUtil.close( reader );
+            IOUtil.close( is );
+        }
+    }
+
     /** {@inheritDoc} */
     public boolean equals( Object other )
     {

Modified: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/InputFileWrapper.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/InputFileWrapper.java?rev=693840&r1=693839&r2=693840&view=diff
==============================================================================
--- maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/InputFileWrapper.java
(original)
+++ maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/InputFileWrapper.java
Wed Sep 10 06:22:19 2008
@@ -25,6 +25,8 @@
 import org.apache.maven.doxia.util.FormatUtils;
 import org.codehaus.plexus.util.StringUtils;
 
+import com.ibm.icu.text.CharsetDetector;
+
 /**
  * Wrapper for an input file.
  *
@@ -40,37 +42,61 @@
     /**
      * Private constructor.
      *
-     * @param file
-     * @param format
-     * @param supportedFormat
+     * @param file not null
+     * @param format not null
+     * @param charsetName could be null
+     * @param supportedFormat not null
      */
-    private InputFileWrapper( File file, String format, String[] supportedFormat )
+    private InputFileWrapper( File file, String format, String charsetName, String[] supportedFormat
)
     {
         setFile( file );
         setFormat( format );
+        setEncoding( charsetName );
         setSupportedFormat( supportedFormat );
     }
 
     /**
      * @param absolutePath not null
      * @param format not null
+     * @param charsetName could be null
      * @param supportedFormat not null
      * @return a type safe input reader
      * @throws IllegalArgumentException if any
      * @throws UnsupportedFormatException if any
      * @see FormatUtils#getSupportedFormat(String, String, String[])
      */
-    public static InputFileWrapper valueOf( String absolutePath, String format, String[]
supportedFormat )
+    public static InputFileWrapper valueOf( String absolutePath, String format, String charsetName,
String[] supportedFormat )
         throws UnsupportedFormatException
     {
         if ( StringUtils.isEmpty( absolutePath ) )
         {
             throw new IllegalArgumentException( "absolutePath is required" );
         }
+        if ( StringUtils.isNotEmpty( charsetName ) && !validateEncoding( charsetName
) )
+        {
+            StringBuffer msg = new StringBuffer();
+            msg.append( "The encoding '" + charsetName + "' is not a valid. The supported
charsets are: " );
+            msg.append( StringUtils.join( CharsetDetector.getAllDetectableCharsets(), ",
" ) );
+            throw new IllegalArgumentException( msg.toString() );
+        }
 
         File file = new File( absolutePath );
+        if ( !file.isAbsolute() )
+        {
+            file = new File( new File( "" ).getAbsolutePath(), absolutePath );
+        }
+
+        String encoding;
+        if ( StringUtils.isNotEmpty( charsetName ) )
+        {
+            encoding = charsetName;
+        }
+        else
+        {
+            encoding = autoDetectEncoding( file );
+        }
 
         return new InputFileWrapper( file, FormatUtils.getSupportedFormat( file.getAbsolutePath(),
format,
-                                                                           supportedFormat
), supportedFormat );
+                                                                           supportedFormat
), encoding, supportedFormat );
     }
 }

Modified: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/OutputFileWrapper.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/OutputFileWrapper.java?rev=693840&r1=693839&r2=693840&view=diff
==============================================================================
--- maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/OutputFileWrapper.java
(original)
+++ maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/OutputFileWrapper.java
Wed Sep 10 06:22:19 2008
@@ -25,6 +25,8 @@
 import org.apache.maven.doxia.util.FormatUtils;
 import org.codehaus.plexus.util.StringUtils;
 
+import com.ibm.icu.text.CharsetDetector;
+
 /**
  * Wrapper for an output file.
  *
@@ -42,35 +44,51 @@
      *
      * @param file
      * @param format
+     * @param charsetName could be null
      * @param supportedFormat
      */
-    private OutputFileWrapper( File file, String format, String[] supportedFormat )
+    private OutputFileWrapper( File file, String format, String charsetName, String[] supportedFormat
)
     {
         setFile( file );
         setFormat( format );
+        setEncoding( charsetName );
         setSupportedFormat( supportedFormat );
     }
 
     /**
      * @param absolutePath not null
      * @param format not null
+     * @param charsetName could be null
      * @param supportedFormat not null
      * @return a type safe output writer
      * @throws IllegalArgumentException if any
      * @throws UnsupportedFormatException if any
      * @see FormatUtils#getSupportedFormat(String, String, String[])
      */
-    public static OutputFileWrapper valueOf( String absolutePath, String format, String[]
supportedFormat )
+    public static OutputFileWrapper valueOf( String absolutePath, String format, String charsetName,
String[] supportedFormat )
         throws UnsupportedFormatException
     {
         if ( StringUtils.isEmpty( absolutePath ) )
         {
             throw new IllegalArgumentException( "absolutePath is required" );
         }
+        if ( StringUtils.isNotEmpty( charsetName ) && !validateEncoding( charsetName
) )
+        {
+            StringBuffer msg = new StringBuffer();
+            msg.append( "The encoding '" + charsetName + "' is not a valid. The supported
charsets are: " );
+            msg.append( StringUtils.join( CharsetDetector.getAllDetectableCharsets(), ",
" ) );
+            throw new IllegalArgumentException( msg.toString() );
+        }
 
         File file = new File( absolutePath );
 
+        if ( !file.isAbsolute() )
+        {
+            file = new File( new File( "" ).getAbsolutePath(), absolutePath );
+        }
+
         return new OutputFileWrapper( file, FormatUtils.getSupportedFormat( file.getAbsolutePath(),
format,
-                                                                            supportedFormat
), supportedFormat );
+                                                                            supportedFormat
), charsetName,
+                                      supportedFormat );
     }
 }

Modified: maven/doxia/doxia-tools/trunk/doxia-converter/src/test/java/org/apache/maven/doxia/ConverterTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-tools/trunk/doxia-converter/src/test/java/org/apache/maven/doxia/ConverterTest.java?rev=693840&r1=693839&r2=693840&view=diff
==============================================================================
--- maven/doxia/doxia-tools/trunk/doxia-converter/src/test/java/org/apache/maven/doxia/ConverterTest.java
(original)
+++ maven/doxia/doxia-tools/trunk/doxia-converter/src/test/java/org/apache/maven/doxia/ConverterTest.java
Wed Sep 10 06:22:19 2008
@@ -31,6 +31,8 @@
 import org.codehaus.plexus.PlexusTestCase;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.ReaderFactory;
+import org.codehaus.plexus.util.WriterFactory;
 
 /**
  * Tests Doxia converter.
@@ -91,8 +93,8 @@
         String out = getBasedir() + "/target/unit/";
         String to = "apt";
 
-        InputFileWrapper input = InputFileWrapper.valueOf( in, from, converter.getInputFormats()
);
-        OutputFileWrapper output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats()
);
+        InputFileWrapper input = InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8,
converter.getInputFormats() );
+        OutputFileWrapper output = OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8,
converter.getOutputFormats() );
 
         converter.convert( input, output );
         assertTrue( new File( out, "Doxia.htm.apt" ).exists() );
@@ -114,8 +116,8 @@
         String out = getBasedir() + "/target/unit/Doxia.apt";
         String to = "apt";
 
-        InputFileWrapper input = InputFileWrapper.valueOf( in, from, converter.getInputFormats()
);
-        OutputFileWrapper output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats()
);
+        InputFileWrapper input = InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8,
converter.getInputFormats() );
+        OutputFileWrapper output = OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8,
converter.getOutputFormats() );
 
         converter.convert( input, output );
         assertTrue( new File( out ).exists() );
@@ -137,8 +139,8 @@
         String out = getBasedir() + "/target/unit/file/apt/test.apt.xhtml";
         String to = "xhtml";
 
-        InputFileWrapper input = InputFileWrapper.valueOf( in, from, converter.getInputFormats()
);
-        OutputFileWrapper output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats()
);
+        InputFileWrapper input = InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8,
converter.getInputFormats() );
+        OutputFileWrapper output = OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8,
converter.getOutputFormats() );
 
         converter.convert( input, output );
         assertTrue( new File( out ).exists() );
@@ -148,8 +150,8 @@
         out = getBasedir() + "/target/unit/file/apt/test.apt";
         to = "apt";
 
-        input = InputFileWrapper.valueOf( in, from, converter.getInputFormats() );
-        output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
+        input = InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8, converter.getInputFormats()
);
+        output = OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8, converter.getOutputFormats()
);
 
         converter.convert( input, output );
         assertTrue( new File( out ).exists() );
@@ -169,8 +171,8 @@
         String out = getBasedir() + "/target/unit/file/confluence/test.confluence.xhtml";
         String to = "xhtml";
 
-        InputFileWrapper input = InputFileWrapper.valueOf( in, from, converter.getInputFormats()
);
-        OutputFileWrapper output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats()
);
+        InputFileWrapper input = InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8,
converter.getInputFormats() );
+        OutputFileWrapper output = OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8,
converter.getOutputFormats() );
 
         converter.convert( input, output );
         assertTrue( new File( out ).exists() );
@@ -182,8 +184,8 @@
 
         try
         {
-            input = InputFileWrapper.valueOf( in, from, converter.getInputFormats() );
-            output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
+            input = InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8, converter.getInputFormats()
);
+            output = OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8, converter.getOutputFormats()
);
 
             converter.convert( input, output );
 
@@ -209,8 +211,8 @@
         String out = getBasedir() + "/target/unit/file/docbook/test.docbook.xhtml";
         String to = "xhtml";
 
-        InputFileWrapper input = InputFileWrapper.valueOf( in, from, converter.getInputFormats()
);
-        OutputFileWrapper output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats()
);
+        InputFileWrapper input = InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8,
converter.getInputFormats() );
+        OutputFileWrapper output = OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8,
converter.getOutputFormats() );
 
         converter.convert( input, output );
         assertTrue( new File( out ).exists() );
@@ -242,8 +244,8 @@
         String out = getBasedir() + "/target/unit/file/fml/test.fml.xhtml";
         String to = "xhtml";
 
-        InputFileWrapper input = InputFileWrapper.valueOf( in, from, converter.getInputFormats()
);
-        OutputFileWrapper output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats()
);
+        InputFileWrapper input = InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8,
converter.getInputFormats() );
+        OutputFileWrapper output = OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8,
converter.getOutputFormats() );
 
         converter.convert( input, output );
         assertTrue( new File( out ).exists() );
@@ -255,8 +257,8 @@
 
         try
         {
-            input = InputFileWrapper.valueOf( in, from, converter.getInputFormats() );
-            output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
+            input = InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8, converter.getInputFormats()
);
+            output = OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8, converter.getOutputFormats()
);
 
             converter.convert( input, output );
 
@@ -282,8 +284,8 @@
         String out = getBasedir() + "/target/unit/file/twiki/test.twiki.xhtml";
         String to = "xhtml";
 
-        InputFileWrapper input = InputFileWrapper.valueOf( in, from, converter.getInputFormats()
);
-        OutputFileWrapper output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats()
);
+        InputFileWrapper input = InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8,
converter.getInputFormats() );
+        OutputFileWrapper output = OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8,
converter.getOutputFormats() );
 
         converter.convert( input, output );
         assertTrue( new File( out ).exists() );
@@ -295,8 +297,8 @@
 
         try
         {
-            input = InputFileWrapper.valueOf( in, from, converter.getInputFormats() );
-            output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
+            input = InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8, converter.getInputFormats()
);
+            output = OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8, converter.getOutputFormats()
);
 
             converter.convert( input, output );
 
@@ -322,8 +324,8 @@
         String out = getBasedir() + "/target/unit/file/xdoc/test.xdoc.xhtml";
         String to = "xhtml";
 
-        InputFileWrapper input = InputFileWrapper.valueOf( in, from, converter.getInputFormats()
);
-        OutputFileWrapper output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats()
);
+        InputFileWrapper input = InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8,
converter.getInputFormats() );
+        OutputFileWrapper output = OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8,
converter.getOutputFormats() );
 
         converter.convert( input, output );
         assertTrue( new File( out ).exists() );
@@ -333,8 +335,8 @@
         out = getBasedir() + "/target/unit/file/xdoc/test.xdoc";
         to = "xdoc";
 
-        input = InputFileWrapper.valueOf( in, from, converter.getInputFormats() );
-        output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
+        input = InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8, converter.getInputFormats()
);
+        output = OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8, converter.getOutputFormats()
);
 
         converter.convert( input, output );
         assertTrue( new File( out ).exists() );
@@ -354,8 +356,8 @@
         String out = getBasedir() + "/target/unit/file/xhtml/test.xhtml.xhtml";
         String to = "xhtml";
 
-        InputFileWrapper input = InputFileWrapper.valueOf( in, from, converter.getInputFormats()
);
-        OutputFileWrapper output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats()
);
+        InputFileWrapper input = InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8,
converter.getInputFormats() );
+        OutputFileWrapper output = OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8,
converter.getOutputFormats() );
 
         converter.convert( input, output );
         assertTrue( new File( out ).exists() );
@@ -365,8 +367,8 @@
         out = getBasedir() + "/target/unit/file/xhtml/test.xhtml";
         to = "xhtml";
 
-        input = InputFileWrapper.valueOf( in, from, converter.getInputFormats() );
-        output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
+        input = InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8, converter.getInputFormats()
);
+        output = OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8, converter.getOutputFormats()
);
 
         converter.convert( input, output );
         assertTrue( new File( out ).exists() );



Mime
View raw message