com.agilejava.docbkx.maven
Class AbstractTransformerMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by com.agilejava.docbkx.maven.AbstractTransformerMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

public abstract class AbstractTransformerMojo
extends org.apache.maven.plugin.AbstractMojo

The abstract Mojo base for concrete Mojos that generate some kind of output format from DocBook. This Mojo will search documents in the directory returned by getTargetDirectory(), and apply the stylesheets on these documents. This Mojo will be subclassed by Mojo's that generate a particular type of output.

Author:
Wilfred Springer

Field Summary
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
AbstractTransformerMojo()
           
 
Method Summary
 void adjustTransformer(javax.xml.transform.Transformer transformer, java.lang.String sourceFilename, java.io.File targetFile)
          The operation to override when it is required to make some adjustments to the Transformer right before it is applied to a certain source file.
protected abstract  void configure(javax.xml.transform.Transformer transformer)
          Configure the Transformer by passing in some parameters.
protected  org.apache.xml.resolver.CatalogManager createCatalogManager()
          Creates a CatalogManager, used to resolve DTDs and other entities.
protected  javax.xml.parsers.DocumentBuilder createDocumentBuilder()
          Creates a DocumentBuilder to be used to parse DocBook XML documents.
protected  org.jaxen.XPath createTitleXPath()
          Creates an instance of an XPath expression for picking the title from a document.
protected  TransformerBuilder createTransformerBuilder(javax.xml.transform.URIResolver resolver)
          Constructs the default TransformerBuilder.
 void execute()
          Builds the actual output document.
protected  void executeTasks(org.apache.tools.ant.Target antTasks, org.apache.maven.project.MavenProject mavenProject)
           
protected abstract  java.util.List getArtifacts()
          Returns the plugin dependencies.
protected abstract  java.lang.String getDefaultStylesheetLocation()
          Returns the default stylesheet location within the root of the stylesheet distribution.
protected  java.net.URL getDefaultStylesheetURL()
          Returns the URL of the default stylesheet.
protected abstract  java.util.List getEntities()
          Returns a list of Entities
protected abstract  java.lang.String[] getIncludes()
          Returns the include patterns, as a comma-seperate collection of patterns.
protected abstract  org.apache.maven.project.MavenProject getMavenProject()
          Returns a reference to the current project.
protected  java.lang.String getNonDefaultStylesheetLocation()
          The stylesheet location override by a class in the mojo hierarchy.
protected  java.net.URL getNonDefaultStylesheetURL()
          Returns the URL of the default stylesheet.
protected abstract  org.apache.tools.ant.Target getPostProcess()
          Returns the tasks that should be executed after the transformation.
protected abstract  org.apache.tools.ant.Target getPreProcess()
          Returns the tasks that should be executed before the transformation.
protected abstract  java.io.File getSourceDirectory()
          Returns the source directory containing the source XML files.
protected abstract  java.lang.String getStylesheetLocation()
          Returns the actual stylesheet location.
protected  java.net.URL getStylesheetURL()
          Returns the URL of the stylesheet.
protected abstract  java.io.File getTargetDirectory()
          Returns the target directory in which all results should be placed.
protected abstract  java.lang.String getTargetFileExtension()
          Returns the extension of the target files, e.g.
protected abstract  java.lang.String getType()
          Returns the type of conversion.
protected abstract  boolean getXIncludeSupported()
          Returns a boolean indicting if XInclude should be supported.
 void postProcess()
          Alles classes to add their own specific post-processing logic.
 void postProcessResult(java.io.File result)
          Post-processes the file.
 void preProcess()
          Allows subclasses to add their own specific pre-processing logic.
 
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractTransformerMojo

public AbstractTransformerMojo()
Method Detail

execute

public void execute()
             throws org.apache.maven.plugin.MojoExecutionException,
                    org.apache.maven.plugin.MojoFailureException
Builds the actual output document.

Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException

getXIncludeSupported

protected abstract boolean getXIncludeSupported()
Returns a boolean indicting if XInclude should be supported.

Returns:
A boolean indicating if XInclude should be supported.

getNonDefaultStylesheetLocation

protected java.lang.String getNonDefaultStylesheetLocation()
The stylesheet location override by a class in the mojo hierarchy.

Returns:
The location of the stylesheet set by one of the superclasses, or null.

adjustTransformer

public void adjustTransformer(javax.xml.transform.Transformer transformer,
                              java.lang.String sourceFilename,
                              java.io.File targetFile)
The operation to override when it is required to make some adjustments to the Transformer right before it is applied to a certain source file. The two parameters provide some context, allowing implementers to respond to specific conditions for specific files.

Parameters:
transformer - The Transformer that must be adjusted.
sourceFilename - The name of the source file that is being transformed.
targetFile - The target File.

preProcess

public void preProcess()
                throws org.apache.maven.plugin.MojoExecutionException
Allows subclasses to add their own specific pre-processing logic.

Throws:
org.apache.maven.plugin.MojoExecutionException - If the Mojo fails to pre-process the results.

postProcess

public void postProcess()
                 throws org.apache.maven.plugin.MojoExecutionException
Alles classes to add their own specific post-processing logic.

Throws:
org.apache.maven.plugin.MojoExecutionException - If the Mojo fails to post-process the results.

postProcessResult

public void postProcessResult(java.io.File result)
                       throws org.apache.maven.plugin.MojoExecutionException
Post-processes the file. (Might be changed in the future to except an XML representation instead of a file, in order to prevent the file from being parsed.)

Parameters:
result - An individual result.
Throws:
org.apache.maven.plugin.MojoExecutionException

createCatalogManager

protected org.apache.xml.resolver.CatalogManager createCatalogManager()
Creates a CatalogManager, used to resolve DTDs and other entities.

Returns:
A CatalogManager to be used for resolving DTDs and other entities.

createDocumentBuilder

protected javax.xml.parsers.DocumentBuilder createDocumentBuilder()
                                                           throws org.apache.maven.plugin.MojoExecutionException
Creates a DocumentBuilder to be used to parse DocBook XML documents.

Returns:
A DocumentBuilder instance.
Throws:
org.apache.maven.plugin.MojoExecutionException - If we cannot create an instance of the DocumentBuilder.

createTitleXPath

protected org.jaxen.XPath createTitleXPath()
                                    throws org.apache.maven.plugin.MojoExecutionException
Creates an instance of an XPath expression for picking the title from a document.

Returns:
An XPath expression to pick the title from a document.
Throws:
org.apache.maven.plugin.MojoExecutionException - If the XPath expression cannot be parsed.

createTransformerBuilder

protected TransformerBuilder createTransformerBuilder(javax.xml.transform.URIResolver resolver)
Constructs the default TransformerBuilder.


executeTasks

protected void executeTasks(org.apache.tools.ant.Target antTasks,
                            org.apache.maven.project.MavenProject mavenProject)
                     throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

configure

protected abstract void configure(javax.xml.transform.Transformer transformer)
Configure the Transformer by passing in some parameters.

Parameters:
transformer - The Transformer that needs to be configured.

getTargetDirectory

protected abstract java.io.File getTargetDirectory()
Returns the target directory in which all results should be placed.

Returns:
The target directory in which all results should be placed.

getSourceDirectory

protected abstract java.io.File getSourceDirectory()
Returns the source directory containing the source XML files.

Returns:
The source directory containing the source XML files.

getIncludes

protected abstract java.lang.String[] getIncludes()
Returns the include patterns, as a comma-seperate collection of patterns.


getStylesheetURL

protected java.net.URL getStylesheetURL()
Returns the URL of the stylesheet. You can override this operation to return a URL pointing to a stylesheet residing on a location that can be adressed by a URL. By default, it will return a stylesheet that will be loaded from the classpath, using the resource name returned by getStylesheetLocation().

Returns:
The URL of the stylesheet.

getNonDefaultStylesheetURL

protected java.net.URL getNonDefaultStylesheetURL()
Returns the URL of the default stylesheet.

Returns:
The URL of the stylesheet.

getDefaultStylesheetURL

protected java.net.URL getDefaultStylesheetURL()
Returns the URL of the default stylesheet.

Returns:
The URL of the stylesheet.

getDefaultStylesheetLocation

protected abstract java.lang.String getDefaultStylesheetLocation()
Returns the default stylesheet location within the root of the stylesheet distribution.

Returns:
The location of the directory containing the stylesheets.

getStylesheetLocation

protected abstract java.lang.String getStylesheetLocation()
Returns the actual stylesheet location.

Returns:
The actual stylesheet location.

getTargetFileExtension

protected abstract java.lang.String getTargetFileExtension()
Returns the extension of the target files, e.g. "html" for HTML files, etc.

Returns:
The extension of the target files.

getEntities

protected abstract java.util.List getEntities()
Returns a list of Entities


getPreProcess

protected abstract org.apache.tools.ant.Target getPreProcess()
Returns the tasks that should be executed before the transformation.

Returns:
The tasks that should be executed before the transformation.

getPostProcess

protected abstract org.apache.tools.ant.Target getPostProcess()
Returns the tasks that should be executed after the transformation.

Returns:
The tasks that should be executed after the transformation.

getMavenProject

protected abstract org.apache.maven.project.MavenProject getMavenProject()
Returns a reference to the current project.

Returns:
A reference to the current project.

getArtifacts

protected abstract java.util.List getArtifacts()
Returns the plugin dependencies.

Returns:
The plugin dependencies.

getType

protected abstract java.lang.String getType()
Returns the type of conversion.



Copyright © 2006-2009. All Rights Reserved.