Class StringTemplateSqlLocator

java.lang.Object
org.jdbi.v3.stringtemplate4.StringTemplateSqlLocator

public class StringTemplateSqlLocator extends Object
Locates SQL in .sql.stg StringTemplate group files on the classpath.
  • Method Details

    • findStringTemplate

      public static org.stringtemplate.v4.ST findStringTemplate(Class<?> type, String name)
      Locates SQL for the given type and name. Example: Given a type com.foo.Bar and a name of baz, loads a StringTemplate group file from the resource named com/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

      public static org.stringtemplate.v4.ST findStringTemplate(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:
      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

      public static org.stringtemplate.v4.STGroup findStringTemplateGroup(Class<?> type)
      Loads the StringTemplateGroup for the given type. Example: Given a type com.foo.Bar, returns a StringTemplateGroup loaded from the resource named com/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

      public static org.stringtemplate.v4.STGroup findStringTemplateGroup(String path)
      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.