Package org.aksw.commons.util.string
Class Envsubst
- java.lang.Object
-
- org.aksw.commons.util.string.Envsubst
-
public class Envsubst extends Object
A basic 'envsubst' implementation. Just uses regex matching for substituting placeholders in a string. Does not precompile templates - we may want to switch to a fully fledged template engine for that.
-
-
Field Summary
Fields Modifier and Type Field Description static PatternPLACEHOLDER_PATTERNRegex for matching strings such as '${varname}' variable names cannot include the '}' symbol
-
Constructor Summary
Constructors Constructor Description Envsubst()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stringenvsubst(String input, java.util.function.Function<String,String> getReplacement)Perform substitution of placeholders of form "${name}"
-
-
-
Field Detail
-
PLACEHOLDER_PATTERN
public static final Pattern PLACEHOLDER_PATTERN
Regex for matching strings such as '${varname}' variable names cannot include the '}' symbol
-
-
Method Detail
-
envsubst
public static String envsubst(String input, java.util.function.Function<String,String> getReplacement)
Perform substitution of placeholders of form "${name}"- Parameters:
input- A string in which to replace placeholder patternsgetReplacement- Function that receives the variable name of a match and can return a substitution string. A result of null leaves the placeholder unchanged in order to allow for future substitution.- Returns:
-
-