Class AbstractDocumentRenderer
- java.lang.Object
-
- org.codehaus.plexus.logging.AbstractLogEnabled
-
- org.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
Abstractdocumentrenderer.- Since:
- 1.1
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringbaseDirThe common base directory of source files.protected org.apache.maven.doxia.Doxiadoxiaprotected org.apache.maven.doxia.parser.module.ParserModuleManagerparserModuleManagerprivate org.codehaus.plexus.velocity.VelocityComponentvelocity-
Fields inherited from interface org.apache.maven.doxia.docrenderer.DocumentRenderer
ROLE
-
-
Constructor Summary
Constructors Constructor Description AbstractDocumentRenderer()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidcopyDirectory(java.io.File source, java.io.File destination)Copy content of a directory, excluding scm-specific files.protected voidcopyResources(java.io.File outputDirectory)Copies the contents of the resource directory to an output folder.protected static booleanendsWithIgnoreCase(java.lang.String str, java.lang.String searchStr)protected static booleanendsWithIgnoreCase(java.lang.String str, java.lang.String[] searchStrs)java.lang.StringgetBaseDir()Return the current base directory.protected static java.lang.String[]getExtensions(org.apache.maven.doxia.parser.module.ParserModule module)java.util.Map<java.lang.String,org.apache.maven.doxia.parser.module.ParserModule>getFilesToProcess(java.io.File baseDirectory)Returns a Map of files to process.java.util.Map<java.lang.String,org.apache.maven.doxia.parser.module.ParserModule>getFilesToProcess(java.util.Collection<java.lang.String> files)Returns a Map of files to process.protected java.lang.StringgetOutputName(org.apache.maven.doxia.document.DocumentModel documentModel)private java.io.ReadergetVelocityReader(java.io.File f, java.lang.String encoding, DocumentRendererContext context)TODO: DOXIA-111: we need a general filter here that knows how to alter the contextprivate static booleanisVelocityFile(java.io.File f)protected voidparse(java.lang.String fullDocPath, java.lang.String parserId, org.apache.maven.doxia.sink.Sink sink)Deprecated.since 1.1.2, useparse(String, String, Sink, DocumentRendererContext)protected voidparse(java.lang.String fullDocPath, java.lang.String parserId, org.apache.maven.doxia.sink.Sink sink, DocumentRendererContext context)Parse a source document into a sink.org.apache.maven.doxia.document.DocumentModelreadDocumentModel(java.io.File documentDescriptor)Read a document model from a file.voidrender(java.io.File baseDirectory, java.io.File outputDirectory)Render a document from the files found in baseDirectory.voidrender(java.io.File baseDirectory, java.io.File outputDirectory, java.io.File documentDescriptor)Render a document from the files found in baseDirectory.voidrender(java.io.File baseDirectory, java.io.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.voidrender(java.io.File baseDirectory, java.io.File outputDirectory, org.apache.maven.doxia.document.DocumentModel documentModel, DocumentRendererContext context)Render a document from the files found in a source directory, depending on a rendering context.voidrender(java.util.Collection<java.lang.String> files, java.io.File outputDirectory, org.apache.maven.doxia.document.DocumentModel documentModel)Render a document from a set of files, depending on a rendering context.abstract voidrender(java.util.Map<java.lang.String,org.apache.maven.doxia.parser.module.ParserModule> filesToProcess, java.io.File outputDirectory, org.apache.maven.doxia.document.DocumentModel documentModel)Deprecated.since 1.1.2, userender(Map, File, DocumentModel, DocumentRendererContext)voidrender(java.util.Map<java.lang.String,org.apache.maven.doxia.parser.module.ParserModule> filesToProcess, java.io.File outputDirectory, org.apache.maven.doxia.document.DocumentModel documentModel, DocumentRendererContext context)Render an aggregate document from the files found in a Map.voidrenderIndividual(java.util.Map<java.lang.String,org.apache.maven.doxia.parser.module.ParserModule> filesToProcess, java.io.File outputDirectory)Deprecated.since 1.1.2, userenderIndividual(Map, File, DocumentRendererContext)voidrenderIndividual(java.util.Map<java.lang.String,org.apache.maven.doxia.parser.module.ParserModule> filesToProcess, java.io.File outputDirectory, DocumentRendererContext context)Render documents separately for each file found in a Map.voidsetBaseDir(java.lang.String newDir)Sets the current base directory.private java.io.Readervalidate(java.io.Reader source, java.lang.String resource)-
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
-
parserModuleManager
@Requirement protected org.apache.maven.doxia.parser.module.ParserModuleManager parserModuleManager
-
doxia
@Requirement protected org.apache.maven.doxia.Doxia doxia
-
velocity
@Requirement private org.codehaus.plexus.velocity.VelocityComponent velocity
-
baseDir
private java.lang.String baseDir
The common base directory of source files.
-
-
Method Detail
-
render
public abstract void render(java.util.Map<java.lang.String,org.apache.maven.doxia.parser.module.ParserModule> filesToProcess, java.io.File outputDirectory, org.apache.maven.doxia.document.DocumentModel documentModel) throws DocumentRendererException, java.io.IOExceptionDeprecated.since 1.1.2, userender(Map, File, DocumentModel, DocumentRendererContext)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 tobaseDir), and the corresponding ParserModule 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 anyjava.io.IOException- if any
-
render
public void render(java.util.Collection<java.lang.String> files, java.io.File outputDirectory, org.apache.maven.doxia.document.DocumentModel documentModel) throws DocumentRendererException, java.io.IOExceptionRender a document from a set of files, depending on a rendering context.- Specified by:
renderin interfaceDocumentRenderer- 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:
DocumentRendererException- if any.java.io.IOException- if any.
-
render
public void render(java.io.File baseDirectory, java.io.File outputDirectory, org.apache.maven.doxia.document.DocumentModel documentModel) throws DocumentRendererException, java.io.IOExceptionRender a document from the files found in a source directory, depending on a rendering context.- Specified by:
renderin interfaceDocumentRenderer- 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 anyjava.io.IOException- if any // * @deprecated since 1.1.2, use#render(File, File, DocumentModel, DocumentRendererContext)
-
render
public void render(java.util.Map<java.lang.String,org.apache.maven.doxia.parser.module.ParserModule> filesToProcess, java.io.File outputDirectory, org.apache.maven.doxia.document.DocumentModel documentModel, DocumentRendererContext context) throws DocumentRendererException, java.io.IOExceptionRender 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 tobaseDir), and the corresponding ParserModule as values.outputDirectory- the output directory where the aggregate document should be generated.documentModel- the document model, containing all the metadata, etc.context- the rendering context when processing files.- Throws:
DocumentRendererException- if anyjava.io.IOException- if any
-
render
public void render(java.io.File baseDirectory, java.io.File outputDirectory, org.apache.maven.doxia.document.DocumentModel documentModel, DocumentRendererContext context) throws DocumentRendererException, java.io.IOExceptionRender a document from the files found in a source directory, depending on a rendering context.- 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.context- the rendering context when processing files.- Throws:
DocumentRendererException- if anyjava.io.IOException- if any- Since:
- 1.1.2
-
render
public void render(java.io.File baseDirectory, java.io.File outputDirectory) throws DocumentRendererException, java.io.IOExceptionRender a document from the files found in baseDirectory. This just forwards torender(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 anyjava.io.IOException- if any- See Also:
render(File, File, DocumentModel)
-
render
public void render(java.io.File baseDirectory, java.io.File outputDirectory, java.io.File documentDescriptor) throws DocumentRendererException, java.io.IOExceptionRender 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 anyjava.io.IOException- if any- See Also:
if documentDescriptor does not exist or is null,otherwise
-
renderIndividual
public void renderIndividual(java.util.Map<java.lang.String,org.apache.maven.doxia.parser.module.ParserModule> filesToProcess, java.io.File outputDirectory) throws DocumentRendererException, java.io.IOExceptionDeprecated.since 1.1.2, userenderIndividual(Map, File, DocumentRendererContext)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 tobaseDir), and the corresponding ParserModule as values.outputDirectory- the output directory where the documents should be generated.- Throws:
DocumentRendererException- if anyjava.io.IOException- if any- Since:
- 1.1.1
-
renderIndividual
public void renderIndividual(java.util.Map<java.lang.String,org.apache.maven.doxia.parser.module.ParserModule> filesToProcess, java.io.File outputDirectory, DocumentRendererContext context) throws DocumentRendererException, java.io.IOExceptionRender 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 tobaseDir), and the corresponding ParserModule as values.outputDirectory- the output directory where the documents should be generated.context- the rendering context.- Throws:
DocumentRendererException- if anyjava.io.IOException- if any- Since:
- 1.1.2
-
getFilesToProcess
public java.util.Map<java.lang.String,org.apache.maven.doxia.parser.module.ParserModule> getFilesToProcess(java.io.File baseDirectory) throws java.io.IOException, DocumentRendererExceptionReturns a Map of files to process. The Map contains as keys the paths of the source files (relative tobaseDir), and the corresponding ParserModule 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:
java.io.IOException- in case of a problem reading the files under baseDirectory.DocumentRendererException- if any
-
getExtensions
protected static java.lang.String[] getExtensions(org.apache.maven.doxia.parser.module.ParserModule module)
-
endsWithIgnoreCase
protected static boolean endsWithIgnoreCase(java.lang.String str, java.lang.String searchStr)
-
endsWithIgnoreCase
protected static boolean endsWithIgnoreCase(java.lang.String str, java.lang.String[] searchStrs)
-
getFilesToProcess
public java.util.Map<java.lang.String,org.apache.maven.doxia.parser.module.ParserModule> getFilesToProcess(java.util.Collection<java.lang.String> files)
Returns a Map of files to process. The Map contains as keys the paths of the source files (relative tobaseDir), and the corresponding ParserModule 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(java.io.File documentDescriptor) throws DocumentRendererException, java.io.IOExceptionRead a document model from a file.- Specified by:
readDocumentModelin interfaceDocumentRenderer- Parameters:
documentDescriptor- a document descriptor file that contains the document model.- Returns:
- the document model, containing all the metadata, etc.
- Throws:
DocumentRendererException- if anyjava.io.IOException- if any
-
setBaseDir
public void setBaseDir(java.lang.String newDir)
Sets the current base directory.- Parameters:
newDir- the absolute path to the base directory to set.
-
getBaseDir
public java.lang.String getBaseDir()
Return the current base directory.- Returns:
- the current base directory.
-
parse
protected void parse(java.lang.String fullDocPath, java.lang.String parserId, org.apache.maven.doxia.sink.Sink sink) throws DocumentRendererException, java.io.IOExceptionDeprecated.since 1.1.2, useparse(String, String, Sink, DocumentRendererContext)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.java.io.IOException- if the source document cannot be opened.
-
parse
protected void parse(java.lang.String fullDocPath, java.lang.String parserId, org.apache.maven.doxia.sink.Sink sink, DocumentRendererContext context) throws DocumentRendererException, java.io.IOExceptionParse 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.context- the rendering context.- Throws:
DocumentRendererException- in case of a parsing error.java.io.IOException- if the source document cannot be opened.
-
copyResources
protected void copyResources(java.io.File outputDirectory) throws java.io.IOExceptionCopies the contents of the resource directory to an output folder.- Parameters:
outputDirectory- the destination folder.- Throws:
java.io.IOException- if any.
-
copyDirectory
protected void copyDirectory(java.io.File source, java.io.File destination) throws java.io.IOExceptionCopy 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:
java.io.IOException- if any.
-
getOutputName
protected java.lang.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()
-
getVelocityReader
private java.io.Reader getVelocityReader(java.io.File f, java.lang.String encoding, DocumentRendererContext context) throws DocumentRendererExceptionTODO: DOXIA-111: we need a general filter here that knows how to alter the context- Parameters:
f- the file to process, not nullencoding- the wanted encoding, not nullcontext- the current render document context not null- Returns:
- a reader with
- Throws:
DocumentRendererException
-
isVelocityFile
private static boolean isVelocityFile(java.io.File f)
- Parameters:
f- not null- Returns:
trueif file has a vm extension,false otherwise.
-
validate
private java.io.Reader validate(java.io.Reader source, java.lang.String resource) throws org.apache.maven.doxia.parser.ParseException, java.io.IOException- Throws:
org.apache.maven.doxia.parser.ParseExceptionjava.io.IOException
-
-