ERR_MSG_FRAGMENT
private static final String ERR_MSG_FRAGMENT
This message fragment (telling users to consult the log or
invoke ant with the -debug flag) is appended to rethrown
exception messages.
contextProperties
protected ExtendedProperties contextProperties
These are properties that are fed into the
initial context from a properties file. This
is simply a convenient way to set some values
that you wish to make available in the context.
These values are not critical, like the template path
or output path, but allow a convenient way to
set a value that may be specific to a particular
generation task.
For example, if you are generating scripts to allow
user to automatically create a database, then
you might want the
$databaseName
to be placed
in the initial context so that it is available
in a script that might look something like the
following:
#!bin/sh
echo y | mysqladmin create $databaseName
The value of
$databaseName
isn't critical to
output, and you obviously don't want to change
the ant task to simply take a database name.
So initial context values can be set with
properties file.
contextPropertiesFile
protected String contextPropertiesFile
Reference to the context properties that is held
until processing in the execute() method. We do this
now so that the Ant TaskAdapter can set the project
which is needed for correct path processing when
this bean is used as an ant task.
controlTemplate
protected String controlTemplate
This is the control template that governs the output.
It may or may not invoke the services of worker
templates.
fileSeparator
private String fileSeparator
Path separator.
inputEncoding
protected String inputEncoding
This is the encoding for the input file(s)
(templates).
outputDirectory
protected String outputDirectory
This is where texen will place all the output
that is a product of the generation process.
outputEncoding
protected String outputEncoding
This is the encoding for the output file(s).
outputFile
protected String outputFile
This is the file where the generated text
will be placed.
project
protected Project project
Ant project that is populated by the Ant TaskAdapter when
this bean is run as an Ant Task.
templatePath
protected String templatePath
This is where Velocity will look for templates
using the file template loader.
useClasspath
protected boolean useClasspath
Property which controls whether the classpath
will be used when trying to locate templates.
cleanup
protected void cleanup()
throws Exception
A hook method called at the end of
execute()
which can
be overridden to perform any necessary cleanup activities (such
as the release of database connections, etc.). By default,
does nothing.
execute
public void execute()
throws Exception
Execute the input script with Velocity
getContextProperties
public ExtendedProperties getContextProperties()
Get the context properties that will be
fed into the initial context be the
generating process starts.
getControlTemplate
public String getControlTemplate()
Get the control template for the
generating process.
getOutputDirectory
public String getOutputDirectory()
Get the output directory.
getOutputFile
public String getOutputFile()
Get the output file for the
generation process.
getProject
public Project getProject()
Get the Ant project which will be non-null if
this bean is used as a Task and adapted by the
Ant TaskAdapter.
getTemplatePath
public String getTemplatePath()
Get the path where Velocity will look
for templates using the file template
loader.
initControlContext
public Context initControlContext()
throws Exception
Creates a VelocityContext.
- new Context
log
private void log(String message)
Log a message. Use the Ant logging system if being
used as an Ant Task.
populateInitialContext
protected void populateInitialContext(Context context)
throws Exception
Place useful objects into the initial context.
TexenTask places
Date().toString()
into the
context as
$now
. Subclasses who want to vary the
objects in the context should override this method.
$generator
is not put into the context in this
method.
initControlContext()
.
context
- The context to populate, as retrieved from
processContextProperties
protected void processContextProperties(String file)
throws Exception
Process the templatePath. We hold off processing so that
when run as an Ant Task the project will be set, and the
project is required for correct path resolving.
processTemplatePath
protected void processTemplatePath(String templatePath)
throws Exception
Process the templatePath. We hold off processing so that
when run as an Ant Task the project will be set, and the
project is required for correct path resolving.
resolveFile
private File resolveFile(String file)
throws Exception
Resolve a file. Use the baseDir of the project if
being run as an Ant Task. A couple methods
setContextProperties
public void setContextProperties(String file)
Set the context properties that will be
fed into the initial context be the
generating process starts.
setControlTemplate
public void setControlTemplate(String controlTemplate)
[REQUIRED] Set the control template for the
generating process.
setInputEncoding
public void setInputEncoding(String inputEncoding)
Set the input (template) encoding.
setOutputDirectory
public void setOutputDirectory(File outputDirectory)
throws Exception
[REQUIRED] Set the output directory. It will be
created if it doesn't exist.
setOutputEncoding
public void setOutputEncoding(String outputEncoding)
Set the output encoding.
setOutputFile
public void setOutputFile(String outputFile)
[REQUIRED] Set the output file for the
generation process.
setProject
public void setProject(Project project)
Set the Ant project. Used when this bean is adapted
by the Ant TaskAdapter.
setTemplatePath
public void setTemplatePath(String templatePath)
[REQUIRED] Set the path where Velocity will look
for templates using the file template
loader.
setUseClasspath
public void setUseClasspath(boolean useClasspath)
Set the use of the classpath in locating templates