org.javagen.agile.core.emitter.template
Class FreemarkerCodeGenerator

java.lang.Object
  extended by org.javagen.agile.core.emitter.template.FreemarkerCodeGenerator
All Implemented Interfaces:
TemplateGenerator

public class FreemarkerCodeGenerator
extends Object
implements TemplateGenerator

FreeMarker template implementation.

At the time of this release FreeMarker was a more capable and uptodate template engine than Velocity and thus the prefered template engine for JavaGen.

TODO do we need to add support for freemarker.properties configuration?

Author:
Richard Easterling

Field Summary
protected  freemarker.template.Configuration cfg
           
static String DEFAULT_TEMPLATE_LOCATION_PATH
           
protected  String templateBasePath
           
protected  WriterFactory writerFactory
           
 
Constructor Summary
FreemarkerCodeGenerator()
           
 
Method Summary
 void gen(String templatePath, File outFile, Map<String,Object> root)
          Process templates.
protected  freemarker.template.Configuration getConfiguration()
           
 String getTemplateBasePath()
          Base path to load templates from which can be prefixed with classpath: or file: and a path to locate the file in any context.
 WriterFactory getWriterFactory()
           
 void setTemplateBasePath(String templateBasePath)
           
 void setWriterFactory(WriterFactory writerFactory)
          Provide a hook for tools to intercept the output sinks.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TEMPLATE_LOCATION_PATH

public static final String DEFAULT_TEMPLATE_LOCATION_PATH
See Also:
Constant Field Values

templateBasePath

protected String templateBasePath

cfg

protected freemarker.template.Configuration cfg

writerFactory

protected WriterFactory writerFactory
Constructor Detail

FreemarkerCodeGenerator

public FreemarkerCodeGenerator()
Method Detail

getConfiguration

protected freemarker.template.Configuration getConfiguration()

gen

public void gen(String templatePath,
                File outFile,
                Map<String,Object> root)
Process templates.

Specified by:
gen in interface TemplateGenerator
Parameters:
templatePath - relative to templateBasePath
outFile - output file
root - usualy a combined context based on current model node.

getTemplateBasePath

public String getTemplateBasePath()
Base path to load templates from which can be prefixed with classpath: or file: and a path to locate the file in any context.

Specified by:
getTemplateBasePath in interface TemplateGenerator

setTemplateBasePath

public void setTemplateBasePath(String templateBasePath)

setWriterFactory

public void setWriterFactory(WriterFactory writerFactory)
Description copied from interface: TemplateGenerator
Provide a hook for tools to intercept the output sinks.

Specified by:
setWriterFactory in interface TemplateGenerator

getWriterFactory

public WriterFactory getWriterFactory()


Copyright 2006-2006-2007 Outsource Cafe Inc.. All Rights Reserved.