Package dk.netarkivet.common.utils
Class Template
- java.lang.Object
-
- dk.netarkivet.common.utils.Template
-
public class Template extends Object
Simple template engine functions that replaces %{...} in an array of strings or a single string. Error handling can be deduced from the unit test. Uses %{..} to avoid replacing ${} strings which are not our concern
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Template()
Prohibit external construction for now.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
untemplate(String[] strArray, Map<String,String> env, boolean bFailOnMissing, String separator)
Takes an array of strings and returns a concatenated string with all %{...} occurrences replaced according to the env map.static String
untemplate(String str, Map<String,String> env, boolean bFailOnMissing)
Takes a string and replaces all %{...} occurrences with env map strings.
-
-
-
Method Detail
-
untemplate
public static String untemplate(String[] strArray, Map<String,String> env, boolean bFailOnMissing, String separator)
Takes an array of strings and returns a concatenated string with all %{...} occurrences replaced according to the env map.- Parameters:
strArray
- array of strings to be processed with env stringsenv
- map of replacement stringsbFailOnMissing
- throw an exception on missing replacement string or notseparator
- separator to insert between lines or null- Returns:
- concatenated and processed string
-
untemplate
public static String untemplate(String str, Map<String,String> env, boolean bFailOnMissing)
Takes a string and replaces all %{...} occurrences with env map strings.- Parameters:
str
- string to be processedenv
- map of replacement stringsbFailOnMissing
- throw an exception on missing replacement string or not- Returns:
- processed string
-
-