Class SqlRegexpHelper


  • public class SqlRegexpHelper
    extends java.lang.Object
    Helper class that knows how to locate, load and apply SQL regexps such as defined in build.properties and run by build.xml (from build-config)
    • Constructor Summary

      Constructors 
      Constructor Description
      SqlRegexpHelper​(java.io.File propertiesFile, java.lang.String sgbdName)
      Constructs a new SqlRegexpHelper from a properties file
      SqlRegexpHelper​(java.util.concurrent.Callable<java.io.InputStream> propertiesSource, java.lang.String sgbdName)
      Constructs a new SqlRegexpHelper from a properties stream
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String filter​(java.lang.String line)
      Performs all substitutions on the given string
      static java.lang.String findDbName​(java.io.File dbProperties)
      Helper to find jdbc vendor from db.properties.
      static java.lang.String findDbName​(java.lang.String jdbcUrl)
      Extracts the database type (mysql, oracle...) from the JDBC URL
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SqlRegexpHelper

        public SqlRegexpHelper​(java.io.File propertiesFile,
                               java.lang.String sgbdName)
                        throws java.lang.Exception
        Constructs a new SqlRegexpHelper from a properties file
        Parameters:
        propertiesFile - contains the regexps
        sgbdName - rdbms vendor to use
        Throws:
        java.io.IOException - if something goes wrong with reading the config file
        java.lang.Exception
      • SqlRegexpHelper

        public SqlRegexpHelper​(java.util.concurrent.Callable<java.io.InputStream> propertiesSource,
                               java.lang.String sgbdName)
                        throws java.lang.Exception
        Constructs a new SqlRegexpHelper from a properties stream
        Parameters:
        propertiesFile - contains the regexps
        sgbdName - rdbms vendor to use
        Throws:
        java.io.IOException - if something goes wrong with reading the stream
        java.lang.Exception
    • Method Detail

      • findDbName

        public static java.lang.String findDbName​(java.io.File dbProperties)
                                           throws java.lang.Exception
        Helper to find jdbc vendor from db.properties. uses same regexp as build.xml from build-config
        Parameters:
        dbProperties - input path for db.properties
        Returns:
        'mysql' or any other vendor identifier
        Throws:
        java.lang.Exception - if vendor cannot be found for any reason
      • findDbName

        public static java.lang.String findDbName​(java.lang.String jdbcUrl)
        Extracts the database type (mysql, oracle...) from the JDBC URL
        Parameters:
        jdbcUrl - JDBC URL to be parsed
        Returns:
        databaseType for a URL such as jdbc:databaseType:someInfo
      • filter

        public java.lang.String filter​(java.lang.String line)
        Performs all substitutions on the given string
        Parameters:
        line - input
        Returns:
        output, possibly modified by substitutions