You are viewing a plain text version of this content. The canonical link for it is here.
Posted to doxia-commits@maven.apache.org by vs...@apache.org on 2008/11/01 12:06:37 UTC
svn commit: r709673 - 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/util/
main/java/org/apache/maven/doxia/wrapper/ site/apt/ test/java/or...
Author: vsiveton
Date: Sat Nov 1 04:06:37 2008
New Revision: 709673
URL: http://svn.apache.org/viewvc?rev=709673&view=rev
Log:
o removed outencoding parameter since UTF-8 should be the default
o update test case and doc
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/util/ConverterUtil.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/main/java/org/apache/maven/doxia/wrapper/OutputWriterWrapper.java
maven/doxia/doxia-tools/trunk/doxia-converter/src/site/apt/index.apt
maven/doxia/doxia-tools/trunk/doxia-converter/src/site/apt/usage.apt
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=709673&r1=709672&r2=709673&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 Sat Nov 1 04:06:37 2008
@@ -378,18 +378,7 @@
Writer writer;
try
{
- String outputEncoding;
- if ( StringUtils.isEmpty( output.getEncoding() )
- || output.getEncoding().equals( OutputFileWrapper.AUTO_ENCODING ) )
- {
- outputEncoding = inputEncoding;
- }
- else
- {
- outputEncoding = output.getEncoding();
- }
-
- writer = WriterFactory.newWriter( outputFile, outputEncoding );
+ writer = WriterFactory.newWriter( outputFile, output.getEncoding() );
}
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=709673&r1=709672&r2=709673&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 Sat Nov 1 04:06:37 2008
@@ -62,9 +62,6 @@
/** inEncoding String */
static final String INENCODING = "inEncoding";
- /** outEncoding String */
- static final String OUTENCODING = "outEncoding";
-
/** X character */
static final char DEBUG = 'X';
@@ -94,11 +91,6 @@
"Input file encoding. "
+ "If not specified, try to autodetect it." )
.hasArg().create( INENCODING ) );
- options.addOption( OptionBuilder.withLongOpt( "outputEncoding" )
- .withDescription(
- "Output file encoding. If not specified, use the "
- + "input encoding (or autodetected)." ).hasArg()
- .create( OUTENCODING ) );
options.addOption( OptionBuilder.withLongOpt( "debug" )
.withDescription( "Produce execution debug output." ).create( DEBUG ) );
@@ -133,7 +125,7 @@
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp( "doxia [options] -in <arg> [-from <arg>] [-inEncoding <arg>] -out <arg> "
- + "-to <arg> [-outEncoding <arg>]\n", "\nOptions:", options, getSupportedFormatAndEncoding() );
+ + "-to <arg>\n", "\nOptions:", options, getSupportedFormatAndEncoding() );
}
private static String getSupportedFormatAndEncoding()
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=709673&r1=709672&r2=709673&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 Sat Nov 1 04:06:37 2008
@@ -130,12 +130,15 @@
OutputFileWrapper output;
try
{
- input = InputFileWrapper.valueOf( commandLine.getOptionValue( CLIManager.IN ), commandLine
- .getOptionValue( CLIManager.FROM ), commandLine.getOptionValue( CLIManager.INENCODING ), converter
- .getInputFormats() );
- output = OutputFileWrapper.valueOf( commandLine.getOptionValue( CLIManager.OUT ), commandLine
- .getOptionValue( CLIManager.TO ), commandLine.getOptionValue( CLIManager.OUTENCODING ), converter
- .getOutputFormats() );
+ input =
+ InputFileWrapper.valueOf( commandLine.getOptionValue( CLIManager.IN ),
+ commandLine.getOptionValue( CLIManager.FROM ),
+ commandLine.getOptionValue( CLIManager.INENCODING ),
+ converter.getInputFormats() );
+ output =
+ OutputFileWrapper.valueOf( commandLine.getOptionValue( CLIManager.OUT ),
+ commandLine.getOptionValue( CLIManager.TO ),
+ converter.getOutputFormats() );
}
catch ( IllegalArgumentException e )
{
Modified: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/util/ConverterUtil.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/util/ConverterUtil.java?rev=709673&r1=709672&r2=709673&view=diff
==============================================================================
--- maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/util/ConverterUtil.java (original)
+++ maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/util/ConverterUtil.java Sat Nov 1 04:06:37 2008
@@ -81,7 +81,9 @@
/**
* @param plexus not null
* @param format not null
- * @param writer could be null
+ * @param writer not null writer to write the result. <b>Should</b> be an UTF-8 Writer such as defines in
+ * {@link org.apache.maven.doxia.sink.Sink}. You could use <code>newWriter</code> methods from
+ * {@link org.codehaus.plexus.util.WriterFactory}.
* @param supportedFormats not null
* @return an instance of <code>Sink</code> depending on the given format.
* @throws ComponentLookupException if could not find the SinkFactory for the given format.
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=709673&r1=709672&r2=709673&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 Sat Nov 1 04:06:37 2008
@@ -41,15 +41,14 @@
*
* @param file not null
* @param format not null
- * @param charsetName could be null
* @param supportedFormat not null.
* @throws IllegalArgumentException if any.
* @throws UnsupportedEncodingException if the encoding is unsupported.
*/
- private OutputFileWrapper( String absolutePath, String format, String charsetName, String[] supportedFormat )
+ private OutputFileWrapper( String absolutePath, String format, String[] supportedFormat )
throws UnsupportedEncodingException
{
- super( absolutePath, format, charsetName, supportedFormat );
+ super( absolutePath, format, WriterFactory.UTF_8, supportedFormat );
if ( getFormat().equalsIgnoreCase( AUTO_FORMAT ) )
{
@@ -60,35 +59,28 @@
/**
* @param absolutePath not null
* @param format not null
- * @param charsetName could be null
* @param supportedFormat not null
- * @return a type safe output writer
+ * @return a type safe output writer using UTF-8 as encoding such as defines in
+ * {@link org.apache.maven.doxia.sink.Sink}.
* @throws IllegalArgumentException if any.
* @throws UnsupportedEncodingException if the encoding is unsupported.
*/
public static OutputFileWrapper valueOf( String absolutePath, String format, String[] supportedFormat )
throws IllegalArgumentException, UnsupportedEncodingException
{
- return valueOf( absolutePath, format, WriterFactory.UTF_8, supportedFormat );
+ if ( StringUtils.isEmpty( format ) )
+ {
+ throw new IllegalArgumentException( "output format is required" );
+ }
+ return new OutputFileWrapper( absolutePath, format, 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 UnsupportedEncodingException if the encoding is unsupported.
+ * @return always the encoding UTF-8 to be used for the file.
*/
- public static OutputFileWrapper valueOf( String absolutePath, String format, String charsetName,
- String[] supportedFormat )
- throws IllegalArgumentException, UnsupportedEncodingException
+ public String getEncoding()
{
- if ( StringUtils.isEmpty( format ) )
- {
- throw new IllegalArgumentException( "output format is required" );
- }
- return new OutputFileWrapper( absolutePath, format, charsetName, supportedFormat );
+ return WriterFactory.UTF_8;
}
}
Modified: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/OutputWriterWrapper.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/OutputWriterWrapper.java?rev=709673&r1=709672&r2=709673&view=diff
==============================================================================
--- maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/OutputWriterWrapper.java (original)
+++ maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/OutputWriterWrapper.java Sat Nov 1 04:06:37 2008
@@ -41,6 +41,9 @@
/**
* Private constructor.
*
+ * @param writer not null writer to write the result. <b>Should</b> be an UTF-8 Writer such as defines in
+ * {@link org.apache.maven.doxia.sink.Sink}. You could use <code>newWriter</code> methods from
+ * {@link org.codehaus.plexus.util.WriterFactory}.
* @param format not null
* @param supportedFormat not null
* @throws IllegalArgumentException if any.
@@ -58,7 +61,8 @@
}
/**
- * @return the writer
+ * @return the writer. <b>Should</b> be an UTF-8 Writer such as defines in
+ * {@link org.apache.maven.doxia.sink.Sink}.
*/
public Writer getWriter()
{
@@ -66,7 +70,9 @@
}
/**
- * @param writer not null
+ * @param writer not null writer to write the result. <b>Should</b> be an UTF-8 Writer such as defines in
+ * {@link org.apache.maven.doxia.sink.Sink}. You could use <code>newWriter</code> methods from
+ * {@link org.codehaus.plexus.util.WriterFactory}.
* @param format not null
* @param supportedFormat not null
* @return a type safe output writer
Modified: maven/doxia/doxia-tools/trunk/doxia-converter/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-tools/trunk/doxia-converter/src/site/apt/index.apt?rev=709673&r1=709672&r2=709673&view=diff
==============================================================================
--- maven/doxia/doxia-tools/trunk/doxia-converter/src/site/apt/index.apt (original)
+++ maven/doxia/doxia-tools/trunk/doxia-converter/src/site/apt/index.apt Sat Nov 1 04:06:37 2008
@@ -3,7 +3,7 @@
-----
Vincent Siveton
------
- March 2007
+ 2008-11-01
------
~~ Licensed to the Apache Software Foundation (ASF) under one
@@ -28,16 +28,18 @@
Maven Doxia Converter
- Doxia Converter is a tool that help you to convert a supported Doxia format to another supported Doxia format.
+ Doxia Converter is a tool that help you to convert a supported Doxia format to another supported Doxia format.
- Actually, the supported formats are:
+ Actually, the supported Doxia formats are:
- * input format: apt, confluence, docbook, fml, twiki, xdoc, xhtml
+ * input format: apt, confluence, docbook, fml, twiki, xdoc, xhtml or autodetect
- * output format: apt, docbook, fo, itext, latex, rtf, xdoc, xhtml
+ * output format: apt, confluence, docbook, fo, itext, latex, rtf, twiki, xdoc, xhtml
- []
+ []
+
+ <<Note>>: The tool supports encoding to read files, but all generated files are in UTF-8.
* Usage
- Instructions on how to use the Doxia Converter can be found {{{usage.html}here}}.
+ Instructions on how to use the Doxia Converter can be found {{{usage.html}here}}.
Modified: maven/doxia/doxia-tools/trunk/doxia-converter/src/site/apt/usage.apt
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-tools/trunk/doxia-converter/src/site/apt/usage.apt?rev=709673&r1=709672&r2=709673&view=diff
==============================================================================
--- maven/doxia/doxia-tools/trunk/doxia-converter/src/site/apt/usage.apt (original)
+++ maven/doxia/doxia-tools/trunk/doxia-converter/src/site/apt/usage.apt Sat Nov 1 04:06:37 2008
@@ -36,7 +36,7 @@
# java -jar target/apache-doxia-1.0-SNAPSHOT-jar-with-dependencies.jar -h
usage: doxia [options] -in <arg> [-from <arg>] [-inEncoding <arg>] -out
- <arg> -to <arg> [-outEncoding <arg>]
+ <arg> -to
Options:
-e,--errors Produce execution error messages
@@ -46,8 +46,6 @@
-inEncoding,--inputEncoding <arg> Input file encoding. If not
specified, autodetect the input encoding.
-out,--output <arg> Output file or directory
- -outEncoding,--outputEncoding <arg> Output file encoding. If not
- specified, use the input encoding (or detected).
-to <arg> To format
-v,--version Display version information
-X,--debug Produce execution debug output
@@ -88,7 +86,7 @@
Converter converter = new DefaultConverter();
try
{
- InputFileWrapper input = InputFileWrapper.valueOf( in, from, converter.getInputFormats() );
+ InputFileWrapper input = InputFileWrapper.valueOf( in, from, "ISO-8859-1", converter.getInputFormats() );
OutputFileWrapper output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
converter.convert( input, output );
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=709673&r1=709672&r2=709673&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 Sat Nov 1 04:06:37 2008
@@ -34,7 +34,6 @@
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.
@@ -98,7 +97,7 @@
InputFileWrapper input =
InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8, converter.getInputFormats() );
OutputFileWrapper output =
- OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8, converter.getOutputFormats() );
+ OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
converter.convert( input, output );
assertTrue( new File( out, "Doxia.htm.apt" ).exists() );
@@ -124,7 +123,7 @@
InputFileWrapper input =
InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8, converter.getInputFormats() );
OutputFileWrapper output =
- OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8, converter.getOutputFormats() );
+ OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
converter.convert( input, output );
assertTrue( new File( out ).exists() );
@@ -150,7 +149,7 @@
InputFileWrapper input =
InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8, converter.getInputFormats() );
OutputFileWrapper output =
- OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8, converter.getOutputFormats() );
+ OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
converter.convert( input, output );
assertTrue( new File( out ).exists() );
@@ -162,7 +161,7 @@
to = "apt";
input = InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8, converter.getInputFormats() );
- output = OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8, converter.getOutputFormats() );
+ output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
converter.convert( input, output );
assertTrue( new File( out ).exists() );
@@ -186,7 +185,7 @@
InputFileWrapper input =
InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8, converter.getInputFormats() );
OutputFileWrapper output =
- OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8, converter.getOutputFormats() );
+ OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
converter.convert( input, output );
assertTrue( new File( out ).exists() );
@@ -198,7 +197,7 @@
to = "confluence";
input = InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8, converter.getInputFormats() );
- output = OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8, converter.getOutputFormats() );
+ output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
converter.convert( input, output );
}
@@ -220,7 +219,7 @@
InputFileWrapper input =
InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8, converter.getInputFormats() );
OutputFileWrapper output =
- OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8, converter.getOutputFormats() );
+ OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
converter.convert( input, output );
assertTrue( new File( out ).exists() );
@@ -256,7 +255,7 @@
InputFileWrapper input =
InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8, converter.getInputFormats() );
OutputFileWrapper output =
- OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8, converter.getOutputFormats() );
+ OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
converter.convert( input, output );
assertTrue( new File( out ).exists() );
@@ -270,7 +269,7 @@
try
{
input = InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8, converter.getInputFormats() );
- output = OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8, converter.getOutputFormats() );
+ output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
converter.convert( input, output );
@@ -299,7 +298,7 @@
InputFileWrapper input =
InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8, converter.getInputFormats() );
OutputFileWrapper output =
- OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8, converter.getOutputFormats() );
+ OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
converter.convert( input, output );
assertTrue( new File( out ).exists() );
@@ -311,7 +310,7 @@
to = "twiki";
input = InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8, converter.getInputFormats() );
- output = OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8, converter.getOutputFormats() );
+ output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
converter.convert( input, output );
}
@@ -333,7 +332,7 @@
InputFileWrapper input =
InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8, converter.getInputFormats() );
OutputFileWrapper output =
- OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8, converter.getOutputFormats() );
+ OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
converter.convert( input, output );
assertTrue( new File( out ).exists() );
@@ -345,7 +344,7 @@
to = "xdoc";
input = InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8, converter.getInputFormats() );
- output = OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8, converter.getOutputFormats() );
+ output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
converter.convert( input, output );
assertTrue( new File( out ).exists() );
@@ -369,7 +368,7 @@
InputFileWrapper input =
InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8, converter.getInputFormats() );
OutputFileWrapper output =
- OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8, converter.getOutputFormats() );
+ OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
converter.convert( input, output );
assertTrue( new File( out ).exists() );
@@ -381,7 +380,7 @@
to = "xhtml";
input = InputFileWrapper.valueOf( in, from, ReaderFactory.UTF_8, converter.getInputFormats() );
- output = OutputFileWrapper.valueOf( out, to, WriterFactory.UTF_8, converter.getOutputFormats() );
+ output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
converter.convert( input, output );
assertTrue( new File( out ).exists() );