Class SQLUtils


  • public final class SQLUtils
    extends Object
    SQL utility class.
    • Constructor Detail

      • SQLUtils

        public SQLUtils()
    • Method Detail

      • getExactlyNumber

        public static Number getExactlyNumber​(String value,
                                              int radix)
        Get exactly number value and type.
        Parameters:
        value - string to be converted
        radix - radix
        Returns:
        exactly number value and type
      • getExactlyValue

        public static String getExactlyValue​(String value)
        Get exactly value for SQL expression.

        remove special char for SQL expression

        Parameters:
        value - SQL expression
        Returns:
        exactly SQL expression
      • getExactlyValue

        public static String getExactlyValue​(String value,
                                             String reservedCharacters)
        Get exactly value for SQL expression.

        remove special char for SQL expression

        Parameters:
        value - SQL expression
        reservedCharacters - characters to be reserved
        Returns:
        exactly SQL expression
      • tryGetRealContentInBackticks

        public static String tryGetRealContentInBackticks​(String value)
        Try get exactly value for backticks string.

        try get content containing backticks exactly value

        Parameters:
        value - SQL expression
        Returns:
        exactly SQL expression
      • getExactlyExpression

        public static String getExactlyExpression​(String value)
        Get exactly SQL expression.

        remove space for SQL expression

        Parameters:
        value - SQL expression
        Returns:
        exactly SQL expression
      • getExpressionWithoutOutsideParentheses

        public static String getExpressionWithoutOutsideParentheses​(String value)
        Get exactly SQL expression without outside parentheses.
        Parameters:
        value - SQL expression
        Returns:
        exactly SQL expression
      • getSubqueryTableSegmentFromTableSegment

        public static List<SubqueryTableSegment> getSubqueryTableSegmentFromTableSegment​(TableSegment tableSegment)
        Get subquery from tableSegment.
        Parameters:
        tableSegment - TableSegment
        Returns:
        exactly SubqueryTableSegment list
      • createLiteralExpression

        public static ExpressionSegment createLiteralExpression​(ASTNode astNode,
                                                                int startIndex,
                                                                int stopIndex,
                                                                String text)
        Create literal expression.
        Parameters:
        astNode - AST node
        startIndex - start index
        stopIndex - stop index
        text - text
        Returns:
        literal expression segment
      • trimSemicolon

        public static String trimSemicolon​(String sql)
        Trim the semicolon of SQL.
        Parameters:
        sql - SQL to be trim
        Returns:
        SQL without semicolon
      • trimComment

        public static String trimComment​(String sql)
        Trim the comment of SQL.
        Parameters:
        sql - SQL to be trim
        Returns:
        remove comment from SQL
      • convertLikePatternToRegex

        public static String convertLikePatternToRegex​(String pattern)
        Convert like pattern to regex.
        Parameters:
        pattern - like pattern
        Returns:
        regex