org.apache.velocity.anakia

Class AnakiaTask


public class AnakiaTask
extends MatchingTask

The purpose of this Ant Task is to allow you to use Velocity as an XML transformation tool like XSLT is. So, instead of using XSLT, you will be able to use this class instead to do your transformations. It works very similar in concept to Ant's <style> task.

You can find more documentation about this class on the Velocity Website.

Version:
$Id: AnakiaTask.java,v 1.34.4.1 2004/03/03 23:22:04 geirm Exp $
Authors:
Jon S. Stevens
Attila Szegedi

Field Summary

private File
baseDir
the base directory
private SAXBuilder
builder
SAXBuilder instance to use
private File
destDir
the destination directory
private String
extension
the default output extension is .html
private boolean
lastModifiedCheck
check the last modified date on files.
private String
projectAttribute
the projectFile= attribute
private File
projectFile
the File for the project.xml file
private long
projectFileLastModified
last modified of the project file if it exists
private String
style
the style= attribute
private File
styleFile
the File to the style file
private long
styleSheetLastModified
last modified of the style sheet
private String
templatePath
the template path
private VelocityEngine
ve
the VelocityEngine instance to use
private File
velocityPropertiesFile
the file to get the velocity properties file

Constructor Summary

AnakiaTask()
Constructor creates the SAXBuilder.

Method Summary

private void
ensureDirectoryFor(File targetFile)
create directories as needed
void
execute()
Main body of the application
private String
getRelativePath(String file)
Hacky method to figure out the relative path that we are currently in.
private void
process(File baseDir, String xmlFile, File destDir, Document projectDocument)
Process an XML file using Velocity
void
setBasedir(File dir)
Set the base directory.
void
setDestdir(File dir)
Set the destination directory into which the VSL result files should be copied to
void
setExtension(String extension)
Allow people to set the default output file extension
void
setLastModifiedCheck(String lastmod)
Turn on/off last modified checking.
void
setProjectFile(String projectAttribute)
Allow people to set the path to the project.xml file
void
setStyle(String style)
Allow people to set the path to the .vsl file
void
setTemplatePath(File templatePath)
Set the path to the templates.
void
setVelocityPropertiesFile(File velocityPropertiesFile)
Allow people to set the path to the velocity.properties file This file is found relative to the path where the JVM was run.

Field Details

baseDir

private File baseDir
the base directory

builder

private SAXBuilder builder
SAXBuilder instance to use

destDir

private File destDir
the destination directory

extension

private String extension
the default output extension is .html

lastModifiedCheck

private boolean lastModifiedCheck
check the last modified date on files. defaults to true

projectAttribute

private String projectAttribute
the projectFile= attribute

projectFile

private File projectFile
the File for the project.xml file

projectFileLastModified

private long projectFileLastModified
last modified of the project file if it exists

style

private String style
the style= attribute

styleFile

private File styleFile
the File to the style file

styleSheetLastModified

private long styleSheetLastModified
last modified of the style sheet

templatePath

private String templatePath
the template path

ve

private VelocityEngine ve
the VelocityEngine instance to use

velocityPropertiesFile

private File velocityPropertiesFile
the file to get the velocity properties file

Constructor Details

AnakiaTask

public AnakiaTask()
Constructor creates the SAXBuilder.

Method Details

ensureDirectoryFor

private void ensureDirectoryFor(File targetFile)
            throws BuildException
create directories as needed

execute

public void execute()
            throws BuildException
Main body of the application

getRelativePath

private String getRelativePath(String file)
Hacky method to figure out the relative path that we are currently in. This is good for getting the relative path for images and anchor's.

process

private void process(File baseDir,
                     String xmlFile,
                     File destDir,
                     Document projectDocument)
            throws BuildException
Process an XML file using Velocity

setBasedir

public void setBasedir(File dir)
Set the base directory.

setDestdir

public void setDestdir(File dir)
Set the destination directory into which the VSL result files should be copied to
Parameters:

setExtension

public void setExtension(String extension)
Allow people to set the default output file extension

setLastModifiedCheck

public void setLastModifiedCheck(String lastmod)
Turn on/off last modified checking. by default, it is on.

setProjectFile

public void setProjectFile(String projectAttribute)
Allow people to set the path to the project.xml file

setStyle

public void setStyle(String style)
Allow people to set the path to the .vsl file

setTemplatePath

public void setTemplatePath(File templatePath)
Set the path to the templates. The way it works is this: If you have a Velocity.properties file defined, this method will override whatever is set in the Velocity.properties file. This allows one to not have to define a Velocity.properties file, therefore using Velocity's defaults only.

setVelocityPropertiesFile

public void setVelocityPropertiesFile(File velocityPropertiesFile)
Allow people to set the path to the velocity.properties file This file is found relative to the path where the JVM was run. For example, if build.sh was executed in the ./build directory, then the path would be relative to this directory. This is optional based on the setting of setTemplatePath().

Copyright B) 2002 Apache Software Foundation. All Rights Reserved.