Package org.jdbi.v3.stringtemplate4
Class StringTemplateSqlLocator
java.lang.Object
org.jdbi.v3.stringtemplate4.StringTemplateSqlLocator
Locates SQL in
.sql.stg
StringTemplate group files on the classpath.-
Method Summary
Modifier and TypeMethodDescriptionstatic org.stringtemplate.v4.ST
findStringTemplate
(Class<?> type, String name) Locates SQL for the given type and name.static org.stringtemplate.v4.ST
findStringTemplate
(ClassLoader classLoader, String path, String name) Locates SQL for the given type and name.static org.stringtemplate.v4.ST
findStringTemplate
(String path, String name) Locates SQL for the given type and name.static org.stringtemplate.v4.STGroup
findStringTemplateGroup
(Class<?> type) Loads the StringTemplateGroup for the given type.static org.stringtemplate.v4.STGroup
findStringTemplateGroup
(ClassLoader classLoader, String path) Loads the StringTemplateGroup from the given path on the classpath.static org.stringtemplate.v4.STGroup
Loads the StringTemplateGroup from the given path on the classpath.
-
Method Details
-
findStringTemplate
Locates SQL for the given type and name. Example: Given a typecom.foo.Bar
and a name ofbaz
, loads a StringTemplate group file from the resource namedcom/foo/Bar.sql.stg
on the classpath, and returns the template with the given name from the group.- Parameters:
type
- the type that "owns" the given StringTemplate group file. Dictates the filename of the StringTemplate group file on the classpath.name
- the template name within the StringTemplate group.- Returns:
- the located SQL.
-
findStringTemplate
Locates SQL for the given type and name. Loads a StringTemplate group from the resource at the given path, and returns the template with the given name from the group.- Parameters:
path
- the resource path for the StringTemplate group.name
- the template name within the StringTemplate group.- Returns:
- the located SQL.
-
findStringTemplate
public static org.stringtemplate.v4.ST findStringTemplate(ClassLoader classLoader, String path, String name) Locates SQL for the given type and name. Loads a StringTemplate group from the resource at the given path, and returns the template with the given name from the group.- Parameters:
classLoader
- the classloader from which to load the resource.path
- the resource path for the StringTemplate group.name
- the template name within the StringTemplate group.- Returns:
- the located SQL.
-
findStringTemplateGroup
Loads the StringTemplateGroup for the given type. Example: Given a typecom.foo.Bar
, returns a StringTemplateGroup loaded from the resource namedcom/foo/Bar.sql.stg
on the classpath.- Parameters:
type
- the type that "owns" the given StringTemplate group file. Dictates the filename of the StringTemplate group file on the classpath.- Returns:
- the loaded StringTemplateGroup.
-
findStringTemplateGroup
Loads the StringTemplateGroup from the given path on the classpath.- Parameters:
path
- the resource path on the classpath.- Returns:
- the loaded StringTemplateGroup.
-
findStringTemplateGroup
public static org.stringtemplate.v4.STGroup findStringTemplateGroup(ClassLoader classLoader, String path) Loads the StringTemplateGroup from the given path on the classpath.- Parameters:
classLoader
- the classloader from which to load the resource.path
- the resource path on the classpath.- Returns:
- the loaded StringTemplateGroup.
-