Class Template


  • public class Template
    extends java.lang.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.
    • 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 java.lang.String untemplate​(java.lang.String[] strArray, java.util.Map<java.lang.String,​java.lang.String> env, boolean bFailOnMissing, java.lang.String separator)
      Takes an array of strings and returns a concatenated string with all ${...} occurrences replaced according to the env map.
      static java.lang.String untemplate​(java.lang.String str, java.util.Map<java.lang.String,​java.lang.String> env, boolean bFailOnMissing)
      Takes a string and replaces all ${...} occurrences with env map strings.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Template

        protected Template()
        Prohibit external construction for now.
    • Method Detail

      • untemplate

        public static java.lang.String untemplate​(java.lang.String[] strArray,
                                                  java.util.Map<java.lang.String,​java.lang.String> env,
                                                  boolean bFailOnMissing,
                                                  java.lang.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 strings
        env - map of replacement strings
        bFailOnMissing - throw an exception on missing replacement string or not
        separator - separator to insert between lines or null
        Returns:
        concatenated and processed string
      • untemplate

        public static java.lang.String untemplate​(java.lang.String str,
                                                  java.util.Map<java.lang.String,​java.lang.String> env,
                                                  boolean bFailOnMissing)
        Takes a string and replaces all ${...} occurrences with env map strings.
        Parameters:
        str - string to be processed
        env - map of replacement strings
        bFailOnMissing - throw an exception on missing replacement string or not
        Returns:
        processed string