Package org.jdbi.v3.core.statement
Class MessageFormatTemplateEngine
java.lang.Object
org.jdbi.v3.core.statement.MessageFormatTemplateEngine
- All Implemented Interfaces:
TemplateEngine
Deprecated.
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());
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jdbi.v3.core.statement.TemplateEngine
TemplateEngine.Parsing -
Field Summary
Fields inherited from interface org.jdbi.v3.core.statement.TemplateEngine
NOP -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionrender(String template, StatementContext ctx) Deprecated.Renders an SQL statement from the given template, using the statement context as needed.private static voidvalidateKeys(Set<String> keySet, int expectedCount) Deprecated.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jdbi.v3.core.statement.TemplateEngine
parse
-
Constructor Details
-
MessageFormatTemplateEngine
public MessageFormatTemplateEngine()Deprecated.
-
-
Method Details
-
render
Deprecated.Description copied from interface:TemplateEngineRenders an SQL statement from the given template, using the statement context as needed.- Specified by:
renderin interfaceTemplateEngine- Parameters:
template- The SQL to rewritectx- 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
Deprecated.
-
MessageFormatformats integers with decimal separators, e.g.1000→"1,000". This hindsight realization has led us to discourage its use.