Package science.aist.gtf.visualization
Class FreemarkerPrinter<T>
- java.lang.Object
-
- science.aist.gtf.visualization.FreemarkerPrinter<T>
-
- Type Parameters:
T
- The type of the input context
- All Implemented Interfaces:
TemplateEngine<T>
- Direct Known Subclasses:
ExceptionPrinter
public class FreemarkerPrinter<T> extends Object implements TemplateEngine<T>
Printer that is based on freemarker. It will persist according to the given template files
- Since:
- 1.0
- Author:
- Oliver Krauss, Andreas Pointner
-
-
Field Summary
Fields Modifier and Type Field Description protected freemarker.template.Configuration
configuration
-
Constructor Summary
Constructors Constructor Description FreemarkerPrinter(String templateDirectory)
Creates the default configuration and set the template loading
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAdditionalTemplateValue(String key, Object value)
Adds a value that has to be used by the template (does override if exists)void
addTemplate(String name, String templateFile)
<S> void
addTemplatePreprocessor(TemplatePreprocessor<S> templatePreprocessor)
protected void
applyTemplate(String templateName, Map<String,Object> data)
Helper function to actually apply the templatevoid
process(T context, String templateFile, Writer destinationWriter)
Runs the enginevoid
removeAdditionalTemplateValue(String key)
Removes a value from the template<S> void
removeTemplatePreprocessor(TemplatePreprocessor<S> templatePreprocessor)
void
setFormat(String format)
void
transform(String template, Object o)
-
-
-
Constructor Detail
-
FreemarkerPrinter
public FreemarkerPrinter(String templateDirectory)
Creates the default configuration and set the template loading- Parameters:
templateDirectory
- if null then this class will be used for template loading, otherwise the directory which was set is used
-
-
Method Detail
-
applyTemplate
protected void applyTemplate(String templateName, Map<String,Object> data)
Helper function to actually apply the template- Parameters:
templateName
- to be applieddata
- to be printed into the template
-
addAdditionalTemplateValue
public void addAdditionalTemplateValue(String key, Object value)
Adds a value that has to be used by the template (does override if exists)- Parameters:
key
- to be usedvalue
- to be applied to the template
-
removeAdditionalTemplateValue
public void removeAdditionalTemplateValue(String key)
Removes a value from the template- Parameters:
key
- to be removed
-
setFormat
public void setFormat(String format)
-
addTemplatePreprocessor
public <S> void addTemplatePreprocessor(TemplatePreprocessor<S> templatePreprocessor)
-
removeTemplatePreprocessor
public <S> void removeTemplatePreprocessor(TemplatePreprocessor<S> templatePreprocessor)
-
process
public void process(T context, String templateFile, Writer destinationWriter)
Description copied from interface:TemplateEngine
Runs the engine- Specified by:
process
in interfaceTemplateEngine<T>
- Parameters:
context
- the context in which this should happentemplateFile
- the template filedestinationWriter
- the writer for the result
-
-