org.apache.maven.doxia.docrenderer
Class AbstractDocumentRenderer

java.lang.Object
  extended byorg.codehaus.plexus.logging.AbstractLogEnabled
      extended byorg.apache.maven.doxia.docrenderer.AbstractDocumentRenderer
All Implemented Interfaces:
DocumentRenderer, org.codehaus.plexus.logging.LogEnabled
Direct Known Subclasses:
AbstractPdfRenderer

public abstract class AbstractDocumentRenderer
extends org.codehaus.plexus.logging.AbstractLogEnabled
implements DocumentRenderer

Abstract document renderer.

Since:
1.1
Version:
$Id: AbstractDocumentRenderer.java 783307 2009-06-10 11:55:35Z vsiveton $
Author:
Vincent Siveton, ltheussl

Field Summary
protected  org.apache.maven.doxia.Doxia doxia
           
protected  org.apache.maven.doxia.module.site.manager.SiteModuleManager siteModuleManager
           
 
Fields inherited from interface org.apache.maven.doxia.docrenderer.DocumentRenderer
ROLE
 
Constructor Summary
AbstractDocumentRenderer()
           
 
Method Summary
protected  void copyDirectory(File source, File destination)
          Copy content of a directory, excluding scm-specific files.
protected  void copyResources(File outputDirectory)
          Copies the contents of the resource directory to an output folder.
 String getBaseDir()
          Return the current base directory.
 Map getFilesToProcess(Collection files)
          Returns a Map of files to process.
 Map getFilesToProcess(File baseDirectory)
          Returns a Map of files to process.
protected  String getOutputName(org.apache.maven.doxia.document.DocumentModel documentModel)
           
protected  void parse(String fullDocPath, String parserId, org.apache.maven.doxia.sink.Sink sink)
          Parse a source document into a sink.
 org.apache.maven.doxia.document.DocumentModel readDocumentModel(File documentDescriptor)
          Read a document model from a file.
 void render(Collection files, File outputDirectory, org.apache.maven.doxia.document.DocumentModel documentModel)
          Render a document from a set of files, depending on a rendering context.
 void render(File baseDirectory, File outputDirectory)
          Render a document from the files found in baseDirectory.
 void render(File baseDirectory, File outputDirectory, org.apache.maven.doxia.document.DocumentModel documentModel)
          Render a document from the files found in a source directory, depending on a rendering context.
 void render(File baseDirectory, File outputDirectory, File documentDescriptor)
          Render a document from the files found in baseDirectory.
abstract  void render(Map filesToProcess, File outputDirectory, org.apache.maven.doxia.document.DocumentModel documentModel)
          Render an aggregate document from the files found in a Map.
 void renderIndividual(Map filesToProcess, File outputDirectory)
          Render documents separately for each file found in a Map.
 void setBaseDir(String newDir)
          Sets the current base directory.
 
Methods inherited from class org.codehaus.plexus.logging.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.maven.doxia.docrenderer.DocumentRenderer
getOutputExtension
 

Field Detail

siteModuleManager

protected org.apache.maven.doxia.module.site.manager.SiteModuleManager siteModuleManager
Plexus requirement

doxia

protected org.apache.maven.doxia.Doxia doxia
Plexus requirement
Constructor Detail

AbstractDocumentRenderer

public AbstractDocumentRenderer()
Method Detail

render

public abstract void render(Map filesToProcess,
                            File outputDirectory,
                            org.apache.maven.doxia.document.DocumentModel documentModel)
                     throws DocumentRendererException,
                            IOException
Render an aggregate document from the files found in a Map.

Parameters:
filesToProcess - the Map of Files to process. The Map should contain as keys the paths of the source files (relative to baseDir), and the corresponding SiteModule as values.
outputDirectory - the output directory where the aggregate document should be generated.
documentModel - the document model, containing all the metadata, etc.
Throws:
DocumentRendererException - if any
IOException - if any

render

public void render(Collection files,
                   File outputDirectory,
                   org.apache.maven.doxia.document.DocumentModel documentModel)
            throws DocumentRendererException,
                   IOException
Render a document from a set of files, depending on a rendering context.

Specified by:
render in interface DocumentRenderer
Parameters:
files - the path name Strings (relative to a common base directory) of files to include in the document generation.
outputDirectory - the output directory where the document should be generated.
documentModel - the document model, containing all the metadata, etc. If the model contains a TOC, only the files found in this TOC are rendered, otherwise all files from the Collection of files will be processed. If the model is null, render all files individually.
Throws:
IOException - if any.
DocumentRendererException - if any.

render

public void render(File baseDirectory,
                   File outputDirectory,
                   org.apache.maven.doxia.document.DocumentModel documentModel)
            throws DocumentRendererException,
                   IOException
Render a document from the files found in a source directory, depending on a rendering context.

Specified by:
render in interface DocumentRenderer
Parameters:
baseDirectory - the directory containing the source files. This should follow the standard Maven convention, ie containing all the site modules.
outputDirectory - the output directory where the document should be generated.
documentModel - the document model, containing all the metadata, etc. If the model contains a TOC, only the files found in this TOC are rendered, otherwise all files found under baseDirectory will be processed. If the model is null, render all files from baseDirectory individually.
Throws:
DocumentRendererException - if any
IOException - if any

render

public void render(File baseDirectory,
                   File outputDirectory)
            throws DocumentRendererException,
                   IOException
Render a document from the files found in baseDirectory. This just forwards to render(File,File,DocumentModel) with a new DocumentModel.

Parameters:
baseDirectory - the directory containing the source files. This should follow the standard Maven convention, ie containing all the site modules.
outputDirectory - the output directory where the document should be generated.
Throws:
DocumentRendererException - if any
IOException - if any
See Also:
render(File, File, DocumentModel)

render

public void render(File baseDirectory,
                   File outputDirectory,
                   File documentDescriptor)
            throws DocumentRendererException,
                   IOException
Render a document from the files found in baseDirectory.

Parameters:
baseDirectory - the directory containing the source files. This should follow the standard Maven convention, ie containing all the site modules.
outputDirectory - the output directory where the document should be generated.
documentDescriptor - a file containing the document model. If this file does not exist or is null, some default settings will be used.
Throws:
DocumentRendererException - if any
IOException - if any
See Also:
if documentDescriptor does not exist or is null, otherwise

renderIndividual

public void renderIndividual(Map filesToProcess,
                             File outputDirectory)
                      throws DocumentRendererException,
                             IOException
Render documents separately for each file found in a Map.

Parameters:
filesToProcess - the Map of Files to process. The Map should contain as keys the paths of the source files (relative to baseDir), and the corresponding SiteModule as values.
outputDirectory - the output directory where the documents should be generated.
Throws:
DocumentRendererException - if any
IOException - if any
Since:
1.1.1

getFilesToProcess

public Map getFilesToProcess(File baseDirectory)
                      throws IOException,
                             DocumentRendererException
Returns a Map of files to process. The Map contains as keys the paths of the source files (relative to baseDir), and the corresponding SiteModule as values.

Parameters:
baseDirectory - the directory containing the source files. This should follow the standard Maven convention, ie containing all the site modules.
Returns:
a Map of files to process.
Throws:
IOException - in case of a problem reading the files under baseDirectory.
DocumentRendererException - if any

getFilesToProcess

public Map getFilesToProcess(Collection files)
Returns a Map of files to process. The Map contains as keys the paths of the source files (relative to baseDir), and the corresponding SiteModule as values.

Parameters:
files - The Collection of source files.
Returns:
a Map of files to process.

readDocumentModel

public org.apache.maven.doxia.document.DocumentModel readDocumentModel(File documentDescriptor)
                                                                throws DocumentRendererException,
                                                                       IOException
Read a document model from a file.

Specified by:
readDocumentModel in interface DocumentRenderer
Parameters:
documentDescriptor - a document descriptor file that contains the document model.
Returns:
the document model, containing all the metadata, etc.
Throws:
IOException - if any
DocumentRendererException - if any

setBaseDir

public void setBaseDir(String newDir)
Sets the current base directory.

Parameters:
newDir - the absolute path to the base directory to set.

getBaseDir

public String getBaseDir()
Return the current base directory.

Returns:
the current base directory.

parse

protected void parse(String fullDocPath,
                     String parserId,
                     org.apache.maven.doxia.sink.Sink sink)
              throws DocumentRendererException,
                     IOException
Parse a source document into a sink.

Parameters:
fullDocPath - absolute path to the source document.
parserId - determines the parser to use.
sink - the sink to receive the events.
Throws:
DocumentRendererException - in case of a parsing error.
IOException - if the source document cannot be opened.

copyResources

protected void copyResources(File outputDirectory)
                      throws IOException
Copies the contents of the resource directory to an output folder.

Parameters:
outputDirectory - the destination folder.
Throws:
IOException - if any.

copyDirectory

protected void copyDirectory(File source,
                             File destination)
                      throws IOException
Copy content of a directory, excluding scm-specific files.

Parameters:
source - directory that contains the files and sub-directories to be copied.
destination - destination folder.
Throws:
IOException - if any.

getOutputName

protected String getOutputName(org.apache.maven.doxia.document.DocumentModel documentModel)
Parameters:
documentModel - not null
Returns:
the output name defined in the documentModel without the output extension. If the output name is not defined, return target by default.
Since:
1.1.1
See Also:
DocumentModel.getOutputName(), DocumentRenderer.getOutputExtension()


Copyright © 2005-2009 The Apache Software Foundation. All Rights Reserved.