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 2009/02/04 12:57:34 UTC
svn commit: r740705 - in
/maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book:
./ context/ services/renderer/ services/renderer/xdoc/
Author: vsiveton
Date: Wed Feb 4 11:57:33 2009
New Revision: 740705
URL: http://svn.apache.org/viewvc?rev=740705&view=rev
Log:
o add more parameters: locale and input/output encoding
o fixed I18N todo
Modified:
maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/BookDoxia.java
maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/BookDoxiaCli.java
maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/DefaultBookDoxia.java
maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/context/BookContext.java
maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/AbstractITextBookRenderer.java
maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/DocbookBookRenderer.java
maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/LatexBookRenderer.java
maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/XHtmlBookRenderer.java
maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/XdocBookRenderer.java
maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xdoc/AbstractXdocBookSink.java
maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xdoc/ChapterXdocBookSink.java
maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xdoc/IndexXdocBookSink.java
maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xdoc/SectionXdocBookSink.java
Modified: maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/BookDoxia.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/BookDoxia.java?rev=740705&r1=740704&r2=740705&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/BookDoxia.java (original)
+++ maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/BookDoxia.java Wed Feb 4 11:57:33 2009
@@ -23,6 +23,7 @@
import java.io.File;
import java.util.List;
+import java.util.Locale;
/**
* An interface to create books in different output formats from a book descriptor.
@@ -46,14 +47,32 @@
throws BookDoxiaException;
/**
- * Creates a book from a BookModel.
+ * Creates a book from a BookModel using the {@link Locale#getDefault()} and UTF-8 as default encoding.
*
* @param book the BookModel.
* @param bookRendererId the id of the output format.
* @param files a list of source files.
* @param outputDirectory the output directory.
* @throws BookDoxiaException if the model cannot be loaded.
+ * @see {@link #renderBook(BookModel, String, List, File, String, String, String)}
+ * @see {@link Locale#getDefault()}
*/
void renderBook( BookModel book, String bookRendererId, List files, File outputDirectory )
throws BookDoxiaException;
+
+ /**
+ * Creates a book from a BookModel.
+ *
+ * @param book the BookModel.
+ * @param bookRendererId the id of the output format.
+ * @param files a list of source files.
+ * @param outputDirectory the output directory.
+ * @param locale the wanted locale.
+ * @param inputEncoding the input encoding when processing {@link files}.
+ * @param outputEncoding the output encoding when writing files in {@link ouputDirectory}.
+ * @throws BookDoxiaException if the model cannot be loaded.
+ */
+ void renderBook( BookModel book, String bookRendererId, List files, File outputDirectory, Locale locale,
+ String inputEncoding, String outputEncoding )
+ throws BookDoxiaException;
}
Modified: maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/BookDoxiaCli.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/BookDoxiaCli.java?rev=740705&r1=740704&r2=740705&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/BookDoxiaCli.java (original)
+++ maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/BookDoxiaCli.java Wed Feb 4 11:57:33 2009
@@ -27,9 +27,12 @@
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.tools.cli.AbstractCli;
import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.ReaderFactory;
+import org.codehaus.plexus.util.WriterFactory;
import java.io.File;
import java.util.List;
+import java.util.Locale;
/**
* Invoke BookDoxia from the command line.
@@ -76,6 +79,18 @@
"The full path of the wanted output directory" ).isRequired()
.create( 'o' ) );
+ options.addOption( OptionBuilder.withLongOpt( "locale" ).hasArg().withDescription(
+ "The wanted locale" )
+ .create( 'l' ) );
+
+ options.addOption( OptionBuilder.withLongOpt( "inputEncoding" ).hasArg().withDescription(
+ "The input encoding" )
+ .create( "inEncoding" ) );
+
+ options.addOption( OptionBuilder.withLongOpt( "outputEncoding" ).hasArg().withDescription(
+ "The output encoding" )
+ .create( "outEncoding" ) );
+
return options;
}
@@ -118,7 +133,11 @@
}
BookModel book = doxia.loadBook( book1 );
- doxia.renderBook( book, "xdoc", files, new File( output ) );
+ String locale = cli.getOptionValue( "locale", Locale.getDefault().toString() );
+ String inEncoding = cli.getOptionValue( "inEncoding", ReaderFactory.UTF_8 );
+ String outEncoding = cli.getOptionValue( "outEncoding", WriterFactory.UTF_8 );
+
+ doxia.renderBook( book, "xdoc", files, new File( output ), new Locale( locale ), inEncoding, outEncoding );
}
/** {@inheritDoc} */
Modified: maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/DefaultBookDoxia.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/DefaultBookDoxia.java?rev=740705&r1=740704&r2=740705&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/DefaultBookDoxia.java (original)
+++ maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/DefaultBookDoxia.java Wed Feb 4 11:57:33 2009
@@ -31,6 +31,7 @@
import java.io.File;
import java.util.Collections;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Set;
@@ -80,6 +81,14 @@
public void renderBook( BookModel book, String bookRendererId, List files, File outputDirectory )
throws BookDoxiaException
{
+ renderBook( book, bookRendererId, files, outputDirectory, Locale.getDefault(), "UTF-8", "UTF-8" );
+ }
+
+ /** {@inheritDoc} */
+ public void renderBook( BookModel book, String bookRendererId, List files, File outputDirectory, Locale locale,
+ String inputEncoding, String outputEncoding )
+ throws BookDoxiaException
+ {
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
@@ -101,6 +110,12 @@
context.setOutputDirectory( outputDirectory );
+ context.setLocale( locale );
+
+ context.setInputEncoding( inputEncoding );
+
+ context.setOutputEncoding( outputEncoding );
+
// -----------------------------------------------------------------------
//
// -----------------------------------------------------------------------
Modified: maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/context/BookContext.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/context/BookContext.java?rev=740705&r1=740704&r2=740705&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/context/BookContext.java (original)
+++ maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/context/BookContext.java Wed Feb 4 11:57:33 2009
@@ -22,6 +22,7 @@
import org.apache.maven.doxia.book.model.BookModel;
import java.io.File;
+import java.util.Locale;
import java.util.Map;
import java.util.HashMap;
@@ -45,6 +46,15 @@
/** The BookIndex of this context. */
private BookIndex index;
+ /** The Locale used to generate the navigation. */
+ private Locale locale;
+
+ /** The input encoding used to read Doxia file. */
+ private String inputEncoding;
+
+ /** The output encoding used to write the renderer files. */
+ private String outputEncoding;
+
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
@@ -179,4 +189,52 @@
{
this.index = index;
}
+
+ /**
+ * @return the locale
+ */
+ public Locale getLocale()
+ {
+ return locale;
+ }
+
+ /**
+ * @param locale the locale to set
+ */
+ public void setLocale( Locale locale )
+ {
+ this.locale = locale;
+ }
+
+ /**
+ * @return the inputEncoding
+ */
+ public String getInputEncoding()
+ {
+ return inputEncoding;
+ }
+
+ /**
+ * @param inputEncoding the inputEncoding to set
+ */
+ public void setInputEncoding( String inputEncoding )
+ {
+ this.inputEncoding = inputEncoding;
+ }
+
+ /**
+ * @return the outputEncoding
+ */
+ public String getOutputEncoding()
+ {
+ return outputEncoding;
+ }
+
+ /**
+ * @param outputEncoding the outputEncoding to set
+ */
+ public void setOutputEncoding( String outputEncoding )
+ {
+ this.outputEncoding = outputEncoding;
+ }
}
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=740705&r1=740704&r2=740705&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 Wed Feb 4 11:57:33 2009
@@ -21,8 +21,8 @@
import java.io.File;
import java.io.FileNotFoundException;
-import java.io.FileReader;
import java.io.IOException;
+import java.io.Reader;
import java.io.Writer;
import java.text.DateFormat;
import java.util.ArrayList;
@@ -42,6 +42,7 @@
import org.apache.maven.doxia.parser.manager.ParserNotFoundException;
import org.apache.maven.doxia.sink.Sink;
import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.WriterFactory;
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
@@ -251,14 +252,14 @@
Sink itextSink = new ITextSinkFactory().createSink( writer );
List pipeline = new ArrayList();
- // pipeline.add( DebugSink.newInstance() );
pipeline.add( itextSink );
Sink sink = PipelineSink.newInstance( pipeline );
+ Reader reader = null;
try
{
- // TODO: fix encoding while reading the file (platform encoding used actually)
- doxia.parse( new FileReader( bookFile.getFile() ), bookFile.getParserId(), sink );
+ reader = ReaderFactory.newReader( bookFile.getFile(), context.getInputEncoding() );
+ doxia.parse( reader, bookFile.getParserId(), sink );
}
catch ( ParserNotFoundException e )
{
@@ -274,8 +275,11 @@
{
throw new BookDoxiaException( "Could not find document: " + bookFile.getFile().getAbsolutePath() + ".", e );
}
-
- // writer.endElement(); // section
+ catch ( IOException e )
+ {
+ throw new BookDoxiaException( "Error while rendering book: "
+ + bookFile.getFile().getAbsolutePath() + ".", e );
+ }
}
/**
Modified: maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/DocbookBookRenderer.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/DocbookBookRenderer.java?rev=740705&r1=740704&r2=740705&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/DocbookBookRenderer.java (original)
+++ maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/DocbookBookRenderer.java Wed Feb 4 11:57:33 2009
@@ -21,7 +21,6 @@
import java.io.File;
import java.io.FileNotFoundException;
-import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
@@ -39,6 +38,7 @@
import org.apache.maven.doxia.sink.Sink;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.WriterFactory;
@@ -198,7 +198,7 @@
Reader reader = null;
try
{
- reader = new FileReader( bookFile.getFile() );
+ reader = ReaderFactory.newReader( bookFile.getFile(), context.getInputEncoding() );
doxia.parse( reader, bookFile.getParserId(), sink );
}
catch ( ParserNotFoundException e )
@@ -215,6 +215,11 @@
{
throw new BookDoxiaException( "Could not find document: " + bookFile.getFile().getAbsolutePath() + ".", e );
}
+ catch ( IOException e )
+ {
+ throw new BookDoxiaException( "Error while rendering book: "
+ + bookFile.getFile().getAbsolutePath() + ".", e );
+ }
finally
{
IOUtil.close( reader );
Modified: maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/LatexBookRenderer.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/LatexBookRenderer.java?rev=740705&r1=740704&r2=740705&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/LatexBookRenderer.java (original)
+++ maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/LatexBookRenderer.java Wed Feb 4 11:57:33 2009
@@ -28,16 +28,18 @@
import org.apache.maven.doxia.parser.manager.ParserNotFoundException;
import org.apache.maven.doxia.parser.ParseException;
import org.apache.maven.doxia.Doxia;
+import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.WriterFactory;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
-import java.io.FileReader;
import java.io.FileNotFoundException;
import java.io.Reader;
+import java.io.Writer;
import java.util.Iterator;
import java.util.Map;
import java.util.HashMap;
@@ -201,7 +203,7 @@
{
File file = new File( context.getOutputDirectory(), ( section.getId() + ".tex" ) );
- FileWriter writer = new FileWriter( file );
+ Writer writer = WriterFactory.newWriter( file, context.getOutputEncoding() );
LatexBookSink sink = new LatexBookSink( writer );
@@ -216,7 +218,7 @@
Reader reader = null;
try
{
- reader = new FileReader( bookFile.getFile() );
+ reader = ReaderFactory.newReader( bookFile.getFile(), context.getInputEncoding() );
doxia.parse( reader, bookFile.getParserId(), sink );
}
catch ( ParserNotFoundException e )
Modified: maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/XHtmlBookRenderer.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/XHtmlBookRenderer.java?rev=740705&r1=740704&r2=740705&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/XHtmlBookRenderer.java (original)
+++ maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/XHtmlBookRenderer.java Wed Feb 4 11:57:33 2009
@@ -31,10 +31,10 @@
import org.apache.maven.doxia.parser.ParseException;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.ReaderFactory;
import java.io.File;
import java.io.FileNotFoundException;
-import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
@@ -171,7 +171,7 @@
Reader reader = null;
try
{
- reader = new FileReader( bookFile.getFile() );
+ reader = ReaderFactory.newReader( bookFile.getFile(), context.getInputEncoding() );
doxia.parse( reader, bookFile.getParserId(), sink );
}
catch ( ParserNotFoundException e )
@@ -189,6 +189,11 @@
throw new BookDoxiaException( "Could not find document: "
+ bookFile.getFile().getAbsolutePath() + ".", e );
}
+ catch ( IOException e )
+ {
+ throw new BookDoxiaException( "Error while rendering book: "
+ + bookFile.getFile().getAbsolutePath() + ".", e );
+ }
finally
{
IOUtil.close( reader );
Modified: maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/XdocBookRenderer.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/XdocBookRenderer.java?rev=740705&r1=740704&r2=740705&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/XdocBookRenderer.java (original)
+++ maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/XdocBookRenderer.java Wed Feb 4 11:57:33 2009
@@ -21,7 +21,6 @@
import java.io.File;
import java.io.FileNotFoundException;
-import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
@@ -49,6 +48,7 @@
import org.codehaus.plexus.i18n.I18N;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.WriterFactory;
@@ -103,18 +103,18 @@
/**
* Gets a trimmed String for the given key from the resource bundle defined by Plexus.
*
+ * @param locale the locale used
* @param key the key for the desired string
- * @return the string for the given key
+ * @return the string for the given key and the given locale
*/
- protected String getString( String key )
+ protected String getString( Locale locale, String key )
{
if ( StringUtils.isEmpty( key ) )
{
throw new IllegalArgumentException( "The key cannot be empty" );
}
- // TODO Handle locale
- return i18n.getString( "book-renderer", Locale.getDefault(), key ).trim();
+ return i18n.getString( "book-renderer", locale, key ).trim();
}
// -----------------------------------------------------------------------
@@ -174,7 +174,7 @@
{
Writer writer = WriterFactory.newXmlWriter( index );
- XdocSink sink = new IndexXdocBookSink( writer, context.getIndex().getFirstEntry(), i18n );
+ XdocSink sink = new IndexXdocBookSink( writer, context.getIndex().getFirstEntry(), i18n, context.getLocale() );
try
{
@@ -185,7 +185,7 @@
sink.head();
sink.title();
- sink.text( book.getTitle() + " - " + getString( "toc" ) );
+ sink.text( book.getTitle() + " - " + getString( context.getLocale(), "toc" ) );
sink.title_();
sink.head_();
@@ -198,7 +198,7 @@
sink.section1();
sink.sectionTitle1();
- sink.text( book.getTitle() + " - " + getString( "toc" ) );
+ sink.text( book.getTitle() + " - " + getString( context.getLocale(), "toc" ) );
sink.sectionTitle1_();
sink.list();
@@ -309,7 +309,7 @@
try
{
- writeChapterIndex( index, chapter, chapterIndex );
+ writeChapterIndex( index, chapter, chapterIndex, context );
}
catch ( IOException e )
{
@@ -335,16 +335,17 @@
* Write a chapter index
*
* @param index the File.
+ * @param context the context.
* @param chapter the Chapter.
* @param chapterIndex the IndexEntry.
* @throws IOException if any.
*/
- private void writeChapterIndex( File index, Chapter chapter, IndexEntry chapterIndex )
+ private void writeChapterIndex( File index, Chapter chapter, IndexEntry chapterIndex, BookContext context )
throws IOException
{
Writer writer = WriterFactory.newXmlWriter( index );
- ChapterXdocBookSink sink = new ChapterXdocBookSink( writer, chapterIndex, i18n );
+ ChapterXdocBookSink sink = new ChapterXdocBookSink( writer, chapterIndex, i18n, context.getLocale() );
try
{
@@ -408,7 +409,7 @@
{
Writer writer = WriterFactory.newXmlWriter( new File( context.getOutputDirectory() + "/" + section.getId() + ".xml" ) );
- SectionXdocBookSink sink = new SectionXdocBookSink( writer, sectionIndex, i18n );
+ SectionXdocBookSink sink = new SectionXdocBookSink( writer, sectionIndex, i18n, context.getLocale() );
BookContext.BookFile bookFile = (BookContext.BookFile) context.getFiles().get( section.getId() );
@@ -425,8 +426,8 @@
Reader reader = null;
try
{
- reader = new FileReader( bookFile.getFile() );
- doxia.parse( new FileReader( bookFile.getFile() ), bookFile.getParserId(), pipelineSink );
+ reader = ReaderFactory.newReader( bookFile.getFile(), context.getInputEncoding() );
+ doxia.parse( reader, bookFile.getParserId(), pipelineSink );
}
catch ( ParserNotFoundException e )
{
Modified: maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xdoc/AbstractXdocBookSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xdoc/AbstractXdocBookSink.java?rev=740705&r1=740704&r2=740705&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xdoc/AbstractXdocBookSink.java (original)
+++ maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xdoc/AbstractXdocBookSink.java Wed Feb 4 11:57:33 2009
@@ -39,19 +39,24 @@
extends XdocSink
{
/** I18N for localized messages. */
- private I18N i18n;
+ private final I18N i18n;
+
+ /** The wanted locale */
+ private final Locale locale;
/**
* Default constructor.
*
* @param out a Writer.
* @param i18n I18N.
+ * @param locale the wanted locale.
*/
- public AbstractXdocBookSink( Writer out, I18N i18n )
+ public AbstractXdocBookSink( Writer out, I18N i18n, Locale locale )
{
super( out );
this.i18n = i18n;
+ this.locale = locale;
}
/** {@inheritDoc} */
@@ -112,7 +117,7 @@
throw new IllegalArgumentException( "The key cannot be empty" );
}
- return i18n.getString( "book-renderer", Locale.getDefault(), key ).trim();
+ return i18n.getString( "book-renderer", locale, key ).trim();
}
/**
Modified: maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xdoc/ChapterXdocBookSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xdoc/ChapterXdocBookSink.java?rev=740705&r1=740704&r2=740705&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xdoc/ChapterXdocBookSink.java (original)
+++ maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xdoc/ChapterXdocBookSink.java Wed Feb 4 11:57:33 2009
@@ -20,6 +20,7 @@
*/
import java.io.Writer;
+import java.util.Locale;
import org.apache.maven.doxia.index.IndexEntry;
import org.codehaus.plexus.i18n.I18N;
@@ -34,7 +35,7 @@
extends AbstractXdocBookSink
{
/** the chapter IndexEntry. */
- private IndexEntry chapterIndex;
+ private final IndexEntry chapterIndex;
/**
* Default constructor.
@@ -42,10 +43,11 @@
* @param out the Writer.
* @param chapterIndex the chapter IndexEntry.
* @param i18n I18N.
+ * @param locale wanted locale.
*/
- public ChapterXdocBookSink( Writer out, IndexEntry chapterIndex, I18N i18n )
+ public ChapterXdocBookSink( Writer out, IndexEntry chapterIndex, I18N i18n, Locale locale )
{
- super( out, i18n );
+ super( out, i18n, locale );
this.chapterIndex = chapterIndex;
}
Modified: maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xdoc/IndexXdocBookSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xdoc/IndexXdocBookSink.java?rev=740705&r1=740704&r2=740705&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xdoc/IndexXdocBookSink.java (original)
+++ maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xdoc/IndexXdocBookSink.java Wed Feb 4 11:57:33 2009
@@ -20,6 +20,7 @@
*/
import java.io.Writer;
+import java.util.Locale;
import org.apache.maven.doxia.index.IndexEntry;
import org.codehaus.plexus.i18n.I18N;
@@ -35,7 +36,7 @@
extends AbstractXdocBookSink
{
/** the first IndexEntry. */
- private IndexEntry firstEntry;
+ private final IndexEntry firstEntry;
/**
* Default constructor.
@@ -43,10 +44,11 @@
* @param out the Writer.
* @param firstEntry the first IndexEntry.
* @param i18n I18N.
+ * @param locale wanted locale.
*/
- public IndexXdocBookSink( Writer out, IndexEntry firstEntry, I18N i18n )
+ public IndexXdocBookSink( Writer out, IndexEntry firstEntry, I18N i18n, Locale locale )
{
- super( out, i18n );
+ super( out, i18n, locale );
this.firstEntry = firstEntry;
}
Modified: maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xdoc/SectionXdocBookSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xdoc/SectionXdocBookSink.java?rev=740705&r1=740704&r2=740705&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xdoc/SectionXdocBookSink.java (original)
+++ maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xdoc/SectionXdocBookSink.java Wed Feb 4 11:57:33 2009
@@ -20,6 +20,7 @@
*/
import java.io.Writer;
+import java.util.Locale;
import org.apache.maven.doxia.index.IndexEntry;
import org.codehaus.plexus.i18n.I18N;
@@ -34,7 +35,7 @@
extends AbstractXdocBookSink
{
/** indexEntry. */
- private IndexEntry indexEntry;
+ private final IndexEntry indexEntry;
/**
* Default constructor.
@@ -42,10 +43,11 @@
* @param out the Writer to use.
* @param indexEntry the IndexEntry.
* @param i18n the I18N.
+ * @param locale wanted locale.
*/
- public SectionXdocBookSink( Writer out, IndexEntry indexEntry, I18N i18n )
+ public SectionXdocBookSink( Writer out, IndexEntry indexEntry, I18N i18n, Locale locale )
{
- super( out, i18n );
+ super( out, i18n, locale );
this.indexEntry = indexEntry;
}