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/03/12 01:34:43 UTC
svn commit: r636161 [1/2] - in
/maven/doxia/doxia-tools/trunk/doxia-converter: ./
src/main/java/org/apache/maven/doxia/
src/main/java/org/apache/maven/doxia/cli/
src/main/java/org/apache/maven/doxia/util/
src/main/java/org/apache/maven/doxia/wrapper/ s...
Author: vsiveton
Date: Tue Mar 11 17:34:40 2008
New Revision: 636161
URL: http://svn.apache.org/viewvc?rev=636161&view=rev
Log:
o replaced modello files to wrappers
o added more tests
o updated doc
Added:
maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/util/
maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/util/FormatUtils.java (with props)
maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/
maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/AbstractFileWrapper.java (with props)
maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/AbstractWrapper.java (with props)
maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/InputFileWrapper.java (with props)
maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/InputReaderWrapper.java (with props)
maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/OutputFileWrapper.java (with props)
maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/OutputWriterWrapper.java (with props)
maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/apt/
maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/apt/test.apt (with props)
maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/confluence/
maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/confluence/test.confluence
maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/docbook/
maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/docbook/test.xml (with props)
maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/fml/
maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/fml/test.fml (with props)
maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/twiki/
maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/twiki/test.twiki
maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/xdoc/
maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/xdoc/test.xml (with props)
maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/xhtml/
maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/xhtml/test.xhtml
Removed:
maven/doxia/doxia-tools/trunk/doxia-converter/src/main/mdo/
Modified:
maven/doxia/doxia-tools/trunk/doxia-converter/pom.xml
maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/Converter.java
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/ConverterCli.java
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/pom.xml
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-tools/trunk/doxia-converter/pom.xml?rev=636161&r1=636160&r2=636161&view=diff
==============================================================================
--- maven/doxia/doxia-tools/trunk/doxia-converter/pom.xml (original)
+++ maven/doxia/doxia-tools/trunk/doxia-converter/pom.xml Tue Mar 11 17:34:40 2008
@@ -132,23 +132,6 @@
<build>
<plugins>
<plugin>
- <groupId>org.codehaus.modello</groupId>
- <artifactId>modello-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>converter</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>java</goal>
- </goals>
- <configuration>
- <model>src/main/mdo/converter.mdo</model>
- <version>1.0.0</version>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-2</version>
<configuration>
Modified: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/Converter.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/Converter.java?rev=636161&r1=636160&r2=636161&view=diff
==============================================================================
--- maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/Converter.java (original)
+++ maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/Converter.java Tue Mar 11 17:34:40 2008
@@ -18,12 +18,14 @@
*/
package org.apache.maven.doxia;
-import org.apache.maven.doxia.convertor.model.InputFile;
-import org.apache.maven.doxia.convertor.model.OutputFile;
import org.apache.maven.doxia.logging.LogEnabled;
+import org.apache.maven.doxia.wrapper.InputFileWrapper;
+import org.apache.maven.doxia.wrapper.InputReaderWrapper;
+import org.apache.maven.doxia.wrapper.OutputFileWrapper;
+import org.apache.maven.doxia.wrapper.OutputWriterWrapper;
/**
- * Interface to convert a Doxia file to another one.
+ * Interface to convert a Doxia input wrapper to a Doxia output wrapper.
*
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
* @version $Id$
@@ -32,21 +34,30 @@
extends LogEnabled
{
/**
- * @return a not null array containing supported input format, i.e. <code>apt</code>.
+ * @return a not null array containing supported input formats, i.e. <code>apt</code>.
*/
String[] getInputFormats();
/**
- * @return a not null array containing supported input format, i.e. <code>xhtml</code>.
+ * @return a not null array containing supported output formats, i.e. <code>xhtml</code>.
*/
String[] getOutputFormats();
/**
- * @param input an input file, not null.
- * @param output an output file, not null.
+ * @param input an input file wrapper, not null.
+ * @param output an output file wrapper, not null.
* @throws UnsupportedFormatException if any
* @throws ConverterException if any
*/
- void convert( InputFile input, OutputFile output )
+ void convert( InputFileWrapper input, OutputFileWrapper output )
+ throws UnsupportedFormatException, ConverterException;
+
+ /**
+ * @param input an input reader wrapper, not null.
+ * @param output an output writer wrapper, not null.
+ * @throws UnsupportedFormatException if any
+ * @throws ConverterException if any
+ */
+ void convert( InputReaderWrapper input, OutputWriterWrapper output )
throws UnsupportedFormatException, ConverterException;
}
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=636161&r1=636160&r2=636161&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 Tue Mar 11 17:34:40 2008
@@ -19,18 +19,16 @@
package org.apache.maven.doxia;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
-import java.io.StringWriter;
import java.io.Writer;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.lang.ClassUtils;
-import org.apache.maven.doxia.convertor.model.InputFile;
-import org.apache.maven.doxia.convertor.model.OutputFile;
import org.apache.maven.doxia.logging.Log;
import org.apache.maven.doxia.logging.SystemStreamLog;
import org.apache.maven.doxia.module.apt.AptParser;
@@ -51,6 +49,10 @@
import org.apache.maven.doxia.parser.ParseException;
import org.apache.maven.doxia.parser.Parser;
import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.wrapper.InputFileWrapper;
+import org.apache.maven.doxia.wrapper.InputReaderWrapper;
+import org.apache.maven.doxia.wrapper.OutputFileWrapper;
+import org.apache.maven.doxia.wrapper.OutputWriterWrapper;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.SelectorUtils;
@@ -153,7 +155,7 @@
}
/** {@inheritDoc} */
- public void convert( InputFile input, OutputFile output )
+ public void convert( InputFileWrapper input, OutputFileWrapper output )
throws UnsupportedFormatException, ConverterException
{
if ( input == null )
@@ -172,17 +174,9 @@
getLog().debug( "Parser used: " + parser.getClass().getName() );
}
- StringWriter stringWriter = new StringWriter();
- Sink sink = getSink( output.getFormat(), stringWriter );
-
- if ( getLog().isDebugEnabled() )
- {
- getLog().debug( "Sink used: " + sink.getClass().getName() );
- }
-
if ( input.getFile().isFile() )
{
- parse( input.getFile(), output, parser, sink, stringWriter );
+ parse( input.getFile(), output, parser );
}
else
{
@@ -201,11 +195,59 @@
{
File f = (File) it.next();
- parse( f, output, parser, sink, stringWriter );
+ parse( f, output, parser );
}
}
}
+ /** {@inheritDoc} */
+ public void convert( InputReaderWrapper input, OutputWriterWrapper output )
+ throws UnsupportedFormatException, ConverterException
+ {
+ if ( input == null )
+ {
+ throw new IllegalArgumentException( "input is required" );
+ }
+ if ( output == null )
+ {
+ throw new IllegalArgumentException( "output is required" );
+ }
+
+ Parser parser = getParser( input.getFormat() );
+
+ if ( getLog().isDebugEnabled() )
+ {
+ getLog().debug( "Parser used: " + parser.getClass().getName() );
+ }
+
+ Sink sink = getSink( output.getFormat(), output.getWriter() );
+
+ if ( getLog().isDebugEnabled() )
+ {
+ getLog().debug( "Sink used: " + sink.getClass().getName() );
+ }
+
+ try
+ {
+ parser.parse( input.getReader(), sink );
+ }
+ catch ( ParseException e )
+ {
+ throw new ConverterException( "ParseException: " + e.getMessage(), e );
+ }
+ finally
+ {
+ IOUtil.close( input.getReader() );
+ sink.flush();
+ sink.close();
+ IOUtil.close( output.getWriter() );
+ }
+ }
+
+ // ----------------------------------------------------------------------
+ // Private methods
+ // ----------------------------------------------------------------------
+
/**
* @param clazz an implementation of <code>Parser</code> with the pattern <code><format>Parser</code>
* @return the parser format in lower case.
@@ -267,30 +309,31 @@
/**
* @param format
+ * @param writer
* @return an instance of <code>Sink</code> depending the format.
* @throws IllegalArgumentException if any
*/
- private static Sink getSink( String format, StringWriter stringWriter )
+ private static Sink getSink( String format, Writer writer )
{
if ( format.equals( APT_SINK ) )
{
- return new AptSink( stringWriter );
+ return new AptSink( writer );
}
else if ( format.equals( DOCBOOK_SINK ) )
{
- return new DocBookSink( stringWriter );
+ return new DocBookSink( writer );
}
else if ( format.equals( FO_SINK ) )
{
- return new FoSink( stringWriter );
+ return new FoSink( writer );
}
else if ( format.equals( ITEXT_SINK ) )
{
- return new ITextSink( stringWriter );
+ return new ITextSink( writer );
}
else if ( format.equals( LATEX_SINK ) )
{
- return new LatexSink( stringWriter );
+ return new LatexSink( writer );
}
else if ( format.equals( RTF_SINK ) )
{
@@ -299,11 +342,11 @@
}
else if ( format.equals( XDOC_SINK ) )
{
- return new XdocSink( stringWriter );
+ return new XdocSink( writer );
}
else if ( format.equals( XHTML_SINK ) )
{
- return new XhtmlSink( stringWriter );
+ return new XhtmlSink( writer );
}
throw new IllegalArgumentException( "Sink not found for: " + format );
@@ -313,72 +356,79 @@
* @param inputFile
* @param output
* @param parser
- * @param sink
- * @param stringWriter
* @throws ConverterException if any
*/
- private void parse( File inputFile, OutputFile output, Parser parser, Sink sink, StringWriter stringWriter )
+ private void parse( File inputFile, OutputFileWrapper output, Parser parser )
throws ConverterException
{
if ( getLog().isDebugEnabled() )
{
getLog().debug(
- "Parsing file from '" + inputFile.getAbsolutePath() + "' to '" + output.getAbsolutePath()
- + "'" );
+ "Parsing file from '" + inputFile.getAbsolutePath() + "' to '"
+ + output.getFile().getAbsolutePath() + "'" );
}
- Reader reader = null;
+ File outputFile;
+ if ( output.getFile().exists() && output.getFile().isDirectory() )
+ {
+ outputFile = new File( output.getFile(), inputFile.getName() + "." + output.getFormat() );
+ }
+ else
+ {
+ if ( !SelectorUtils.match( "**.*", output.getFile().getName() ) )
+ {
+ // assume it is a directory
+ output.getFile().mkdirs();
+ outputFile = new File( output.getFile(), inputFile.getName() + "." + output.getFormat() );
+ }
+ else
+ {
+ output.getFile().getParentFile().mkdirs();
+ outputFile = output.getFile();
+ }
+ }
+
+ Writer writer;
try
{
- reader = new FileReader( inputFile );
- parser.parse( reader, sink );
+ writer = new FileWriter( outputFile );
}
catch ( IOException e )
{
throw new ConverterException( "IOException: " + e.getMessage(), e );
}
- catch ( ParseException e )
+
+ Sink sink = getSink( output.getFormat(), writer );
+
+ if ( getLog().isDebugEnabled() )
{
- throw new ConverterException( "ParseException: " + e.getMessage(), e );
+ getLog().debug( "Sink used: " + sink.getClass().getName() );
}
- finally
+
+ Reader reader;
+ try
{
- IOUtil.close( reader );
+ reader = new FileReader( inputFile );
+ }
+ catch ( FileNotFoundException e )
+ {
+ throw new ConverterException( "IOException: " + e.getMessage(), e );
}
- Writer writer = null;
try
{
- if ( output.getFile().exists() && output.getFile().isDirectory() )
- {
- writer = new FileWriter( new File( output.getFile(), inputFile.getName() + "." + output.getFormat() ) );
- }
- else
- {
- if ( !SelectorUtils.match( "**.*", output.getFile().getName() ) )
- {
- // assume it is a directory
- output.getFile().mkdirs();
- writer = new FileWriter(
- new File( output.getFile(), inputFile.getName() + "." + output.getFormat() ) );
- }
- else
- {
- output.getFile().getParentFile().mkdirs();
- writer = new FileWriter( output.getFile() );
- }
- }
-
- IOUtil.copy( stringWriter.toString(), writer );
+ parser.parse( reader, sink );
}
- catch ( IOException e )
+ catch ( ParseException e )
{
- throw new ConverterException( "IOException: " + e.getMessage(), e );
+ throw new ConverterException( "ParseException: " + e.getMessage(), e );
}
finally
{
+ IOUtil.close( reader );
+ sink.flush();
+ sink.close();
IOUtil.close( writer );
- IOUtil.close( stringWriter );
}
}
}
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=636161&r1=636160&r2=636161&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 Tue Mar 11 17:34:40 2008
@@ -28,10 +28,10 @@
import org.apache.maven.doxia.ConverterException;
import org.apache.maven.doxia.DefaultConverter;
import org.apache.maven.doxia.UnsupportedFormatException;
-import org.apache.maven.doxia.convertor.model.InputFile;
-import org.apache.maven.doxia.convertor.model.OutputFile;
import org.apache.maven.doxia.logging.Log;
import org.apache.maven.doxia.logging.SystemStreamLog;
+import org.apache.maven.doxia.wrapper.InputFileWrapper;
+import org.apache.maven.doxia.wrapper.OutputFileWrapper;
import org.codehaus.plexus.util.Os;
/**
@@ -78,7 +78,6 @@
return 1;
}
- // TODO: maybe classworlds could handle this requirement...
if ( "1.4".compareTo( System.getProperty( "java.specification.version" ) ) > 0 )
{
System.err.println( "Sorry, but JDK 1.4 or above is required to execute Maven. You appear to be using "
@@ -125,13 +124,13 @@
}
converter.enableLogging( log );
- InputFile input;
- OutputFile output;
+ InputFileWrapper input;
+ OutputFileWrapper output;
try
{
- input = InputFile.valueOf( commandLine.getOptionValue( CLIManager.IN ), commandLine
+ input = InputFileWrapper.valueOf( commandLine.getOptionValue( CLIManager.IN ), commandLine
.getOptionValue( CLIManager.FROM ), converter.getInputFormats() );
- output = OutputFile.valueOf( commandLine.getOptionValue( CLIManager.OUT ), commandLine
+ output = OutputFileWrapper.valueOf( commandLine.getOptionValue( CLIManager.OUT ), commandLine
.getOptionValue( CLIManager.TO ), converter.getOutputFormats() );
}
catch ( IllegalArgumentException e )
Added: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/util/FormatUtils.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/util/FormatUtils.java?rev=636161&view=auto
==============================================================================
--- maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/util/FormatUtils.java (added)
+++ maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/util/FormatUtils.java Tue Mar 11 17:34:40 2008
@@ -0,0 +1,111 @@
+package org.apache.maven.doxia.util;
+
+/*
+ * 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 org.apache.maven.doxia.UnsupportedFormatException;
+import org.codehaus.plexus.util.SelectorUtils;
+import org.codehaus.plexus.util.StringUtils;
+
+/**
+ * Utility class to play with Doxia formats.
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ */
+public class FormatUtils
+{
+ /**
+ * @param from a supported format
+ * @param supportedFormat an array of supported formats in Doxia
+ * @return Doxia supported format for <code>from</code>
+ * @throws IllegalArgumentException if any
+ * @throws UnsupportedFormatException if any
+ */
+ public static String getSupportedFormat( String from, String[] supportedFormat )
+ throws UnsupportedFormatException
+ {
+ if ( supportedFormat == null )
+ {
+ throw new IllegalArgumentException( "supportedFormat is required" );
+ }
+
+ if ( StringUtils.isEmpty( from ) )
+ {
+ throw new IllegalArgumentException( "from is required" );
+ }
+
+ String fromFormat = from;
+ String supportedString = StringUtils.join( supportedFormat, ", " );
+ if ( supportedString.indexOf( fromFormat.toLowerCase() ) == -1 )
+ {
+ throw new UnsupportedFormatException( fromFormat, supportedFormat );
+ }
+
+ return fromFormat.toLowerCase();
+ }
+
+ /**
+ * @param absolutePath an absolute path
+ * @param from a supported format
+ * @param supportedFormat an array of supported formats in Doxia
+ * @return Doxia supported format for <code>from</code> or the extension of <code>in</code>
+ * @throws IllegalArgumentException if any
+ * @throws UnsupportedFormatException if any
+ */
+ public static String getSupportedFormat( String absolutePath, String from, String[] supportedFormat )
+ throws UnsupportedFormatException
+ {
+ if ( supportedFormat == null )
+ {
+ throw new IllegalArgumentException( "supportedFormat is required" );
+ }
+
+ String fromFormat = null;
+ if ( StringUtils.isEmpty( from ) )
+ {
+ if ( absolutePath == null || absolutePath.trim().length() == 0 )
+ {
+ throw new IllegalArgumentException( "absolutePath is required" );
+ }
+
+ // try to detect format
+ if ( SelectorUtils.match( "**.*", absolutePath ) )
+ {
+ fromFormat = absolutePath.substring( absolutePath.lastIndexOf( '.' ) + 1, absolutePath.length() );
+ }
+ else
+ {
+ throw new IllegalArgumentException( "'" + absolutePath + "' is directory: cannot detect the format" );
+ }
+ }
+ else
+ {
+ fromFormat = from;
+ }
+
+ String supportedString = StringUtils.join( supportedFormat, ", " );
+ if ( supportedString.indexOf( fromFormat.toLowerCase() ) == -1 )
+ {
+ throw new UnsupportedFormatException( fromFormat, supportedFormat );
+ }
+
+ return fromFormat.toLowerCase();
+ }
+}
Propchange: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/util/FormatUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/util/FormatUtils.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: 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=636161&view=auto
==============================================================================
--- maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/AbstractFileWrapper.java (added)
+++ maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/AbstractFileWrapper.java Tue Mar 11 17:34:40 2008
@@ -0,0 +1,87 @@
+package org.apache.maven.doxia.wrapper;
+
+/*
+ * 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;
+
+/**
+ * Abstract File wrapper for Doxia converter.
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ */
+public abstract class AbstractFileWrapper
+ extends AbstractWrapper
+{
+ private File file;
+
+ /**
+ * @return the file
+ */
+ public File getFile()
+ {
+ return file;
+ }
+
+ /**
+ * @param file new file.
+ */
+ void setFile( File file )
+ {
+ this.file = file;
+ }
+
+ /** {@inheritDoc} */
+ public boolean equals( Object other )
+ {
+ if ( this == other )
+ {
+ return true;
+ }
+
+ if ( !( other instanceof AbstractFileWrapper ) )
+ {
+ return false;
+ }
+
+ AbstractFileWrapper that = (AbstractFileWrapper) other;
+ boolean result = true;
+ result = result && super.equals( other );
+ result = result && ( getFile() == null ? that.getFile() == null : getFile().equals( that.getFile() ) );
+ return result;
+ }
+
+ /** {@inheritDoc} */
+ public int hashCode()
+ {
+ int result = super.hashCode();
+ result = 37 * result + ( getFile() != null ? getFile().hashCode() : 0 );
+ return result;
+ }
+
+ /** {@inheritDoc} */
+ public java.lang.String toString()
+ {
+ StringBuffer buf = new StringBuffer( super.toString() + "\n" );
+ buf.append( "file= '" );
+ buf.append( getFile() + "'" );
+ return buf.toString();
+ }
+}
Propchange: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/AbstractFileWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/AbstractFileWrapper.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/AbstractWrapper.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/AbstractWrapper.java?rev=636161&view=auto
==============================================================================
--- maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/AbstractWrapper.java (added)
+++ maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/AbstractWrapper.java Tue Mar 11 17:34:40 2008
@@ -0,0 +1,104 @@
+package org.apache.maven.doxia.wrapper;
+
+/*
+ * 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.Serializable;
+
+/**
+ * Abstract wrapper for Doxia converter.
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ */
+public abstract class AbstractWrapper
+ implements Serializable
+{
+ private String format;
+
+ private String[] supportedFormat;
+
+ /**
+ * @return the wanted format.
+ */
+ public String getFormat()
+ {
+ return this.format;
+ }
+
+ /**
+ * @param format The wanted format.
+ */
+ void setFormat( String format )
+ {
+ this.format = format;
+ }
+
+ /**
+ * @return the supportedFormat
+ */
+ public String[] getSupportedFormat()
+ {
+ return supportedFormat;
+ }
+
+ /**
+ * @param supportedFormat the supportedFormat to set
+ */
+ void setSupportedFormat( String[] supportedFormat )
+ {
+ this.supportedFormat = supportedFormat;
+ }
+
+ /** {@inheritDoc} */
+ public boolean equals( Object other )
+ {
+ if ( this == other )
+ {
+ return true;
+ }
+
+ if ( !( other instanceof AbstractWrapper ) )
+ {
+ return false;
+ }
+
+ AbstractWrapper that = (AbstractWrapper) other;
+ boolean result = true;
+ result = result && ( getFormat() == null ? that.getFormat() == null : getFormat().equals( that.getFormat() ) );
+ return result;
+ }
+
+ /** {@inheritDoc} */
+ public int hashCode()
+ {
+ int result = 17;
+ result = 37 * result + ( format != null ? format.hashCode() : 0 );
+ return result;
+ }
+
+ /** {@inheritDoc} */
+ public java.lang.String toString()
+ {
+ StringBuffer buf = new StringBuffer();
+ buf.append( "format = '" );
+ buf.append( getFormat() + "'" );
+ return buf.toString();
+ }
+}
Propchange: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/AbstractWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/AbstractWrapper.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: 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=636161&view=auto
==============================================================================
--- maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/InputFileWrapper.java (added)
+++ maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/InputFileWrapper.java Tue Mar 11 17:34:40 2008
@@ -0,0 +1,76 @@
+package org.apache.maven.doxia.wrapper;
+
+/*
+ * 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 org.apache.maven.doxia.UnsupportedFormatException;
+import org.apache.maven.doxia.util.FormatUtils;
+import org.codehaus.plexus.util.StringUtils;
+
+/**
+ * Wrapper for an input file.
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ */
+public class InputFileWrapper
+ extends AbstractFileWrapper
+{
+ /** serialVersionUID */
+ static final long serialVersionUID = 6510443036267371188L;
+
+ /**
+ * Private constructor.
+ *
+ * @param file
+ * @param format
+ * @param supportedFormat
+ */
+ private InputFileWrapper( File file, String format, String[] supportedFormat )
+ {
+ setFile( file );
+ setFormat( format );
+ setSupportedFormat( supportedFormat );
+ }
+
+ /**
+ * @param absolutePath not null
+ * @param format not 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 )
+ throws UnsupportedFormatException
+ {
+ if ( StringUtils.isEmpty( absolutePath ) )
+ {
+ throw new IllegalArgumentException( "absolutePath is required" );
+ }
+
+ File file = new File( absolutePath );
+
+ return new InputFileWrapper( file, FormatUtils.getSupportedFormat( file.getAbsolutePath(), format,
+ supportedFormat ), supportedFormat );
+ }
+}
Propchange: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/InputFileWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/InputFileWrapper.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/InputReaderWrapper.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/InputReaderWrapper.java?rev=636161&view=auto
==============================================================================
--- maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/InputReaderWrapper.java (added)
+++ maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/InputReaderWrapper.java Tue Mar 11 17:34:40 2008
@@ -0,0 +1,84 @@
+package org.apache.maven.doxia.wrapper;
+
+/*
+ * 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.Reader;
+
+import org.apache.maven.doxia.UnsupportedFormatException;
+import org.apache.maven.doxia.util.FormatUtils;
+
+/**
+ * Wrapper for an input reader.
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ */
+public class InputReaderWrapper
+ extends AbstractFileWrapper
+{
+ /** serialVersionUID */
+ static final long serialVersionUID = 3260213754615748766L;
+
+ private Reader reader;
+
+ /**
+ * Private constructor.
+ *
+ * @param format
+ * @param supportedFormat
+ */
+ private InputReaderWrapper( String format, String[] supportedFormat )
+ {
+ setFormat( format );
+ setSupportedFormat( supportedFormat );
+ }
+
+ /**
+ * @return the reader
+ */
+ public Reader getReader()
+ {
+ return this.reader;
+ }
+
+ /**
+ * @param reader not null
+ * @param format not null
+ * @param supportedFormat not null
+ * @return a type safe input reader
+ * @throws IllegalArgumentException if any
+ * @throws UnsupportedFormatException if any
+ * @see FormatUtils#getSupportedFormat(String, String[])
+ */
+ public static InputReaderWrapper valueOf( Reader reader, String format, String[] supportedFormat )
+ throws UnsupportedFormatException
+ {
+ if ( reader == null )
+ {
+ throw new IllegalArgumentException( "reader is required" );
+ }
+
+ InputReaderWrapper input = new InputReaderWrapper( FormatUtils.getSupportedFormat( format, supportedFormat ),
+ supportedFormat );
+ input.reader = reader;
+
+ return input;
+ }
+}
Propchange: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/InputReaderWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/InputReaderWrapper.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: 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=636161&view=auto
==============================================================================
--- maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/OutputFileWrapper.java (added)
+++ maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/OutputFileWrapper.java Tue Mar 11 17:34:40 2008
@@ -0,0 +1,76 @@
+package org.apache.maven.doxia.wrapper;
+
+/*
+ * 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 org.apache.maven.doxia.UnsupportedFormatException;
+import org.apache.maven.doxia.util.FormatUtils;
+import org.codehaus.plexus.util.StringUtils;
+
+/**
+ * Wrapper for an output file.
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ */
+public class OutputFileWrapper
+ extends AbstractFileWrapper
+{
+ /** serialVersionUID */
+ static final long serialVersionUID = 804499615902780116L;
+
+ /**
+ * Private constructor.
+ *
+ * @param file
+ * @param format
+ * @param supportedFormat
+ */
+ private OutputFileWrapper( File file, String format, String[] supportedFormat )
+ {
+ setFile( file );
+ setFormat( format );
+ setSupportedFormat( supportedFormat );
+ }
+
+ /**
+ * @param absolutePath not null
+ * @param format not 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 )
+ throws UnsupportedFormatException
+ {
+ if ( StringUtils.isEmpty( absolutePath ) )
+ {
+ throw new IllegalArgumentException( "absolutePath is required" );
+ }
+
+ File file = new File( absolutePath );
+
+ return new OutputFileWrapper( file, FormatUtils.getSupportedFormat( file.getAbsolutePath(), format,
+ supportedFormat ), supportedFormat );
+ }
+}
Propchange: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/OutputFileWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/OutputFileWrapper.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: 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=636161&view=auto
==============================================================================
--- maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/OutputWriterWrapper.java (added)
+++ maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/OutputWriterWrapper.java Tue Mar 11 17:34:40 2008
@@ -0,0 +1,85 @@
+package org.apache.maven.doxia.wrapper;
+
+/*
+ * 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.Writer;
+
+import org.apache.maven.doxia.UnsupportedFormatException;
+import org.apache.maven.doxia.util.FormatUtils;
+
+/**
+ * Wrapper for an output writer.
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ */
+public class OutputWriterWrapper
+ extends AbstractFileWrapper
+{
+ /** serialVersionUID */
+ static final long serialVersionUID = 3329037527245430610L;
+
+ private Writer writer;
+
+ /**
+ * Private constructor.
+ *
+ * @param format
+ * @param supportedFormat
+ */
+ private OutputWriterWrapper( String format, String[] supportedFormat )
+ {
+ setFormat( format );
+ setSupportedFormat( supportedFormat );
+ }
+
+ /**
+ * @return the writer
+ */
+ public Writer getWriter()
+ {
+ return this.writer;
+ }
+
+ /**
+ * @param writer not null
+ * @param format not null
+ * @param supportedFormat not null
+ * @return a type safe output writer
+ * @throws IllegalArgumentException if any
+ * @throws UnsupportedFormatException if any
+ * @see FormatUtils#getSupportedFormat(String, String[])
+ */
+ public static OutputWriterWrapper valueOf( Writer writer, String format, String[] supportedFormat )
+ throws UnsupportedFormatException
+ {
+ if ( writer == null )
+ {
+ throw new IllegalArgumentException( "writer is required" );
+ }
+
+ OutputWriterWrapper output = new OutputWriterWrapper(
+ FormatUtils.getSupportedFormat( format, supportedFormat ),
+ supportedFormat );
+ output.writer = writer;
+
+ return output;
+ }
+}
Propchange: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/OutputWriterWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/doxia/doxia-tools/trunk/doxia-converter/src/main/java/org/apache/maven/doxia/wrapper/OutputWriterWrapper.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
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=636161&r1=636160&r2=636161&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 Tue Mar 11 17:34:40 2008
@@ -77,8 +77,8 @@
Converter converter = new DefaultConverter();
try
{
- InputFile input = InputFile.valueOf( in, from, converter.getInputFormats() );
- OutputFile output = OutputFile.valueOf( out, to, converter.getOutputFormats() );
+ InputFileWrapper input = InputFileWrapper.valueOf( in, from, 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=636161&r1=636160&r2=636161&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 Tue Mar 11 17:34:40 2008
@@ -1,3 +1,5 @@
+package org.apache.maven.doxia;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -16,16 +18,23 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.maven.doxia;
import java.io.File;
-
-import org.apache.maven.doxia.convertor.model.InputFile;
-import org.apache.maven.doxia.convertor.model.OutputFile;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.StringWriter;
+
+import org.apache.maven.doxia.wrapper.InputFileWrapper;
+import org.apache.maven.doxia.wrapper.InputReaderWrapper;
+import org.apache.maven.doxia.wrapper.OutputFileWrapper;
+import org.apache.maven.doxia.wrapper.OutputWriterWrapper;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
/**
+ * Tests Doxia converter.
+ *
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
* @version $Id$
*/
@@ -43,6 +52,15 @@
converter = new DefaultConverter();
}
+ /** {@inheritDoc} */
+ protected void tearDown()
+ throws Exception
+ {
+ super.tearDown();
+
+ converter = null;
+ }
+
/**
* @see Converter#getInputFormats()
*/
@@ -60,10 +78,12 @@
}
/**
- * @see Converter#convert(InputFile, OutputFile)
- * @throws Exception
+ * Input file / output dir
+ *
+ * @see Converter#convert(InputFileWrapper, OutputFileWrapper)
+ * @throws Exception if any
*/
- public void testConvert()
+ public void testFileConverterWithInputFileOutputDir()
throws Exception
{
String in = getBasedir() + "/src/test/resources/unit/Doxia.htm";
@@ -71,60 +91,353 @@
String out = getBasedir() + "/target/unit/";
String to = "apt";
- InputFile input = InputFile.valueOf( in, from, converter.getInputFormats() );
- OutputFile output = OutputFile.valueOf( out, to, converter.getOutputFormats() );
+ InputFileWrapper input = InputFileWrapper.valueOf( in, from, converter.getInputFormats() );
+ OutputFileWrapper output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
converter.convert( input, output );
assertTrue( new File( out, "Doxia.htm.apt" ).exists() );
- // ----------------------------------------------------------------------
+ FileUtils.deleteDirectory( new File( getBasedir() + "/target/unit/" ) );
+ }
+
+ /**
+ * Input file / output file
+ *
+ * @see Converter#convert(InputFileWrapper, OutputFileWrapper)
+ * @throws Exception if any
+ */
+ public void testFileConverterWithInputFileOutputFile()
+ throws Exception
+ {
+ String in = getBasedir() + "/src/test/resources/unit/Doxia.htm";
+ String from = "xhtml";
+ 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() );
+
+ converter.convert( input, output );
+ assertTrue( new File( out ).exists() );
FileUtils.deleteDirectory( new File( getBasedir() + "/target/unit/" ) );
+ }
+
+ /**
+ * Input apt file / output file
+ *
+ * @see Converter#convert(InputFileWrapper, OutputFileWrapper)
+ * @throws Exception if any
+ */
+ public void testAptFileConverter()
+ throws Exception
+ {
+ String in = getBasedir() + "/src/test/resources/unit/apt/test.apt";
+ String from = "apt";
+ 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() );
+
+ converter.convert( input, output );
+ assertTrue( new File( out ).exists() );
+
+ //TODO
+ // in = getBasedir() + "/target/unit/file/apt/test.apt.xhtml";
+ // from = "xhtml";
+ // out = getBasedir() + "/target/unit/file/apt/test.apt";
+ // to = "apt";
+ //
+ // input = InputFileWrapper.valueOf( in, from, converter.getInputFormats() );
+ // output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
+ //
+ // converter.convert( input, output );
+ // assertTrue( new File( out ).exists() );
+ }
+
+ /**
+ * Input confluence file / output file
+ *
+ * @see Converter#convert(InputFileWrapper, OutputFileWrapper)
+ * @throws Exception if any
+ */
+ public void testConfluenceFileConverter()
+ throws Exception
+ {
+ String in = getBasedir() + "/src/test/resources/unit/confluence/test.confluence";
+ String from = "confluence";
+ 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() );
+
+ converter.convert( input, output );
+ assertTrue( new File( out ).exists() );
- in = getBasedir() + "/src/test/resources/unit/Doxia.htm";
+ in = getBasedir() + "/target/unit/file/confluence/test.confluence.xhtml";
from = "xhtml";
- out = getBasedir() + "/target/unit/Doxia.apt";
- to = "apt";
+ out = getBasedir() + "/target/unit/file/confluence/test.confluence";
+ to = "confluence";
+
+ try
+ {
+ input = InputFileWrapper.valueOf( in, from, converter.getInputFormats() );
+ output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
+
+ converter.convert( input, output );
+
+ assertFalse( true );
+ }
+ catch ( UnsupportedFormatException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ /**
+ * Input docbook file / output file
+ *
+ * @see Converter#convert(InputFileWrapper, OutputFileWrapper)
+ * @throws Exception if any
+ */
+ public void testDocbookFileConverter()
+ throws Exception
+ {
+ String in = getBasedir() + "/src/test/resources/unit/docbook/test.xml";
+ String from = "docbook";
+ String out = getBasedir() + "/target/unit/file/docbook/test.docbook.xhtml";
+ String to = "xhtml";
- input = InputFile.valueOf( in, from, converter.getInputFormats() );
- output = OutputFile.valueOf( out, to, converter.getOutputFormats() );
+ InputFileWrapper input = InputFileWrapper.valueOf( in, from, converter.getInputFormats() );
+ OutputFileWrapper output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
converter.convert( input, output );
assertTrue( new File( out ).exists() );
- // ----------------------------------------------------------------------
+ // TODO
+ // in = getBasedir() + "/target/unit/file/docbook/test.docbook.xhtml";
+ // from = "xhtml";
+ // out = getBasedir() + "/target/unit/file/docbook/test.docbook";
+ // to = "docbook";
+ //
+ // input = InputFileWrapper.valueOf( in, from, converter.getInputFormats() );
+ // output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
+ //
+ // converter.convert( input, output );
+ // assertTrue( new File( out ).exists() );
+ }
- FileUtils.deleteDirectory( new File( getBasedir() + "/target/unit/" ) );
+ /**
+ * Input fml dir / output dir
+ *
+ * @see Converter#convert(InputFileWrapper, OutputFileWrapper)
+ * @throws Exception if any
+ */
+ public void testFmlFileConverter()
+ throws Exception
+ {
+ String in = getBasedir() + "/src/test/resources/unit/fml/test.fml";
+ String from = "fml";
+ String out = getBasedir() + "/target/unit/file/fml/test.fml.xhtml";
+ String to = "xhtml";
- FileUtils.copyFile( new File( in ), new File( getBasedir(), "/target/unit/Doxia.xhtml" ) );
+ InputFileWrapper input = InputFileWrapper.valueOf( in, from, converter.getInputFormats() );
+ OutputFileWrapper output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
- in = getBasedir() + "/target/unit/Doxia.xhtml";
- from = null;
- out = getBasedir() + "/target/unit/Doxia.apt";
- to = "apt";
+ converter.convert( input, output );
+ assertTrue( new File( out ).exists() );
+
+ in = getBasedir() + "/target/unit/file/fml/test.fml.xhtml";
+ from = "xhtml";
+ out = getBasedir() + "/target/unit/file/fml/test.fml";
+ to = "fml";
- input = InputFile.valueOf( in, from, converter.getInputFormats() );
- output = OutputFile.valueOf( out, to, converter.getOutputFormats() );
+ try
+ {
+ input = InputFileWrapper.valueOf( in, from, converter.getInputFormats() );
+ output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
+
+ converter.convert( input, output );
+
+ assertFalse( true );
+ }
+ catch ( UnsupportedFormatException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ /**
+ * Input twiki file / output file
+ *
+ * @see Converter#convert(InputFileWrapper, OutputFileWrapper)
+ * @throws Exception if any
+ */
+ public void testTwikiFileConverter()
+ throws Exception
+ {
+ String in = getBasedir() + "/src/test/resources/unit/twiki/test.twiki";
+ String from = "twiki";
+ 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() );
converter.convert( input, output );
assertTrue( new File( out ).exists() );
- // ----------------------------------------------------------------------
+ in = getBasedir() + "/target/unit/file/twiki/test.twiki.xhtml";
+ from = "xhtml";
+ out = getBasedir() + "/target/unit/file/twiki/test.twiki";
+ to = "twiki";
- FileUtils.deleteDirectory( new File( getBasedir() + "/target/unit/" ) );
+ try
+ {
+ input = InputFileWrapper.valueOf( in, from, converter.getInputFormats() );
+ output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
+
+ converter.convert( input, output );
+
+ assertFalse( true );
+ }
+ catch ( UnsupportedFormatException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ /**
+ * Input xdoc file / output dir
+ *
+ * @see Converter#convert(InputFileWrapper, OutputFileWrapper)
+ * @throws Exception if any
+ */
+ public void testXdocFileConverter()
+ throws Exception
+ {
+ String in = getBasedir() + "/src/test/resources/unit/xdoc/test.xml";
+ String from = "xdoc";
+ 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() );
- FileUtils.copyFile( new File( getBasedir() + "/src/test/resources/unit/Doxia.htm" ),
- new File( getBasedir(), "/target/unit/Doxia.xhtml" ) );
+ converter.convert( input, output );
+ assertTrue( new File( out ).exists() );
- in = getBasedir() + "/target/unit/Doxia.xhtml";
- from = null;
- out = getBasedir() + "/target/unit/Doxia.apt";
- to = null;
+ in = getBasedir() + "/target/unit/file/xdoc/test.xdoc.xhtml";
+ from = "xhtml";
+ out = getBasedir() + "/target/unit/file/xdoc/test.xdoc";
+ to = "xdoc";
- input = InputFile.valueOf( in, from, converter.getInputFormats() );
- output = OutputFile.valueOf( out, to, converter.getOutputFormats() );
+ input = InputFileWrapper.valueOf( in, from, converter.getInputFormats() );
+ output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
converter.convert( input, output );
assertTrue( new File( out ).exists() );
+ }
+
+ /**
+ * Input xhtml file / output dir
+ *
+ * @see Converter#convert(InputFileWrapper, OutputFileWrapper)
+ * @throws Exception if any
+ */
+ public void testXhtmlFileConverter()
+ throws Exception
+ {
+ String in = getBasedir() + "/src/test/resources/unit/xhtml/test.xhtml";
+ String from = "xhtml";
+ 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() );
+
+ converter.convert( input, output );
+ assertTrue( new File( out ).exists() );
+
+ in = getBasedir() + "/target/unit/file/xhtml/test.xhtml.xhtml";
+ from = "xhtml";
+ out = getBasedir() + "/target/unit/file/xhtml/test.xhtml";
+ to = "xhtml";
+
+ input = InputFileWrapper.valueOf( in, from, converter.getInputFormats() );
+ output = OutputFileWrapper.valueOf( out, to, converter.getOutputFormats() );
+
+ converter.convert( input, output );
+ assertTrue( new File( out ).exists() );
+ }
+
+ /**
+ * Input apt reader / output writer
+ *
+ * @see Converter#convert(InputReaderWrapper, OutputWriterWrapper)
+ * @throws Exception if any
+ */
+ public void testAptWriterConverter()
+ throws Exception
+ {
+ String in = getBasedir() + "/src/test/resources/unit/apt/test.apt";
+ String from = "apt";
+ String out = getBasedir() + "/target/unit/writer/apt/test.apt.xhtml";
+ String to = "xhtml";
+
+ File inFile = new File( in );
+ File outFile = new File( out );
+ outFile.getParentFile().mkdirs();
+ FileWriter fw = new FileWriter( outFile );
+
+ StringWriter writer = new StringWriter();
+
+ InputReaderWrapper input = InputReaderWrapper.valueOf( new FileReader( inFile ), from, converter
+ .getInputFormats() );
+ OutputWriterWrapper output = OutputWriterWrapper.valueOf( writer, to, converter
+ .getOutputFormats() );
+
+ converter.convert( input, output );
+
+ IOUtil.copy( writer.toString(), fw );
+ IOUtil.close( fw );
+
+ assertTrue( outFile.exists() );
+ }
+
+ /**
+ * Input confluence reader / output writer
+ *
+ * @see Converter#convert(InputReaderWrapper, OutputWriterWrapper)
+ * @throws Exception if any
+ */
+ public void testConfluenceWriterConverter()
+ throws Exception
+ {
+ String in = getBasedir() + "/src/test/resources/unit/confluence/test.confluence";
+ String from = "confluence";
+ String out = getBasedir() + "/target/unit/writer/confluence/test.confluence.xhtml";
+ String to = "xhtml";
+
+ File inFile = new File( in );
+ File outFile = new File( out );
+ outFile.getParentFile().mkdirs();
+ FileWriter fw = new FileWriter( outFile );
+
+ StringWriter writer = new StringWriter();
+
+ InputReaderWrapper input = InputReaderWrapper.valueOf( new FileReader( inFile ), from, converter
+ .getInputFormats() );
+ OutputWriterWrapper output = OutputWriterWrapper.valueOf( new FileWriter( outFile ), to, converter
+ .getOutputFormats() );
+
+ converter.convert( input, output );
+
+ IOUtil.copy( writer.toString(), fw );
+ IOUtil.close( fw );
+
+ assertTrue( outFile.exists() );
}
}
Added: maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/apt/test.apt
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/apt/test.apt?rev=636161&view=auto
==============================================================================
--- maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/apt/test.apt (added)
+++ maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/apt/test.apt Tue Mar 11 17:34:40 2008
@@ -0,0 +1 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head></head><body></body></html>
\ No newline at end of file
Propchange: maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/apt/test.apt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/apt/test.apt
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/confluence/test.confluence
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/confluence/test.confluence?rev=636161&view=auto
==============================================================================
--- maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/confluence/test.confluence (added)
+++ maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/confluence/test.confluence Tue Mar 11 17:34:40 2008
@@ -0,0 +1 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head></head><body></body></html>
\ No newline at end of file
Added: maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/docbook/test.xml
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/docbook/test.xml?rev=636161&view=auto
==============================================================================
--- maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/docbook/test.xml (added)
+++ maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/docbook/test.xml Tue Mar 11 17:34:40 2008
@@ -0,0 +1,153 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<!--
+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.
+-->
+
+<!DOCTYPE article PUBLIC "-//OASIS//DTD Simplified DocBook XML V1.0CR2//EN"
+ "http://www.oasis-open.org/docbook/xml/simple/1.0CR2/sdocbook.dtd">
+
+<article id="index">
+ <articleinfo>
+ <title>Geotools2 Developer Guide</title>
+
+ <author>
+ <firstname>Cameron</firstname>
+
+ <surname>Shorter</surname>
+ </author>
+
+ <date>22 May 2002</date>
+
+ <abstract>
+ <para>Guide to aid <filename>geotools2</filename> development.</para>
+ </abstract>
+ </articleinfo>
+
+ <section id="intro">
+ <title>Introduction</title>
+
+ <para>This document aims to help new geotools developers get up to speed
+ and track practices of existing developers in order to keep the project
+ consistent.</para>
+
+ <para>If you feel something is missing, feel free to contribute a new
+ section.</para>
+ </section>
+
+ <section id="design">
+ <title>Design</title>
+ <figure>
+ <title>Geotools Logo</title>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/developersguide/geotools_logo.png"
+ format="PNG"/>
+ </imageobject>
+ <textobject><phrase>Geotools Logo</phrase></textobject>
+ </mediaobject>
+ </figure>
+
+ <para>To do: Explain</para><itemizedlist><listitem><para>Key design structure
+ (core interfaces, data sources, rendering, tools)</para></listitem><listitem><para>Design
+ Drivers (Our design goals: modular, derives structure from netbeans,
+ support multiple version of java, ..)</para></listitem><listitem><para>Directory
+ structure</para></listitem><listitem><para></para></listitem></itemizedlist>
+ </section>
+
+ <section id="development">
+ <title>Development</title>
+
+ <section id="building">
+ <title>Building</title>
+
+ <para>To do:</para><itemizedlist><listitem><para>using ant</para></listitem><listitem><para>what
+ ant checks</para></listitem><listitem><para>insert the
+ "howto-build.html" doc into here</para></listitem><listitem><para></para></listitem></itemizedlist>
+ </section>
+
+ <section id="cvs">
+ <title>Code Versioning (using CVS)</title>
+
+ <para>To do:</para><itemizedlist><listitem><para>Point to sourceforge CVS howto
+ links.</para></listitem><listitem><para>Also point to some HOWTOs for
+ windows users.</para></listitem><listitem><para>What is acceptable to
+ commit to CVS, what is not. (Ie, code should compile)</para></listitem><listitem><para>Talk
+ about version numbering convention, use of branches, etc (if we decide
+ to do this).</para></listitem></itemizedlist>
+
+ <para>To do:</para>
+ </section>
+
+ <section id="CodingStandards">
+ <title>Coding Standards</title>
+
+ <para>To do:</para><itemizedlist><listitem><para>Using Sun's coding
+ standard, need to note any exceptions to it.</para></listitem><listitem><para>Note
+ the auto checking of coding standards.</para></listitem><listitem><para>Javadocs</para></listitem><listitem><para></para></listitem></itemizedlist>
+ </section>
+
+ <section id="templates">
+ <title>Template File</title>
+
+ <para>To do:</para><itemizedlist><listitem><para>Provide a template file.</para></listitem><listitem><para>Link
+ it to sections explaining the different parts of the template.</para></listitem><listitem><para>Include
+ headers, footers, example logging, example coding style, CVS key tags,
+ sample javadocs.</para></listitem><listitem><para></para></listitem></itemizedlist>
+ </section>
+
+ <section id="logging">
+ <title>Logging</title>
+
+ <para>To do:</para><itemizedlist><listitem><para>Talk about log4j, links to</para></listitem><listitem><para></para></listitem><listitem><para></para></listitem><listitem><para></para></listitem></itemizedlist>
+ </section>
+
+ <section id="testing">
+ <title>Testing</title>
+
+ <para>To do:</para><itemizedlist><listitem><para>Explain use of junit. Might be
+ a link to another web site.</para></listitem><listitem><para></para></listitem><listitem><para></para></listitem><listitem><para></para></listitem></itemizedlist>
+ </section>
+
+ <section>
+ <title>Documentation</title>
+
+ <para>To do:</para><itemizedlist><listitem><para>Talk about docbook, why we
+ decided to use it (most commonly used format of LDP, converts to
+ multiple formats, tools coming which can support it. Need to mention
+ which version of docbook we are using.</para></listitem><listitem><para>Mention
+ tools that can be used.</para></listitem><listitem><para>Links to
+ docbook references.</para></listitem><listitem><para>Process for
+ updating this document.</para></listitem><listitem><para>How to use ant
+ tools to build doc.</para></listitem></itemizedlist>
+ </section>
+ </section>
+
+ <section id="tools">
+ <title>Development Tools</title>
+
+ <section id="netbeans">
+ <title>Netbeans</title>
+
+ <para>To do:</para><itemizedlist><listitem><para>Where to get it.</para></listitem><listitem><para>Aim
+ is to make geotools a module within Netbeans</para></listitem><listitem><para>How
+ to setup getools to fit the multiple directory structure</para></listitem><listitem><para>The
+ extra Netbeans modules that are useful and should be downloaded.</para></listitem></itemizedlist>
+ </section>
+ </section>
+</article>
+
Propchange: maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/docbook/test.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/doxia/doxia-tools/trunk/doxia-converter/src/test/resources/unit/docbook/test.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"