Class SqlFilesLoader


  • public class SqlFilesLoader
    extends Object
    The helper class for the file(s) loading. The file(s) can be located on the classpath, in the root directory or in the user's home directory. It's used for the purpose of the SqlProcessorLoader instance creation.

    For more info please see the Tutorials.

    Author:
    Vladimir Hudec
    • Field Detail

      • logger

        protected final org.slf4j.Logger logger
        The internal slf4j logger.
      • sbStatements

        private StringBuilder sbStatements
        The string representation of the file(s) content.
    • Constructor Detail

      • SqlFilesLoader

        public SqlFilesLoader​(String fileName,
                              Class<?> loaderClass)
        Reads the file(s) content and creates a new SqlFilesLoader instance.
        Parameters:
        fileName - The name of the file to be read.
        loaderClass - Class used to detect the correct classloader.
      • SqlFilesLoader

        public SqlFilesLoader​(List<String> fileNames,
                              Class<?> loaderClass)
        Reads the file(s) content and creates a new SqlFilesLoader instance.
        Parameters:
        fileNames - The names of the files to be read.
        loaderClass - Class used to detect the correct classloader.
    • Method Detail

      • getStatements

        public static StringBuilder getStatements​(Class<?> loaderClass,
                                                  String fileName)
        Reads the file(s) content and creates a new SqlFilesLoader instance.
        Parameters:
        fileName - The name of the file to be read.
        loaderClass - Class used to detect the correct classloader.
        Returns:
        the content of the specified file(s) as a String
      • getStatements

        public static StringBuilder getStatements​(Class<?> loaderClass,
                                                  String... fileNames)
        Reads the file(s) content and creates a new SqlFilesLoader instance.
        Parameters:
        fileNames - The name sof the files to be read.
        loaderClass - Class used to detect the correct classloader.
        Returns:
        the content of the specified file(s) as a String
      • load

        private StringBuilder load​(String fileName,
                                   Class<?> loaderClass)
        Reads the file content and creates a String representation of this content.
        Parameters:
        fileName - The name of the file to be read.
        loaderClass - Class used to detect the correct classloader.
        Returns:
        the content of the specified file as a String
      • getStatements

        public StringBuilder getStatements()
        Returns the content of all read files.
        Returns:
        the content of all read files
      • toString

        public String toString()
        Returns a string representation of the object.
        Overrides:
        toString in class Object
        Returns:
        a string representation of the object