|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.velocity.texen.Generator
public class Generator
A text/code generator class
Field Summary | |
---|---|
protected java.lang.String |
inputEncoding
This is the encoding for the input file(s) (templates). |
static java.lang.String |
OUTPUT_PATH
Where the texen output will placed. |
protected java.lang.String |
outputEncoding
This is the encoding for the output file(s). |
static java.lang.String |
TEMPLATE_PATH
Where the velocity templates live. |
protected VelocityEngine |
ve
Velocity engine. |
Constructor Summary | |
---|---|
Generator(java.util.Properties props)
Create a new Generator object with a given property set. |
|
Generator(java.lang.String propFile)
Create a new generator object with properties loaded from a file. |
Method Summary | |
---|---|
protected void |
fillContextDefaults(Context context)
Add properties that will aways be in the context by default |
protected void |
fillContextHash(Context context,
java.util.Hashtable objs)
Add all the contents of a Hashtable to the context. |
protected void |
fillContextProperties(Context context)
Add objects to the context from the current properties. |
protected Context |
getContext(java.util.Hashtable objs)
Create a new context and fill it with the elements of the objs Hashtable. |
static Generator |
getInstance()
Create a new generator object with default properties. |
java.lang.String |
getOutputPath()
Get the output path for the generated output. |
Template |
getTemplate(java.lang.String templateName,
java.lang.String encoding)
Returns a template, based on encoding and path. |
java.lang.String |
getTemplatePath()
Get the template path. |
java.io.Writer |
getWriter(java.lang.String path,
java.lang.String encoding)
Returns a writer, based on encoding and path. |
java.lang.String |
parse(java.lang.String controlTemplate,
Context controlContext)
Parse the control template and merge it with the control context. |
java.lang.String |
parse(java.lang.String inputTemplate,
java.lang.String outputFile)
Parse an input and write the output to an output file. |
java.lang.String |
parse(java.lang.String inputTemplate,
java.lang.String outputFile,
java.lang.String objectID,
java.lang.Object object)
Parse an input and write the output to an output file. |
java.lang.String |
parse(java.lang.String inputTemplate,
java.lang.String inputEncoding,
java.lang.String outputFile,
java.lang.String outputEncoding,
java.lang.String objectID,
java.lang.Object object)
Parse an input and write the output to an output file. |
protected void |
setDefaultProps()
Set default properties. |
void |
setInputEncoding(java.lang.String inputEncoding)
Set the input (template) encoding. |
void |
setOutputEncoding(java.lang.String outputEncoding)
Set the output encoding. |
void |
setOutputPath(java.lang.String outputPath)
Set the output path for the generated output. |
void |
setTemplatePath(java.lang.String templatePath)
Set the template path, where Texen will look for Velocity templates. |
void |
setVelocityEngine(VelocityEngine ve)
Set the velocity engine. |
void |
shutdown()
Properly shut down the generator, right now this is simply flushing and closing the file writers that we have been holding on to. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String OUTPUT_PATH
public static final java.lang.String TEMPLATE_PATH
protected java.lang.String outputEncoding
protected java.lang.String inputEncoding
protected VelocityEngine ve
Constructor Detail |
---|
public Generator(java.lang.String propFile)
propFile
- properties used to help populate the control context.public Generator(java.util.Properties props)
props
- properties object to help populate the control context.Method Detail |
---|
public static Generator getInstance()
public void setVelocityEngine(VelocityEngine ve)
ve
- protected void setDefaultProps()
public void setTemplatePath(java.lang.String templatePath)
templatePath
- template path for velocity templates.public java.lang.String getTemplatePath()
public void setOutputPath(java.lang.String outputPath)
outputPath
- public java.lang.String getOutputPath()
public void setOutputEncoding(java.lang.String outputEncoding)
outputEncoding
- public void setInputEncoding(java.lang.String inputEncoding)
inputEncoding
- public java.io.Writer getWriter(java.lang.String path, java.lang.String encoding) throws java.lang.Exception
path
- path to the output fileencoding
- output encoding
java.lang.Exception
public Template getTemplate(java.lang.String templateName, java.lang.String encoding) throws java.lang.Exception
templateName
- name of the templateencoding
- template encoding
java.lang.Exception
public java.lang.String parse(java.lang.String inputTemplate, java.lang.String outputFile) throws java.lang.Exception
inputTemplate
- input templateoutputFile
- output file
java.lang.Exception
public java.lang.String parse(java.lang.String inputTemplate, java.lang.String outputFile, java.lang.String objectID, java.lang.Object object) throws java.lang.Exception
inputTemplate
- input templateoutputFile
- output fileobjectID
- id for object to be placed in the control contextobject
- object to be placed in the context
java.lang.Exception
public java.lang.String parse(java.lang.String inputTemplate, java.lang.String inputEncoding, java.lang.String outputFile, java.lang.String outputEncoding, java.lang.String objectID, java.lang.Object object) throws java.lang.Exception
inputTemplate
- input templateinputEncoding
- template encodingoutputFile
- output fileoutputEncoding
- outputEncoding encoding of output fileobjectID
- id for object to be placed in the control contextobject
- object to be placed in the context
java.lang.Exception
public java.lang.String parse(java.lang.String controlTemplate, Context controlContext) throws java.lang.Exception
controlTemplate
- control templatecontrolContext
- control context
java.lang.Exception
protected Context getContext(java.util.Hashtable objs)
objs
- objects to place in the control context
protected void fillContextHash(Context context, java.util.Hashtable objs)
context
- context to fill with objectsobjs
- source of objectsprotected void fillContextDefaults(Context context)
context
- control context to fill with default values.protected void fillContextProperties(Context context)
context
- control context to fill with objects
that are specified in the default.properties
filepublic void shutdown()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |