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
.
Since 5.7.2, it an accept default values using syntax ${parameter:=defaultValue}. The default value will be used if parameter is null or unset.
Method setParsingExtensions(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() |
boolean |
isTrim() |
String |
process(CharSequence text) |
String |
process(InputStream in) |
void |
process(InputStream in,
OutputStream out) |
void |
process(InputStream is,
OutputStream os,
boolean processText) |
void |
processDirectory(File in,
File out)
Recursive call
process(InputStream, OutputStream, boolean) on each file from "in" directory to "out"
directory. |
void |
setParsingExtensions(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 String process(CharSequence text)
public String process(InputStream in) throws IOException
IOException
public void process(InputStream in, OutputStream out) throws IOException
IOException
public void processDirectory(File in, File out) throws FileNotFoundException, IOException
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
public void process(InputStream is, OutputStream os, boolean processText) throws IOException
processText
- if true, text is processed for parameters replacementIOException
public void setParsingExtensions(String extensionsList)
extensionsList
- comma-separated list of files extensions to parseCopyright © 2015 Nuxeo SA. All rights reserved.