Class TemplateProcessing


  • public class TemplateProcessing
    extends java.lang.Object
    Class for processing simple string templates.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String NULL_VALUE  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String processTemplate​(java.lang.String pattern, java.lang.Object object, java.lang.reflect.Executable executable, java.util.Map<java.lang.String,​java.lang.Object> parameters, TemplateConfiguration config)
      Format given pattern with given parameters and configuration.
      static java.lang.String processTemplate​(java.lang.String pattern, java.util.Map<java.lang.String,​java.lang.Object> parameters, TemplateConfiguration config)
      Format given pattern with given parameters and configuration.
      static java.lang.String retrieveValue​(TemplateConfiguration templateConfig, int index, java.lang.String[] fields, java.lang.Object object)
      Example: fields = {"object", "names", "hash"} from 'template part' = {object.names.hash} templateConfig - default
      • Methods inherited from class java.lang.Object

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

      • processTemplate

        public static java.lang.String processTemplate​(@Nonnull
                                                       java.lang.String pattern,
                                                       @Nullable
                                                       java.lang.Object object,
                                                       @Nullable
                                                       java.lang.reflect.Executable executable,
                                                       @Nullable
                                                       java.util.Map<java.lang.String,​java.lang.Object> parameters,
                                                       @Nonnull
                                                       TemplateConfiguration config)
        Format given pattern with given parameters and configuration.
        Parameters:
        pattern - text patter to format
        object - current object context
        executable - current execution context
        parameters - a map which will be used to locate reference replacements in pattern
        config - templating mechanism configuration
        Returns:
        formatted string
      • processTemplate

        public static java.lang.String processTemplate​(@Nonnull
                                                       java.lang.String pattern,
                                                       @Nullable
                                                       java.util.Map<java.lang.String,​java.lang.Object> parameters,
                                                       @Nonnull
                                                       TemplateConfiguration config)
        Format given pattern with given parameters and configuration.
        Parameters:
        pattern - text patter to format
        parameters - a map which will be used to locate reference replacements in pattern
        config - templating mechanism configuration
        Returns:
        formatted string
      • retrieveValue

        public static java.lang.String retrieveValue​(@Nonnull
                                                     TemplateConfiguration templateConfig,
                                                     int index,
                                                     @Nonnull
                                                     java.lang.String[] fields,
                                                     @Nullable
                                                     java.lang.Object object)
                                              throws java.lang.Throwable
        Example: fields = {"object", "names", "hash"} from 'template part' = {object.names.hash} templateConfig - default

        Given: object - some object names - the List containing 3 String objects with hashes: {25,32,57} hash - field, which value should be retrieved

        Result: "[25,32,57]"

        Parameters:
        templateConfig - TemplateConfiguration for result formatting
        index - Index of the current field, from the template part
        fields - Fields of the template part
        object - Value of the current field
        Returns:
        String representation of object field(s) value(s).
        Throws:
        java.lang.NoSuchFieldException - if field not found
        java.lang.Throwable