类 StringUtils


  • public class StringUtils
    extends Object
    Various utility methods for converting to/from byte arrays in the platform encoding and several other String operations.
    • 构造器详细资料

      • StringUtils

        public StringUtils()
    • 方法详细资料

      • dumpAsHex

        public static String dumpAsHex​(byte[] byteBuffer,
                                       int length)
        Returns the given bytes as a hex and ASCII dump (up to length bytes).
        参数:
        byteBuffer - the data to dump as hex
        length - the number of bytes to print
        返回:
        a hex and ASCII dump
      • toHexString

        public static String toHexString​(byte[] byteBuffer,
                                         int length)
        Converts the given byte array into Hex String, stopping at given length.
        参数:
        byteBuffer - the byte array to convert
        length - the number of bytes from the given array to convert
        返回:
        a String containing the Hex representation of the given bytes
      • firstNonWsCharUc

        public static char firstNonWsCharUc​(String searchIn)
        Returns the first non-whitespace char, converted to upper case
        参数:
        searchIn - the string to search in
        返回:
        the first non-whitespace character, upper cased.
      • firstNonWsCharUc

        public static char firstNonWsCharUc​(String searchIn,
                                            int startAt)
      • firstAlphaCharUc

        public static char firstAlphaCharUc​(String searchIn,
                                            int startAt)
      • fixDecimalExponent

        public static String fixDecimalExponent​(String dString)
        Adds '+' to decimal numbers that are positive (MySQL doesn't understand them otherwise
        参数:
        dString - The value as a string
        返回:
        String the string with a '+' added (if needed)
      • getBytes

        public static byte[] getBytes​(String s,
                                      String encoding)
        Returns the byte[] representation of the given string using the given encoding.
        参数:
        s - source string
        encoding - java encoding
        返回:
        bytes
      • getBytesWrapped

        public static byte[] getBytesWrapped​(String s,
                                             char beginWrap,
                                             char endWrap,
                                             String encoding)
        Returns the byte[] representation of the given string properly wrapped between the given char delimiters using the given encoding.
        参数:
        s - source string
        beginWrap - opening char delimiter
        endWrap - closing char delimiter
        encoding - java encoding
        返回:
        bytes
      • indexOfIgnoreCase

        public static int indexOfIgnoreCase​(String searchIn,
                                            String searchFor)
        Finds the position of a substring within a string ignoring case.
        参数:
        searchIn - the string to search in
        searchFor - the array of strings to search for
        返回:
        the position where searchFor is found within searchIn starting from startingPosition.
      • indexOfIgnoreCase

        public static int indexOfIgnoreCase​(int startingPosition,
                                            String searchIn,
                                            String searchFor)
        Finds the position of a substring within a string ignoring case.
        参数:
        startingPosition - the position to start the search from
        searchIn - the string to search in
        searchFor - the array of strings to search for
        返回:
        the position where searchFor is found within searchIn starting from startingPosition.
      • indexOfIgnoreCase

        public static int indexOfIgnoreCase​(int startingPosition,
                                            String searchIn,
                                            String[] searchForSequence,
                                            String openingMarkers,
                                            String closingMarkers,
                                            Set<SearchMode> searchMode)
        Finds the position of the first of a consecutive sequence of strings within a string, ignoring case, with the option to skip text delimited by given markers or within comments.

        Independently of the searchMode provided, when searching for the second and following strings SearchMode.SKIP_WHITE_SPACE will be added and SearchMode.SKIP_BETWEEN_MARKERS removed.

        参数:
        startingPosition - the position to start the search from
        searchIn - the string to search in
        searchForSequence - searchForSequence
        openingMarkers - characters that delimit the beginning of a text block to skip
        closingMarkers - characters that delimit the end of a text block to skip
        searchMode - a Set, ideally an EnumSet, containing the flags from the enum StringUtils.SearchMode that determine the behavior of the search
        返回:
        the position where searchFor is found within searchIn starting from startingPosition.
      • indexOfIgnoreCase

        public static int indexOfIgnoreCase​(int startingPosition,
                                            String searchIn,
                                            String searchFor,
                                            String openingMarkers,
                                            String closingMarkers,
                                            Set<SearchMode> searchMode)
        Finds the position of a substring within a string, ignoring case, with the option to skip text delimited by given markers or within comments.
        参数:
        startingPosition - the position to start the search from
        searchIn - the string to search in
        searchFor - the string to search for
        openingMarkers - characters that delimit the beginning of a text block to skip
        closingMarkers - characters that delimit the end of a text block to skip
        searchMode - a Set, ideally an EnumSet, containing the flags from the enum StringUtils.SearchMode that determine the behavior of the search
        返回:
        the position where searchFor is found within searchIn starting from startingPosition.
      • indexOfIgnoreCase

        public static int indexOfIgnoreCase​(int startingPosition,
                                            String searchIn,
                                            String searchFor,
                                            String openingMarkers,
                                            String closingMarkers,
                                            String overridingMarkers,
                                            Set<SearchMode> searchMode)
        Finds the position of a substring within a string, ignoring case, with the option to skip text delimited by given markers or within comments.
        参数:
        startingPosition - the position to start the search from
        searchIn - the string to search in
        searchFor - the string to search for
        openingMarkers - characters that delimit the beginning of a text block to skip
        closingMarkers - characters that delimit the end of a text block to skip
        overridingMarkers - the subset of openingMarkers that override the remaining markers, e.g., if openingMarkers = "'(" and overridingMarkers = "'" then the block between the outer parenthesis in "start ('max('); end" is strictly consumed, otherwise the suffix " end" would end up being consumed too in the process of handling the nested parenthesis.
        searchMode - a Set, ideally an EnumSet, containing the flags from the enum StringUtils.SearchMode that determine the behavior of the search
        返回:
        the position where searchFor is found within searchIn starting from startingPosition.
      • indexOfNextAlphanumericChar

        public static int indexOfNextAlphanumericChar​(int startingPosition,
                                                      String searchIn,
                                                      String openingMarkers,
                                                      String closingMarkers,
                                                      String overridingMarkers,
                                                      Set<SearchMode> searchMode)
        Finds the position of the next alphanumeric character within a string, with the option to skip text delimited by given markers or within comments.
        参数:
        startingPosition - the position to start the search from
        searchIn - the string to search in
        openingMarkers - characters that delimit the beginning of a text block to skip
        closingMarkers - characters that delimit the end of a text block to skip
        overridingMarkers - the subset of openingMarkers that override the remaining markers, e.g., if openingMarkers = "'(" and overridingMarkers = "'" then the block between the outer parenthesis in "start ('max('); end" is strictly consumed, otherwise the suffix " end" would end up being consumed too in the process of handling the nested parenthesis.
        searchMode - a Set, ideally an EnumSet, containing the flags from the enum StringUtils.SearchMode that determine the behavior of the search
        返回:
        the position where the next non-whitespace character is found within searchIn starting from startingPosition.
      • indexOfNextNonWsChar

        public static int indexOfNextNonWsChar​(int startingPosition,
                                               String searchIn,
                                               String openingMarkers,
                                               String closingMarkers,
                                               String overridingMarkers,
                                               Set<SearchMode> searchMode)
        Finds the position of the next non-whitespace character within a string, with the option to skip text delimited by given markers or within comments.
        参数:
        startingPosition - the position to start the search from
        searchIn - the string to search in
        openingMarkers - characters that delimit the beginning of a text block to skip
        closingMarkers - characters that delimit the end of a text block to skip
        overridingMarkers - the subset of openingMarkers that override the remaining markers, e.g., if openingMarkers = "'(" and overridingMarkers = "'" then the block between the outer parenthesis in "start ('max('); end" is strictly consumed, otherwise the suffix " end" would end up being consumed too in the process of handling the nested parenthesis.
        searchMode - a Set, ideally an EnumSet, containing the flags from the enum StringUtils.SearchMode that determine the behavior of the search
        返回:
        the position where the next non-whitespace character is found within searchIn starting from startingPosition.
      • indexOfNextWsChar

        public static int indexOfNextWsChar​(int startingPosition,
                                            String searchIn,
                                            String openingMarkers,
                                            String closingMarkers,
                                            String overridingMarkers,
                                            Set<SearchMode> searchMode)
        Finds the position of the next whitespace character within a string, with the option to skip text delimited by given markers or within comments.
        参数:
        startingPosition - the position to start the search from
        searchIn - the string to search in
        openingMarkers - characters that delimit the beginning of a text block to skip
        closingMarkers - characters that delimit the end of a text block to skip
        overridingMarkers - the subset of openingMarkers that override the remaining markers, e.g., if openingMarkers = "'(" and overridingMarkers = "'" then the block between the outer parenthesis in "start ('max('); end" is strictly consumed, otherwise the suffix " end" would end up being consumed too in the process of handling the nested parenthesis.
        searchMode - a Set, ideally an EnumSet, containing the flags from the enum StringUtils.SearchMode that determine the behavior of the search
        返回:
        the position where the next whitespace character is found within searchIn starting from startingPosition.
      • isCharEqualIgnoreCase

        protected static boolean isCharEqualIgnoreCase​(char charToCompare,
                                                       char compareToCharUC,
                                                       char compareToCharLC)
      • split

        public static List<String> split​(String stringToSplit,
                                         String delimiter,
                                         boolean trim)
        Splits stringToSplit into a list, using the given delimiter
        参数:
        stringToSplit - the string to split
        delimiter - the string to split on
        trim - should the split strings be whitespace trimmed?
        返回:
        the list of strings, split by delimiter
        抛出:
        IllegalArgumentException - if an error occurs
      • split

        public static List<String> split​(String stringToSplit,
                                         String delimiter,
                                         String openingMarkers,
                                         String closingMarkers,
                                         boolean trim)
        Splits stringToSplit into a list, using the given delimiter and skipping all between the given markers.
        参数:
        stringToSplit - the string to split
        delimiter - the string to split on
        openingMarkers - characters that delimit the beginning of a text block to skip
        closingMarkers - characters that delimit the end of a text block to skip
        trim - should the split strings be whitespace trimmed?
        返回:
        the list of strings, split by delimiter
        抛出:
        IllegalArgumentException - if an error occurs
      • split

        public static List<String> split​(String stringToSplit,
                                         String delimiter,
                                         String openingMarkers,
                                         String closingMarkers,
                                         boolean trim,
                                         Set<SearchMode> searchMode)
        Splits stringToSplit into a list, using the given delimiter and skipping all between the given markers.
        参数:
        stringToSplit - the string to split
        delimiter - the string to split on
        openingMarkers - characters that delimit the beginning of a text block to skip
        closingMarkers - characters that delimit the end of a text block to skip
        trim - should the split strings be whitespace trimmed?
        searchMode - a Set, ideally an EnumSet, containing the flags from the enum StringUtils.SearchMode that determine the behaviour of the search
        返回:
        the list of strings, split by delimiter
        抛出:
        IllegalArgumentException - if an error occurs
      • split

        public static List<String> split​(String stringToSplit,
                                         String delimiter,
                                         String openingMarkers,
                                         String closingMarkers,
                                         String overridingMarkers,
                                         boolean trim)
        Splits stringToSplit into a list, using the given delimiter and skipping all between the given markers.
        参数:
        stringToSplit - the string to split
        delimiter - the string to split on
        openingMarkers - characters that delimit the beginning of a text block to skip
        closingMarkers - characters that delimit the end of a text block to skip
        overridingMarkers - the subset of openingMarkers that override the remaining markers, e.g., if openingMarkers = "'(" and overridingMarkers = "'" then the block between the outer parenthesis in "start ('max('); end" is strictly consumed, otherwise the suffix " end" would end up being consumed too in the process of handling the nested parenthesis.
        trim - should the split strings be whitespace trimmed?
        返回:
        the list of strings, split by delimiter
        抛出:
        IllegalArgumentException - if an error occurs
      • split

        public static List<String> split​(String stringToSplit,
                                         String delimiter,
                                         String openingMarkers,
                                         String closingMarkers,
                                         String overridingMarkers,
                                         boolean trim,
                                         Set<SearchMode> searchMode)
        Splits stringToSplit into a list, using the given delimiter and skipping all between the given markers.
        参数:
        stringToSplit - the string to split
        delimiter - the string to split on
        openingMarkers - characters that delimit the beginning of a text block to skip
        closingMarkers - characters that delimit the end of a text block to skip
        overridingMarkers - the subset of openingMarkers that override the remaining markers, e.g., if openingMarkers = "'(" and overridingMarkers = "'" then the block between the outer parenthesis in "start ('max('); end" is strictly consumed, otherwise the suffix " end" would end up being consumed too in the process of handling the nested parenthesis.
        trim - should the split strings be whitespace trimmed?
        searchMode - a Set, ideally an EnumSet, containing the flags from the enum StringUtils.SearchMode that determine the behaviour of the search
        返回:
        the list of strings, split by delimiter
        抛出:
        IllegalArgumentException - if an error occurs
      • regionMatchesIgnoreCase

        public static boolean regionMatchesIgnoreCase​(String searchIn,
                                                      int startAt,
                                                      String searchFor)
        Determines whether or not the string 'searchIn' contains the string 'searchFor', disregarding case and starting at 'startAt'. Shorthand for a String.regionMatch(...)
        参数:
        searchIn - the string to search in
        startAt - the position to start at
        searchFor - the string to search for
        返回:
        whether searchIn starts with searchFor, ignoring case
      • startsWithIgnoreCase

        public static boolean startsWithIgnoreCase​(String searchIn,
                                                   String searchFor)
        Determines whether or not the string 'searchIn' starts with the string 'searchFor', dis-regarding case. Shorthand for a String.regionMatch(...)
        参数:
        searchIn - the string to search in
        searchFor - the string to search for
        返回:
        whether searchIn starts with searchFor, ignoring case
      • startsWithIgnoreCaseAndNonAlphaNumeric

        public static boolean startsWithIgnoreCaseAndNonAlphaNumeric​(String searchIn,
                                                                     String searchFor)
        Determines whether or not the string 'searchIn' starts with the string 'searchFor', disregarding case,leading whitespace and non-alphanumeric characters.
        参数:
        searchIn - the string to search in
        searchFor - the string to search for
        返回:
        true if the string starts with 'searchFor' ignoring whitespace
      • startsWithIgnoreCaseAndWs

        public static boolean startsWithIgnoreCaseAndWs​(String searchIn,
                                                        String searchFor)
        Determines whether or not the string 'searchIn' starts with the string 'searchFor', disregarding case and leading whitespace
        参数:
        searchIn - the string to search in
        searchFor - the string to search for
        返回:
        true if the string starts with 'searchFor' ignoring whitespace
      • startsWithIgnoreCaseAndWs

        public static boolean startsWithIgnoreCaseAndWs​(String searchIn,
                                                        String searchFor,
                                                        int beginPos)
        Determines whether or not the string 'searchIn' contains the string 'searchFor', disregarding case and leading whitespace
        参数:
        searchIn - the string to search in
        searchFor - the string to search for
        beginPos - where to start searching
        返回:
        true if the string starts with 'searchFor' ignoring whitespace
      • startsWithIgnoreCaseAndWs

        public static int startsWithIgnoreCaseAndWs​(String searchIn,
                                                    String[] searchFor)
        Determines whether or not the string 'searchIn' starts with one of the strings in 'searchFor', disregarding case and leading whitespace
        参数:
        searchIn - the string to search in
        searchFor - the string array to search for
        返回:
        the 'searchFor' array index that matched or -1 if none matches
      • endsWithIgnoreCase

        public static boolean endsWithIgnoreCase​(String searchIn,
                                                 String searchFor)
        Determines whether or not the string 'searchIn' ends with the string 'searchFor', dis-regarding case starting at 'startAt' Shorthand for a String.regionMatch(...)
        参数:
        searchIn - the string to search in
        searchFor - the string to search for
        返回:
        whether searchIn ends with searchFor, ignoring case
      • stripEnclosure

        public static byte[] stripEnclosure​(byte[] source,
                                            String prefix,
                                            String suffix)
        参数:
        source - bytes to strip
        prefix - prefix
        suffix - suffix
        返回:
        result bytes
      • toAsciiString

        public static String toAsciiString​(byte[] buffer)
        Returns the bytes as an ASCII String.
        参数:
        buffer - the bytes representing the string
        返回:
        The ASCII String.
      • toAsciiString

        public static String toAsciiString​(byte[] buffer,
                                           int startPos,
                                           int length)
        Returns the bytes as an ASCII String.
        参数:
        buffer - the bytes to convert
        startPos - the position to start converting
        length - the length of the string to convert
        返回:
        the ASCII string
      • toAsciiCharArray

        public static char[] toAsciiCharArray​(byte[] buffer,
                                              int startPos,
                                              int length)
        Returns the bytes as an ASCII String.
        参数:
        buffer - the bytes to convert
        startPos - the position to start converting
        length - the length of the string to convert
        返回:
        the ASCII char array
      • wildCompareIgnoreCase

        public static boolean wildCompareIgnoreCase​(String searchIn,
                                                    String searchFor)
        Compares searchIn against searchForWildcard with wildcards, in a case insensitive manner.
        参数:
        searchIn - the string to search in
        searchFor - the string to search for, using the 'standard' SQL wildcard chars of '%' and '_'
        返回:
        true if matches
      • lastIndexOf

        public static int lastIndexOf​(byte[] s,
                                      char c)
      • indexOf

        public static int indexOf​(byte[] s,
                                  char c)
      • isNullOrEmpty

        public static boolean isNullOrEmpty​(String str)
      • nullSafeEqual

        public static boolean nullSafeEqual​(String str1,
                                            String str2)
        Two given strings are considered equal if both are null or if they have the same string value.
        参数:
        str1 - first string to compare
        str2 - fecond string to compare
        返回:
        true if both strings are null or have the same value
      • stripCommentsAndHints

        public static String stripCommentsAndHints​(String source,
                                                   String openingMarkers,
                                                   String closingMarkers,
                                                   boolean allowBackslashEscapes)
        Removes comments and hints from the given string.
        参数:
        source - the query string to clean up.
        openingMarkers - characters that delimit the beginning of a text block to skip
        closingMarkers - characters that delimit the end of a text block to skip
        allowBackslashEscapes - whether or not backslash escapes are allowed
        返回:
        the query string with all comment-delimited data removed
      • sanitizeProcOrFuncName

        public static String sanitizeProcOrFuncName​(String src)
        Next two functions are to help DBMD check if the given string is in form of database.name and return it as "database";"name" with comments removed. If string is NULL or wildcard (%), returns null and exits. First, we sanitize...
        参数:
        src - the source string
        返回:
        the input string with all comment-delimited data removed
      • splitDBdotName

        public static List<String> splitDBdotName​(String source,
                                                  String db,
                                                  String quoteId,
                                                  boolean isNoBslashEscSet)
        Splits an entity identifier into its parts (database and entity name) and returns a list containing the two elements. If the identifier doesn't contain the database part then the argument db is used in its place and source corresponds to the full entity name. If argument source is NULL or wildcard (%), returns an empty list.
        参数:
        source - the source string
        db - database, if available
        quoteId - quote character as defined on server
        isNoBslashEscSet - is our connection in no BackSlashEscape mode
        返回:
        the input string with all comment-delimited data removed
      • getFullyQualifiedName

        public static String getFullyQualifiedName​(String db,
                                                   String entity,
                                                   String quoteId,
                                                   boolean isPedantic)
        Builds and returns a fully qualified name, quoted if necessary, for the given database entity.
        参数:
        db - database name
        entity - identifier
        quoteId - quote character as defined on server
        isPedantic - are we in pedantic mode
        返回:
        fully qualified name
      • isEmptyOrWhitespaceOnly

        public static boolean isEmptyOrWhitespaceOnly​(String str)
      • quoteIdentifier

        public static String quoteIdentifier​(String identifier,
                                             String quoteChar,
                                             boolean isPedantic)
        Surrounds identifier with quoteChar and duplicates these symbols inside the identifier.
        参数:
        quoteChar - ` or "
        identifier - in pedantic mode (connection property pedantic=true) identifier is treated as unquoted (as it is stored in the database) even if it starts and ends with quoteChar; in non-pedantic mode if identifier starts and ends with quoteChar method treats it as already quoted and doesn't modify.
        isPedantic - are we in pedantic mode
        返回:
        With quoteChar="`":
        • null -> null
        • abc -> `abc`
        • ab`c -> `ab``c`
        • ab"c -> `ab"c`
        • `ab``c` -> `ab``c` in non-pedantic mode or ```ab````c``` in pedantic mode
        With quoteChar="\"":
        • null -> null
        • abc -> "abc"
        • ab`c -> "ab`c"
        • ab"c -> "ab""c"
        • "ab""c" -> "ab""c" in non-pedantic mode or """ab""""c""" in pedantic mode
      • quoteIdentifier

        public static String quoteIdentifier​(String identifier,
                                             boolean isPedantic)
        Surrounds identifier with "`" and duplicates these symbols inside the identifier.
        参数:
        identifier - in pedantic mode (connection property pedantic=true) identifier is treated as unquoted (as it is stored in the database) even if it starts and ends with "`"; in non-pedantic mode if identifier starts and ends with "`" method treats it as already quoted and doesn't modify.
        isPedantic - are we in pedantic mode
        返回:
        • null -> null
        • abc -> `abc`
        • ab`c -> `ab``c`
        • ab"c -> `ab"c`
        • `ab``c` -> `ab``c` in non-pedantic mode or ```ab````c``` in pedantic mode
      • unQuoteIdentifier

        public static String unQuoteIdentifier​(String identifier,
                                               String quoteChar)
        Trims the identifier, removes quote chars from first and last positions and replaces double occurrences of quote char from entire identifier, i.e. converts quoted identifier into the form as it is stored in database.
        参数:
        identifier - identifier
        quoteChar - ` or "
        返回:
        • null -> null
        • abc -> abc
        • `abc` -> abc
        • `ab``c` -> ab`c
        • `"ab`c"` -> "ab`c"
        • `ab"c` -> ab"c
        • "abc" -> abc
        • "`ab""c`" -> `ab"c`
        • "ab`c" -> ab`c
      • indexOfQuoteDoubleAware

        public static int indexOfQuoteDoubleAware​(String searchIn,
                                                  String quoteChar,
                                                  int startFrom)
      • toString

        public static String toString​(byte[] value,
                                      int offset,
                                      int length,
                                      String encoding)
      • toString

        public static String toString​(byte[] value,
                                      String encoding)
      • toString

        public static String toString​(byte[] value,
                                      int offset,
                                      int length)
      • toString

        public static String toString​(byte[] value)
      • getBytes

        public static byte[] getBytes​(char[] value)
        Returns the byte[] representation of subset of the given char[] using the default/platform encoding.
        参数:
        value - chars
        返回:
        bytes
      • getBytes

        public static byte[] getBytes​(char[] c,
                                      String encoding)
        Returns the byte[] representation of subset of the given char[] using the given encoding.
        参数:
        c - chars
        encoding - java encoding
        返回:
        bytes
      • getBytes

        public static byte[] getBytes​(char[] value,
                                      int offset,
                                      int length)
      • getBytes

        public static byte[] getBytes​(char[] value,
                                      int offset,
                                      int length,
                                      String encoding)
        Returns the byte[] representation of subset of the given char[] using the given encoding.
        参数:
        value - chars
        offset - offset
        length - length
        encoding - java encoding
        返回:
        bytes
      • getBytes

        public static byte[] getBytes​(String value)
      • getBytes

        public static byte[] getBytes​(String value,
                                      int offset,
                                      int length)
      • getBytes

        public static byte[] getBytes​(String value,
                                      int offset,
                                      int length,
                                      String encoding)
      • isValidIdChar

        public static final boolean isValidIdChar​(char c)
      • hexEscapeBlock

        public static final void hexEscapeBlock​(byte[] buf,
                                                int size,
                                                java.util.function.BiConsumer<Byte,​Byte> bc)
        Used to escape binary data with hex
        参数:
        buf - source bytes
        size - number of bytes to read
        bc - consumer for low and high bits of each byte
      • appendAsHex

        public static void appendAsHex​(StringBuilder builder,
                                       byte[] bytes)
      • appendAsHex

        public static void appendAsHex​(StringBuilder builder,
                                       int value)
      • getBytesNullTerminated

        public static byte[] getBytesNullTerminated​(String value,
                                                    String encoding)
      • canHandleAsServerPreparedStatementNoCache

        public static boolean canHandleAsServerPreparedStatementNoCache​(String sql,
                                                                        ServerVersion serverVersion,
                                                                        boolean allowMultiQueries,
                                                                        boolean noBackslashEscapes,
                                                                        boolean useAnsiQuotes)
      • padString

        public static String padString​(String stringVal,
                                       int requiredLength)
      • safeIntParse

        public static int safeIntParse​(String intAsString)
      • isStrictlyNumeric

        public static boolean isStrictlyNumeric​(CharSequence cs)
        Checks is the CharSequence contains digits only. No leading sign and thousands or decimal separators are allowed.
        参数:
        cs - The CharSequence to check.
        返回:
        true if the CharSequence not empty and contains only digits, false otherwise.
      • safeTrim

        public static String safeTrim​(String toTrim)
      • stringArrayToString

        public static String stringArrayToString​(String[] elems,
                                                 String prefix,
                                                 String midDelimiter,
                                                 String lastDelimiter,
                                                 String suffix)
        Constructs a String containing all the elements in the String array bounded and joined by the provided concatenation elements. The last element uses a different delimiter.
        参数:
        elems - the String array from where to take the elements.
        prefix - the prefix of the resulting String.
        midDelimiter - the delimiter to be used between the N-1 elements
        lastDelimiter - the delimiter to be used before the last element.
        suffix - the suffix of the resulting String.
        返回:
        a String built from the provided String array and concatenation elements.
      • hasWildcards

        public static boolean hasWildcards​(String src)
        Does the string contain wildcard symbols ('%' or '_'). Used in DatabaseMetaData.
        参数:
        src - string
        返回:
        true if src contains wildcard symbols
      • getUniqueSavepointId

        public static String getUniqueSavepointId()
      • joinWithSerialComma

        public static String joinWithSerialComma​(List<?> elements)
        Joins all elements of the given list using serial comma (Oxford comma) rules. E.g.: - "A" - "A and B" - "A, B, and C"
        参数:
        elements - the elements to join
        返回:
        the String with all elements, joined by commas and "and".
      • unquoteBytes

        public static byte[] unquoteBytes​(byte[] bytes)
      • quoteBytes

        public static byte[] quoteBytes​(byte[] bytes)