org.apache.velocity.anakia
Class AnakiaTask

java.lang.Object
  extended byorg.apache.tools.ant.ProjectComponent
      extended byorg.apache.tools.ant.Task
          extended byorg.apache.tools.ant.taskdefs.MatchingTask
              extended byorg.apache.velocity.anakia.AnakiaTask
All Implemented Interfaces:
java.lang.Cloneable, org.apache.tools.ant.types.selectors.SelectorContainer

public class AnakiaTask
extends org.apache.tools.ant.taskdefs.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 $
Author:
Jon S. Stevens, Attila Szegedi

Field Summary
private  java.io.File baseDir
          the base directory
private  org.jdom.input.SAXBuilder builder
          SAXBuilder instance to use
private  java.io.File destDir
          the destination directory
private  java.lang.String extension
          the default output extension is .html
private  boolean lastModifiedCheck
          check the last modified date on files.
private  java.lang.String projectAttribute
          the projectFile= attribute
private  java.io.File projectFile
          the File for the project.xml file
private  long projectFileLastModified
          last modified of the project file if it exists
private  java.lang.String style
          the style= attribute
private  java.io.File styleFile
          the File to the style file
private  long styleSheetLastModified
          last modified of the style sheet
private  java.lang.String templatePath
          the template path
private  VelocityEngine ve
          the VelocityEngine instance to use
private  java.io.File velocityPropertiesFile
          the file to get the velocity properties file
 
Fields inherited from class org.apache.tools.ant.taskdefs.MatchingTask
fileset
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
AnakiaTask()
          Constructor creates the SAXBuilder.
 
Method Summary
private  void ensureDirectoryFor(java.io.File targetFile)
          create directories as needed
 void execute()
          Main body of the application
private  java.lang.String getRelativePath(java.lang.String file)
          Hacky method to figure out the relative path that we are currently in.
private  void process(java.io.File baseDir, java.lang.String xmlFile, java.io.File destDir, org.jdom.Document projectDocument)
          Process an XML file using Velocity
 void setBasedir(java.io.File dir)
          Set the base directory.
 void setDestdir(java.io.File dir)
          Set the destination directory into which the VSL result files should be copied to
 void setExtension(java.lang.String extension)
          Allow people to set the default output file extension
 void setLastModifiedCheck(java.lang.String lastmod)
          Turn on/off last modified checking.
 void setProjectFile(java.lang.String projectAttribute)
          Allow people to set the path to the project.xml file
 void setStyle(java.lang.String style)
          Allow people to set the path to the .vsl file
 void setTemplatePath(java.io.File templatePath)
          Set the path to the templates.
 void setVelocityPropertiesFile(java.io.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.
 
Methods inherited from class org.apache.tools.ant.taskdefs.MatchingTask
add, addAnd, addContains, addContainsRegexp, addCustom, addDate, addDepend, addDepth, addDifferent, addFilename, addMajority, addModified, addNone, addNot, addOr, addPresent, addSelector, addSize, addType, appendSelector, createExclude, createExcludesFile, createInclude, createIncludesFile, createPatternSet, getDirectoryScanner, getImplicitFileSet, getSelectors, hasSelectors, selectorCount, selectorElements, setCaseSensitive, setDefaultexcludes, setExcludes, setExcludesfile, setFollowSymlinks, setIncludes, setIncludesfile, setProject, XsetIgnore, XsetItems
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

builder

private org.jdom.input.SAXBuilder builder
SAXBuilder instance to use


destDir

private java.io.File destDir
the destination directory


baseDir

private java.io.File baseDir
the base directory


style

private java.lang.String style
the style= attribute


styleFile

private java.io.File styleFile
the File to the style file


styleSheetLastModified

private long styleSheetLastModified
last modified of the style sheet


projectAttribute

private java.lang.String projectAttribute
the projectFile= attribute


projectFile

private java.io.File projectFile
the File for the project.xml file


projectFileLastModified

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


lastModifiedCheck

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


extension

private java.lang.String extension
the default output extension is .html


templatePath

private java.lang.String templatePath
the template path


velocityPropertiesFile

private java.io.File velocityPropertiesFile
the file to get the velocity properties file


ve

private VelocityEngine ve
the VelocityEngine instance to use

Constructor Detail

AnakiaTask

public AnakiaTask()
Constructor creates the SAXBuilder.

Method Detail

setBasedir

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


setDestdir

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


setExtension

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


setStyle

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


setProjectFile

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


setTemplatePath

public void setTemplatePath(java.io.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(java.io.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().


setLastModifiedCheck

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


execute

public void execute()
             throws org.apache.tools.ant.BuildException
Main body of the application

Throws:
org.apache.tools.ant.BuildException

process

private void process(java.io.File baseDir,
                     java.lang.String xmlFile,
                     java.io.File destDir,
                     org.jdom.Document projectDocument)
              throws org.apache.tools.ant.BuildException
Process an XML file using Velocity

Throws:
org.apache.tools.ant.BuildException

getRelativePath

private java.lang.String getRelativePath(java.lang.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.


ensureDirectoryFor

private void ensureDirectoryFor(java.io.File targetFile)
                         throws org.apache.tools.ant.BuildException
create directories as needed

Throws:
org.apache.tools.ant.BuildException


Copyright ? 2002 Apache Software Foundation. All Rights Reserved.