org.hibernate.tool.hbm2x
Class TemplateHelper

java.lang.Object
  extended by org.hibernate.tool.hbm2x.TemplateHelper

public class TemplateHelper
extends Object

Helper and wrapper for a Template engine (currently only FreeMarker). Exposes only the essential functions to avoid too much coupling else where.

Author:
max

Nested Class Summary
 class TemplateHelper.Templates
           
 
Field Summary
protected  freemarker.template.SimpleHash context
           
protected  freemarker.template.Configuration freeMarkerEngine
           
 
Constructor Summary
TemplateHelper()
           
 
Method Summary
 void ensureExistence(File destination)
           
protected  freemarker.template.SimpleHash getContext()
           
 File getOutputDirectory()
           
protected  String getTemplatePrefix()
           
 void init(File outputDirectory, String[] templatePaths)
           
protected  Object internalPutInContext(String key, Object value)
           
protected  Object internalRemoveFromContext(String key)
           
 void processString(String template, Writer output)
           
 void processTemplate(String templateName, Writer output, String rootContext)
          look up the template named templateName via the paths and print the content to the output
 void putInContext(String key, Object value)
           
 void removeFromContext(String key, Object expected)
           
 void setupContext()
           
 boolean templateExists(String templateName)
          Check if the template exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

freeMarkerEngine

protected freemarker.template.Configuration freeMarkerEngine

context

protected freemarker.template.SimpleHash context
Constructor Detail

TemplateHelper

public TemplateHelper()
Method Detail

init

public void init(File outputDirectory,
                 String[] templatePaths)

getOutputDirectory

public File getOutputDirectory()

putInContext

public void putInContext(String key,
                         Object value)

removeFromContext

public void removeFromContext(String key,
                              Object expected)

ensureExistence

public void ensureExistence(File destination)

getTemplatePrefix

protected String getTemplatePrefix()

getContext

protected freemarker.template.SimpleHash getContext()

processString

public void processString(String template,
                          Writer output)

setupContext

public void setupContext()

internalPutInContext

protected Object internalPutInContext(String key,
                                      Object value)

internalRemoveFromContext

protected Object internalRemoveFromContext(String key)

processTemplate

public void processTemplate(String templateName,
                            Writer output,
                            String rootContext)
look up the template named templateName via the paths and print the content to the output


templateExists

public boolean templateExists(String templateName)
Check if the template exists. Tries to search with the templatePrefix first and then secondly without the template prefix.

Parameters:
name -
Returns: