Class Utils


  • public class Utils
    extends Object
    • Constructor Detail

      • Utils

        public Utils()
    • Method Detail

      • Base64Encode

        public static String Base64Encode​(byte[] input,
                                          boolean addLineBreaks)
        Base 64 encode.
        Parameters:
        input - the input
        addLineBreaks - the add line breaks
        Returns:
        the string
      • removeAllNewLines

        public static String removeAllNewLines​(String str)
        Removes the all new lines.
        Parameters:
        str - the str
        Returns:
        the string
      • isLiteralString

        public static boolean isLiteralString​(String str)
        Checks if is literal string.
        Parameters:
        str - the str
        Returns:
        true, if is literal string
      • isSQLLiteralString

        public static boolean isSQLLiteralString​(String str)
        Checks if is SQL literal string.
        Parameters:
        str - the str
        Returns:
        true, if is literal string
      • isNumeric

        public static boolean isNumeric​(String str)
        Checks if value represented in string is numeric.
        Parameters:
        str - the value to test
        Returns:
        true, if is numeric
      • doesNotRequireQuotes

        public static boolean doesNotRequireQuotes​(Object obj)
        Determines if entry represented by obj does not require single quote encapsulation.
        Parameters:
        obj - the entry
        Returns:
        true, if single quotes not required
      • isInParenthesis

        public static boolean isInParenthesis​(String parenstring)
        Checks if is in parenthesis.
        Parameters:
        parenstring - the parenstring
        Returns:
        true, if is in parenthesis
      • isCommaList

        public static boolean isCommaList​(String commastring)
      • isAggFunction

        public static boolean isAggFunction​(String aggfunstr)
        Checks if is agg function.
        Parameters:
        aggfunstr - the aggfunstr
        Returns:
        true, if is agg function
      • getParenContents

        public static String getParenContents​(String parenstring)
        Gets the paren contents.
        Parameters:
        parenstring - the parenstring
        Returns:
        the paren contents
      • stringToLong

        public static long stringToLong​(String str,
                                        long uponError)
        String to long.
        Parameters:
        str - the str
        uponError - the upon error
        Returns:
        the long
      • stringToInt

        public static int stringToInt​(String str,
                                      int uponError)
        String to int.
        Parameters:
        str - the str
        uponError - the upon error
        Returns:
        the int
      • replaceAll

        public static String replaceAll​(String input,
                                        String forReplace,
                                        String replaceWith)
        Replace all.
        Parameters:
        input - the input
        forReplace - the for replace
        replaceWith - the replace with
        Returns:
        the string
      • handleQuotedString

        public static String handleQuotedString​(String quotedString)
        Handle quoted string.
        Parameters:
        quotedString - the quoted string
        Returns:
        the string
      • handleQuotedIdentifier

        public static String handleQuotedIdentifier​(String quotedString)
      • isParameterizedStr

        public static boolean isParameterizedStr​(String value)
        Checks if is parameterized str.
        Parameters:
        value - the value
        Returns:
        true, if is parameterized str
      • hasPossibleEscapedQuoteLiteral

        public static boolean hasPossibleEscapedQuoteLiteral​(String quotedString)
                                                      throws Exception
        Checks for possible escaped quote literal.
        Parameters:
        quotedString - the quoted string
        Returns:
        true, if successful
        Throws:
        Exception - the exception
      • replaceSQLwithECLEscapeChar

        public static String replaceSQLwithECLEscapeChar​(String quotedString)
                                                  throws Exception
        Replace SQ lwith ECL escape char.
        Parameters:
        quotedString - the quoted string
        Returns:
        the string
        Throws:
        Exception - the exception
      • convertECLtypeCode2SQLtype

        public static int convertECLtypeCode2SQLtype​(Utils.EclTypes ecltype)
        Translates an ecltype element to sql type int (java.sql.Types value)
        Parameters:
        ecltype - The ecl type enumerated value.
        Returns:
        The java.sql.Types value to convert to a string representation.
      • convertSQLtype2JavaClassName

        public static String convertSQLtype2JavaClassName​(int type)
        Translates a data type from an integer (java.sql.Types value) to a string that represents the corresponding class.
        Parameters:
        type - The java.sql.Types value to convert to a string representation.
        Returns:
        The class name that corresponds to the given java.sql.Types value, or "java.lang.Object" if the type has no known mapping.
      • findEnumValFromString

        public static <T extends Enum<T>> T findEnumValFromString​(Class<T> enumclass,
                                                                  String strvalue)
        Attempts to map a string value to an enum value of a given enum class. Iterates through all enum values of given enum class, and compares to given string. Returns enum value if it finds match, otherwise throws Exception
        Type Parameters:
        T - the generic type
        Parameters:
        enumclass - reference to target enumaration
        strvalue - string value to be mapped to enum value
        Returns:
        The corresponding enum value if found
        Throws:
        IllegalArgumentException - if strvalue cannot be mapped to given enum
      • isBooleanKeyWord

        public static boolean isBooleanKeyWord​(String str)
        Checks if is boolean key word.
        Parameters:
        str - the str
        Returns:
        true, if is boolean key word
      • extractUnsigned8Val

        public static BigInteger extractUnsigned8Val​(long unsigned8)
        Extracts raw (8 byte unsigned value) from Long type
        Parameters:
        unsigned8 - - 8 byte unsigned value stored in Long type
        Returns:
        raw 8 byte unsigned value stored in BigInteger