public abstract class AbstractTemplateEngine extends Object implements ITemplateEngine
| Modifier and Type | Field and Description |
|---|---|
protected Map |
formats
Formats to use for formatting of values.
|
protected Reader |
template
Reader that contains the template.
|
| Constructor and Description |
|---|
AbstractTemplateEngine() |
| Modifier and Type | Method and Description |
|---|---|
protected Object |
escapeSpecialCharacters(Object value)
Escape special chracters { and } with \{ and \}
otherwise, RTF document generated is not valid.
|
IContext |
getContext() |
Format |
getDefaultFormat(Class clazz)
Get the default format for a given class.
|
IContext |
initializeContext()
Initialize context.
|
void |
merge(File file)
Merge.
|
void |
merge(String file)
Merge.
|
void |
merge(Writer writer)
Merge.
|
protected abstract void |
mergeWithTemplateEngine(Writer writer) |
boolean |
mustBeEscaped(Object value)
Return true if value must be escaped and false otherwise
|
void |
put(String key,
Object value)
Put a value for the given key.
|
protected void |
setContext(IContext context) |
void |
setDefaultFormat(Class clazz,
Format format)
Set the default format for a given class.
|
void |
setFormatMap(Map commonFormats)
Use a pre-populated formats map as the map for this template
|
void |
setGlobalContext(IContext globalContext)
Use a pre-populated Context.
|
void |
setTemplate(Reader template)
Set the template to use
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitnewContextprotected Map formats
protected Reader template
public void put(String key, Object value)
put in interface ITemplateEnginekey - value - public void merge(String file) throws Exception
merge in interface ITemplateEnginefile - name of file to merge intoExceptionpublic void merge(File file) throws Exception
merge in interface ITemplateEnginefile - file to merge intoExceptionpublic void merge(Writer writer) throws Exception
ITemplateEnginemerge in interface ITemplateEnginewriter - writer to merge intoExceptionpublic void setFormatMap(Map commonFormats)
commonFormats - a pre-built map of formatspublic void setDefaultFormat(Class clazz, Format format)
setDefaultFormat in interface ITemplateEngineclazz - class to set format forformat - format to use for instances of the given classpublic Format getDefaultFormat(Class clazz)
clazz - class to get default format forprotected void setContext(IContext context)
public IContext getContext()
getContext in interface ITemplateEnginepublic void setTemplate(Reader template)
ITemplateEnginesetTemplate in interface ITemplateEnginepublic boolean mustBeEscaped(Object value)
value - protected Object escapeSpecialCharacters(Object value)
value - public IContext initializeContext()
ITemplateEngineinitializeContext in interface ITemplateEnginepublic void setGlobalContext(IContext globalContext)
setGlobalContext in interface ITemplateEngineinnerContext - a pre-populated Context objectCopyright © 2020 Mice S.r.l. All rights reserved.