Class StringTemplateSqlLocator


  • public class StringTemplateSqlLocator
    extends java.lang.Object
    Locates SQL in .sql.stg StringTemplate group files on the classpath.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.Map<java.lang.ClassLoader,​java.util.Map<java.lang.String,​java.lang.ThreadLocal<org.stringtemplate.v4.STGroup>>> CACHE  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.stringtemplate.v4.ST findStringTemplate​(java.lang.Class<?> type, java.lang.String name)
      Locates SQL for the given type and name.
      static org.stringtemplate.v4.ST findStringTemplate​(java.lang.ClassLoader classLoader, java.lang.String path, java.lang.String name)
      Locates SQL for the given type and name.
      static org.stringtemplate.v4.ST findStringTemplate​(java.lang.String path, java.lang.String name)
      Locates SQL for the given type and name.
      static org.stringtemplate.v4.STGroup findStringTemplateGroup​(java.lang.Class<?> type)
      Loads the StringTemplateGroup for the given type.
      static org.stringtemplate.v4.STGroup findStringTemplateGroup​(java.lang.ClassLoader classLoader, java.lang.String path)
      Loads the StringTemplateGroup from the given path on the classpath.
      static org.stringtemplate.v4.STGroup findStringTemplateGroup​(java.lang.String path)
      Loads the StringTemplateGroup from the given path on the classpath.
      private static org.stringtemplate.v4.ST findTemplateInGroup​(java.lang.String path, java.lang.String name, org.stringtemplate.v4.STGroup group)  
      private static org.stringtemplate.v4.STGroup readStringTemplateGroup​(java.lang.ClassLoader classLoader, java.lang.String path)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • CACHE

        private static final java.util.Map<java.lang.ClassLoader,​java.util.Map<java.lang.String,​java.lang.ThreadLocal<org.stringtemplate.v4.STGroup>>> CACHE
    • Constructor Detail

      • StringTemplateSqlLocator

        private StringTemplateSqlLocator()
    • Method Detail

      • findStringTemplate

        public static org.stringtemplate.v4.ST findStringTemplate​(java.lang.Class<?> type,
                                                                  java.lang.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​(java.lang.String path,
                                                                  java.lang.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​(java.lang.ClassLoader classLoader,
                                                                  java.lang.String path,
                                                                  java.lang.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.
      • findTemplateInGroup

        private static org.stringtemplate.v4.ST findTemplateInGroup​(java.lang.String path,
                                                                    java.lang.String name,
                                                                    org.stringtemplate.v4.STGroup group)
      • findStringTemplateGroup

        public static org.stringtemplate.v4.STGroup findStringTemplateGroup​(java.lang.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​(java.lang.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​(java.lang.ClassLoader classLoader,
                                                                            java.lang.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.
      • readStringTemplateGroup

        private static org.stringtemplate.v4.STGroup readStringTemplateGroup​(java.lang.ClassLoader classLoader,
                                                                             java.lang.String path)