Class StringSubstitutorTemplateEngine
java.lang.Object
org.jdbi.v3.commonstext.StringSubstitutorTemplateEngine
- All Implemented Interfaces:
TemplateEngine
Register an instance of this class (
SqlStatements.setTemplateEngine(org.jdbi.v3.core.statement.TemplateEngine)
) to use an Apache Commons Text StringSubstitutor
as a TemplateEngine
. This lets you use any pair of strings as variable delimiters, enabling the use of syntax like select * from ${foo},
select * from <foo>,
select * from %foo%, etc.
-
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
ConstructorDescriptionDefault isStringSubstitutorTemplateEngine
(Consumer<org.apache.commons.text.StringSubstitutor> customizer) Customize the givenStringSubstitutor
instance to set your preferred prefix, suffix, escape character, and perhaps other configuration. -
Method Summary
Modifier and TypeMethodDescriptionbetween
(char prefix, char suffix) between
(char prefix, char suffix, char escape) render
(String template, StatementContext ctx) Renders an SQL statement from the given template, using the statement context as needed.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.jdbi.v3.core.statement.TemplateEngine
parse
-
Constructor Details
-
StringSubstitutorTemplateEngine
public StringSubstitutorTemplateEngine()Default is${foo}
syntax. -
StringSubstitutorTemplateEngine
public StringSubstitutorTemplateEngine(Consumer<org.apache.commons.text.StringSubstitutor> customizer) Customize the givenStringSubstitutor
instance to set your preferred prefix, suffix, escape character, and perhaps other configuration. The instance is created by Jdbi, and is not shared nor re-used. Your customizer function however will be re-used for all instances.
-
-
Method Details
-
render
Description copied from interface:TemplateEngine
Renders an SQL statement from the given template, using the statement context as needed.- Specified by:
render
in 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
-
between
-
between
-
between
-
between
-