Class MessageFormatTemplateEngine

  • All Implemented Interfaces:
    TemplateEngine

    @Deprecated
    public class MessageFormatTemplateEngine
    extends java.lang.Object
    implements TemplateEngine
    Deprecated.
    MessageFormat formats integers with decimal separators, e.g. 1000"1,000". This hindsight realization has led us to discourage its use.
    Uses the equivalent of MessageFormat.format(String, Object...) as a template engine. You must use "0", "1", "2", etc as keys: start at 0, increment by 1. Keys must be numerically unique. You must Configurable.define(String, Object) as many key/value pairs as there are placeholders in the pattern string. You may define key/value pairs in any order. Keys may contain leading '0's. Any invalid use will trigger an IllegalArgumentException (or subclasses such as NumberFormatException) when render(String, StatementContext) is called – typically when the statement is about to be executed. Example usage:
    
         // select bar from foo where col = 'abc'
         jdbi.useHandle(handle -> handle.createCall("select {1} from {0} where col = ''{2}''")
             .setTemplateEngine(MessageFormatTemplateEngine.INSTANCE)
             .define("0", "foo")
             .define("1", "bar")
             .define("2", "abc")
             .invoke());
     
    • Constructor Detail

      • MessageFormatTemplateEngine

        public MessageFormatTemplateEngine()
        Deprecated.
    • Method Detail

      • render

        public java.lang.String render​(java.lang.String template,
                                       StatementContext ctx)
        Deprecated.
        Description copied from interface: TemplateEngine
        Renders an SQL statement from the given template, using the statement context as needed.
        Specified by:
        render in interface TemplateEngine
        Parameters:
        template - The SQL to rewrite
        ctx - The statement context for the statement being executed
        Returns:
        something which can provide the actual SQL to prepare a statement from and which can bind the correct arguments to that prepared statement
      • validateKeys

        private static void validateKeys​(java.util.Set<java.lang.String> keySet,
                                         int expectedCount)
        Deprecated.