Class TemplateHelper

java.lang.Object
org.hibernate.tool.internal.export.common.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
  • Field Details

    • freeMarkerEngine

      protected freemarker.template.Configuration freeMarkerEngine
    • context

      protected freemarker.template.SimpleHash context
  • Constructor Details

    • TemplateHelper

      public TemplateHelper()
  • Method Details

    • 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: