public class TextTemplate extends Object
Copy files or directories replacing parameters matching pattern
'${[a-zA-Z_0-9\-\.]+}' with values from a Map
(deprecated) or a
Properties
.
Method setTextParsingExtensions(String)
allow to set list of files
being processed when using processDirectory(File, File)
or #pro,
others are simply copied.
Constructor and Description |
---|
TextTemplate() |
TextTemplate(Map<String,String> vars)
Deprecated.
prefer use of
TextTemplate(Properties) |
TextTemplate(Properties vars) |
Modifier and Type | Method and Description |
---|---|
String |
getVariable(String name) |
Properties |
getVariables() |
void |
initFreeMarker() |
boolean |
isTrim() |
Properties |
preprocessVars(Properties unprocessedVars) |
List<String> |
processDirectory(File in,
File out)
Recursive call
#process(InputStream, OutputStream, boolean) on
each file from "in" directory to "out" directory. |
void |
processFreemarker(File in,
File out) |
String |
processText(CharSequence text) |
String |
processText(InputStream in) |
void |
processText(InputStream is,
OutputStream os) |
void |
setFreemarkerParsingExtensions(String extensionsList) |
void |
setTextParsingExtensions(String extensionsList) |
void |
setTrim(boolean trim)
Set to true in order to trim invisible characters (spaces) from values.
|
void |
setVariable(String name,
String value) |
void |
setVariables(Map<String,String> vars)
Deprecated.
prefer use of
getVariables() then Properties
.load() |
public TextTemplate()
@Deprecated public TextTemplate(Map<String,String> vars)
TextTemplate(Properties)
public TextTemplate(Properties vars)
vars
- Properties containing keys and values for template processingpublic boolean isTrim()
public void setTrim(boolean trim)
@Deprecated public void setVariables(Map<String,String> vars)
public Properties getVariables()
public Properties preprocessVars(Properties unprocessedVars)
public String processText(CharSequence text)
public String processText(InputStream in) throws IOException
IOException
public void processText(InputStream is, OutputStream os) throws IOException
IOException
public void initFreeMarker()
public void processFreemarker(File in, File out) throws IOException, freemarker.template.TemplateException
IOException
freemarker.template.TemplateException
public List<String> processDirectory(File in, File out) throws FileNotFoundException, IOException, freemarker.template.TemplateException
#process(InputStream, OutputStream, boolean)
on
each file from "in" directory to "out" directory.in
- Directory to read files fromout
- Directory to write files toFileNotFoundException
IOException
freemarker.template.TemplateException
public void setTextParsingExtensions(String extensionsList)
extensionsList
- comma-separated list of files extensions to parsepublic void setFreemarkerParsingExtensions(String extensionsList)
Copyright © 2013 Nuxeo SA. All Rights Reserved.