Package jodd.util

Class StringUtil


  • public class StringUtil
    extends java.lang.Object
    String utilities.
    • Constructor Summary

      Constructors 
      Constructor Description
      StringUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String capitalize​(java.lang.String str)
      Capitalizes a string, changing the first letter to upper case.
      static java.lang.String compressChars​(java.lang.String s, char c)
      Compress multiple occurrences of given char into one appearance.
      static boolean containsOnlyDigits​(java.lang.CharSequence string)
      Returns true if string contains only digits.
      static boolean containsOnlyDigitsAndSigns​(java.lang.CharSequence string)
      Returns true if string contains only digits or signs plus or minus.
      static boolean containsOnlyWhitespaces​(java.lang.CharSequence string)
      Returns true if string contains only white spaces.
      static java.lang.String convertCharset​(java.lang.String source, java.nio.charset.Charset sourceCharset, java.nio.charset.Charset newCharset)
      Converts string charset.
      static java.lang.String convertTabsToSpaces​(java.lang.String line, int tabWidth)
      Converts all tabs on a line to spaces according to the provided tab width.
      static int count​(java.lang.String source, char c)  
      static int count​(java.lang.String source, char c, int start)  
      static int count​(java.lang.String source, java.lang.String sub)
      Counts substring occurrences in a source string.
      static int count​(java.lang.String source, java.lang.String sub, int start)  
      static int countIgnoreCase​(java.lang.String source, java.lang.String sub)
      Count substring occurrences in a source string, ignoring case.
      static java.lang.String crop​(java.lang.String string)
      Crops string by setting empty strings to null.
      static void cropAll​(java.lang.String... strings)
      Crops all elements of string array.
      static java.lang.String cutBetween​(java.lang.String string, java.lang.String left, java.lang.String right)
      Cuts a string between two other strings.
      static java.lang.String cutFromIndexOf​(java.lang.String string, char c)
      Cuts the string from the first index of provided char to the end.
      static java.lang.String cutFromIndexOf​(java.lang.String string, java.lang.String substring)
      Cuts the string from the first index of provided substring to the end.
      static java.lang.String cutPrefix​(java.lang.String string, java.lang.String prefix)
      Cuts prefix if exists.
      static java.lang.String cutSuffix​(java.lang.String string, java.lang.String suffix)
      Cuts sufix if exists.
      static java.lang.String cutSurrounding​(java.lang.String string, java.lang.String fix)  
      static java.lang.String cutSurrounding​(java.lang.String string, java.lang.String prefix, java.lang.String suffix)
      Removes surrounding prefix and suffixes.
      static java.lang.String cutToIndexOf​(java.lang.String string, char c)
      Cuts the string from beginning to the first index of provided char.
      static java.lang.String cutToIndexOf​(java.lang.String string, java.lang.String substring)
      Cuts the string from beginning to the first index of provided substring.
      static java.lang.String decapitalize​(java.lang.String name)
      Utility method to take a string and convert it to normal Java variable name capitalization.
      static char detectQuoteChar​(java.lang.String str)
      Detects quote character or return 0.
      static boolean endsWithChar​(java.lang.String s, char c)
      Returns if string ends with provided character.
      static boolean endsWithIgnoreCase​(java.lang.String src, java.lang.String subS)
      Tests if this string ends with the specified suffix.
      static int endsWithOne​(java.lang.String src, java.lang.String... dest)
      Checks if string ends with at least one string from the provided array.
      static int endsWithOneIgnoreCase​(java.lang.String src, java.lang.String... dest)
      Checks if string ends with at least one string from the provided array.
      static boolean equals​(java.lang.String[] as, java.lang.String[] as1)
      Compares two string arrays.
      static boolean equals​(java.lang.String s1, java.lang.String s2)
      Compares 2 strings.
      static boolean equalsIgnoreCase​(java.lang.String[] as, java.lang.String[] as1)
      Compares two string arrays.
      static int equalsOne​(java.lang.String src, java.lang.String... dest)
      Compares string with at least one from the provided array.
      static int equalsOneIgnoreCase​(java.lang.String src, java.lang.String... dest)
      Compares string with at least one from the provided array, ignoring case.
      static java.lang.String escapeJava​(java.lang.String string)
      Escapes a string using java rules.
      static java.lang.String findCommonPrefix​(java.lang.String... strings)
      Finds common prefix for several strings.
      static java.lang.String fromCamelCase​(java.lang.String input, char separator)
      Changes CamelCase string to lower case words separated by provided separator character.
      static java.lang.String ifNotNull​(java.lang.String input, java.util.function.Function<java.lang.String,​java.lang.String> stringFunction)
      Executes function on a string if not null.
      static int indexOf​(java.lang.String src, char c, int startIndex, int endIndex)
      Finds the first occurrence of a character in the given source but within limited range (start, end].
      static int[] indexOf​(java.lang.String s, java.lang.String... arr)
      Finds the very first index of a substring from the specified array.
      static int[] indexOf​(java.lang.String s, java.lang.String[] arr, int offset)
      Finds the very first index of a substring from the specified array.
      static int indexOf​(java.lang.String src, java.lang.String sub, int startIndex, int endIndex)
      Finds first occurrence of a substring in the given source but within limited range [start, end).
      static int indexOfChars​(java.lang.String string, char[] chars)  
      static int indexOfChars​(java.lang.String string, char[] chars, int startindex)
      Returns the very first index of any char from provided string, starting from specified index offset.
      static int indexOfChars​(java.lang.String string, java.lang.String chars)  
      static int indexOfChars​(java.lang.String string, java.lang.String chars, int startindex)
      Returns the very first index of any char from provided string, starting from specified index offset.
      static int indexOfIgnoreCase​(java.lang.String src, char c, int startIndex, int endIndex)
      Finds the first occurrence of a character in the given source but within limited range (start, end].
      static int indexOfIgnoreCase​(java.lang.String src, java.lang.String subS)
      Finds first index of a substring in the given source string with ignored case.
      static int[] indexOfIgnoreCase​(java.lang.String s, java.lang.String... arr)
      Finds the very first index of a substring from the specified array.
      static int[] indexOfIgnoreCase​(java.lang.String s, java.lang.String[] arr, int start)
      Finds the very first index of a substring from the specified array.
      static int indexOfIgnoreCase​(java.lang.String src, java.lang.String subS, int startIndex)
      Finds first index of a substring in the given source string with ignored case.
      static int indexOfIgnoreCase​(java.lang.String src, java.lang.String sub, int startIndex, int endIndex)
      Finds first index of a substring in the given source string and range with ignored case.
      static int indexOfNonWhitespace​(java.lang.String string)  
      static int indexOfNonWhitespace​(java.lang.String string, int startindex)  
      static int indexOfNonWhitespace​(java.lang.String string, int startindex, int endindex)  
      static int[] indexOfRegion​(java.lang.String string, java.lang.String leftBoundary, java.lang.String rightBoundary)  
      static int[] indexOfRegion​(java.lang.String string, java.lang.String leftBoundary, java.lang.String rightBoundary, char escape)  
      static int[] indexOfRegion​(java.lang.String string, java.lang.String leftBoundary, java.lang.String rightBoundary, char escape, int offset)
      Returns indexes of the first string region.
      static int[] indexOfRegion​(java.lang.String string, java.lang.String leftBoundary, java.lang.String rightBoundary, int offset)
      Returns indexes of the first region without escaping character.
      static int indexOfUnescapedChar​(java.lang.String src, char sub, char escapeChar)  
      static int indexOfUnescapedChar​(java.lang.String src, char sub, char escapeChar, int startIndex)  
      static int indexOfWhitespace​(java.lang.String string)
      Returns first index of a whitespace character.
      static int indexOfWhitespace​(java.lang.String string, int startindex)  
      static int indexOfWhitespace​(java.lang.String string, int startindex, int endindex)
      Returns first index of a whitespace character, starting from specified index offset.
      static java.lang.String insert​(java.lang.String src, java.lang.String insert)  
      static java.lang.String insert​(java.lang.String src, java.lang.String insert, int offset)
      Inserts a string on provided offset.
      static boolean isAllBlank​(java.lang.String... strings)
      Determines if string array contains just blank strings.
      static boolean isAllEmpty​(java.lang.String... strings)
      Determines if string array contains empty strings.
      static boolean isBlank​(java.lang.CharSequence string)
      Determines if a string is blank (null or containsOnlyWhitespaces(CharSequence)).
      static boolean isCharAtEqual​(java.lang.String string, int index, char charToCompare)
      Safely compares provided char with char on given location.
      static boolean isCharAtEscaped​(java.lang.String src, int ndx, char escapeChar)
      Returns true if character at provided index position is escaped by escape character.
      static boolean isEmpty​(java.lang.CharSequence string)
      Determines if a string is empty (null or zero-length).
      static boolean isNotBlank​(java.lang.CharSequence string)
      Determines if string is not blank.
      static boolean isNotEmpty​(java.lang.CharSequence string)
      Determines if a string is not empty.
      static boolean isSubstringAt​(java.lang.String string, java.lang.String substring, int offset)
      Returns true if substring exist at given offset in a string.
      static java.lang.String join​(java.lang.Object[] array)
      Joins an array of objects into one string without separators.
      static java.lang.String join​(java.lang.Object[] array, char separator)
      Joins an array of objects into one string with separator.
      static java.lang.String join​(java.lang.Object[] array, java.lang.String separator)
      Joins an array of objects into one string with separator.
      static java.lang.String join​(java.util.Collection collection, char separator)
      Joins an collection of objects into one string with separator.
      static java.lang.String join​(java.util.Collection collection, java.lang.String separator)  
      static int lastIndexOf​(java.lang.String src, char c, int startIndex, int endIndex)
      Finds last index of a character in the given source string in specified range [end, start]
      static int[] lastIndexOf​(java.lang.String s, java.lang.String... arr)
      Finds the very last index of a substring from the specified array.
      static int[] lastIndexOf​(java.lang.String s, java.lang.String[] arr, int fromIndex)
      Finds the very last index of a substring from the specified array.
      static int lastIndexOf​(java.lang.String src, java.lang.String sub, int startIndex, int endIndex)
      Finds last index of a substring in the given source string in specified range [end, start] See indexOf(String, String, int, int) for details about the speed.
      static int lastIndexOfIgnoreCase​(java.lang.String src, char c, int startIndex, int endIndex)
      Finds last index of a character in the given source string in specified range [end, start]
      static int lastIndexOfIgnoreCase​(java.lang.String s, java.lang.String subS)
      Finds last index of a substring in the given source string with ignored case.
      static int[] lastIndexOfIgnoreCase​(java.lang.String s, java.lang.String... arr)
      Finds the very last index of a substring from the specified array.
      static int[] lastIndexOfIgnoreCase​(java.lang.String s, java.lang.String[] arr, int fromIndex)
      Finds the very last index of a substring from the specified array.
      static int lastIndexOfIgnoreCase​(java.lang.String src, java.lang.String subS, int startIndex)
      Finds last index of a substring in the given source string with ignored case.
      static int lastIndexOfIgnoreCase​(java.lang.String src, java.lang.String sub, int startIndex, int endIndex)
      Finds last index of a substring in the given source string with ignored case in specified range.
      static int lastIndexOfNonWhitespace​(java.lang.String src)  
      static int lastIndexOfNonWhitespace​(java.lang.String src, int startIndex)  
      static int lastIndexOfNonWhitespace​(java.lang.String src, int startIndex, int endIndex)  
      static int lastIndexOfWhitespace​(java.lang.String src)  
      static int lastIndexOfWhitespace​(java.lang.String src, int startIndex)
      Returns last index of a whitespace.
      static int lastIndexOfWhitespace​(java.lang.String src, int startIndex, int endIndex)
      Returns last index of a whitespace.
      static java.lang.String maxCommonPrefix​(java.lang.String one, java.lang.String two)
      Returns max common prefix of two strings.
      static java.lang.String prefix​(java.lang.String string, java.lang.String prefix)
      Inserts prefix if doesn't exist.
      static java.lang.String remove​(java.lang.String string, char ch)
      Removes a single character from string.
      static java.lang.String remove​(java.lang.String s, java.lang.String sub)
      Removes all substring occurrences from the string.
      static java.lang.String removeChars​(java.lang.String src, char... chars)
      Removes set of characters from string.
      static java.lang.String removeChars​(java.lang.String src, java.lang.String chars)
      Removes all characters contained in provided string.
      static java.lang.String removeQuotes​(java.lang.String string)
      Removes starting and ending single or double quotes.
      static java.lang.String repeat​(char c, int count)  
      static java.lang.String repeat​(java.lang.String source, int count)
      Creates a new string that contains the provided string a number of times.
      static java.lang.String replace​(java.lang.String s, java.lang.String[] sub, java.lang.String[] with)
      Replaces many substring at once.
      static java.lang.String replace​(java.lang.String s, java.lang.String sub, java.lang.String with)
      Replaces all occurrences of a certain pattern in a string with a replacement string.
      static java.lang.String replaceChar​(java.lang.String s, char sub, char with)
      Replaces all occurrences of a character in a string.
      static java.lang.String replaceChars​(java.lang.String s, char[] sub, char[] with)
      Replaces all occurrences of a characters in a string.
      static java.lang.String replaceFirst​(java.lang.String s, char sub, char with)
      Replaces the very first occurrence of a character in a string.
      static java.lang.String replaceFirst​(java.lang.String s, java.lang.String sub, java.lang.String with)
      Replaces the very first occurrence of a substring with supplied string.
      static java.lang.String replaceIgnoreCase​(java.lang.String s, java.lang.String[] sub, java.lang.String[] with)
      Replaces many substring at once.
      static java.lang.String replaceLast​(java.lang.String s, char sub, char with)
      Replaces the very last occurrence of a character in a string.
      static java.lang.String replaceLast​(java.lang.String s, java.lang.String sub, java.lang.String with)
      Replaces the very last occurrence of a substring with supplied string.
      static java.lang.String reverse​(java.lang.String s)
      Reverse a string.
      static java.lang.String shorten​(java.lang.String s, int length, java.lang.String suffix)
      Shorten string to given length.
      static java.lang.String[] split​(java.lang.String src, java.lang.String delimiter)
      Splits a string in several parts (tokens) that are separated by delimiter.
      static java.lang.String[] splitc​(java.lang.String src, char delimiter)
      Splits a string in several parts (tokens) that are separated by single delimiter characters.
      static java.lang.String[] splitc​(java.lang.String src, char[] delimiters)
      Splits a string in several parts (tokens) that are separated by delimiter characters.
      static java.lang.String[] splitc​(java.lang.String src, java.lang.String d)
      Splits a string in several parts (tokens) that are separated by delimiter characters.
      static boolean startsWithChar​(java.lang.String s, char c)
      Returns if string starts with given character.
      static boolean startsWithIgnoreCase​(java.lang.String src, java.lang.String subS)
      Tests if this string starts with the specified prefix with ignored case.
      static boolean startsWithIgnoreCase​(java.lang.String src, java.lang.String subS, int startIndex)
      Tests if this string starts with the specified prefix with ignored case and with the specified prefix beginning a specified index.
      static int startsWithOne​(java.lang.String src, java.lang.String... dest)
      Checks if string starts with at least one string from the provided array.
      static int startsWithOneIgnoreCase​(java.lang.String src, java.lang.String... dest)
      Checks if string starts with at least one string from the provided array.
      static java.lang.String stripChar​(java.lang.String string, char c)
      Strips leading and trailing char from given string.
      static java.lang.String stripFromChar​(java.lang.String string, char c)
      Strips everything from the first appearance of given char.
      static java.lang.String stripLeadingChar​(java.lang.String string, char c)
      Strips leading char if string starts with one.
      static java.lang.String stripToChar​(java.lang.String string, char c)
      Strips everything up to the first appearance of given char.
      static java.lang.String stripTrailingChar​(java.lang.String string, char c)
      Strips trailing char if string ends with one.
      static java.lang.String substring​(java.lang.String string, int fromIndex, int toIndex)
      Returns a new string that is a substring of this string.
      static java.lang.String suffix​(java.lang.String string, java.lang.String suffix)
      Appends suffix if doesn't exist.
      static java.lang.String surround​(java.lang.String string, java.lang.String fix)  
      static java.lang.String surround​(java.lang.String string, java.lang.String prefix, java.lang.String suffix)
      Surrounds the string with provided prefix and suffix if such missing from string.
      static java.lang.String title​(java.lang.String string)
      Makes a title-cased string from given input.
      static java.lang.String toCamelCase​(java.lang.String input, boolean firstCharUppercase, char separator)
      Converts separated string value to CamelCase.
      static java.lang.String toHexString​(byte[] bytes)
      Converts bytes to hex string.
      static java.lang.String toLowerCase​(java.lang.String s)
      Converts all of the characters in the string to lower case, based on the portal instance's default locale.
      static java.lang.String toLowerCase​(java.lang.String s, java.util.Locale locale)
      Converts all of the characters in the string to lower case, based on the locale.
      static java.lang.String toSafeString​(java.lang.Object value)
      Converts safely an object to a string.
      static java.lang.String toString​(java.lang.Object value)
      Converts safely an object to a string.
      static java.lang.String[] toStringArray​(java.lang.Object value)
      Converts an array object to array of strings, where every element of input array is converted to a string.
      static java.lang.String toUpperCase​(java.lang.String s)
      Converts all of the characters in the string to upper case, based on the portal instance's default locale.
      static java.lang.String toUpperCase​(java.lang.String s, java.util.Locale locale)
      Converts all of the characters in the string to upper case, based on the locale.
      static void trimAll​(java.lang.String... strings)
      Trims array of strings.
      static java.lang.String trimDown​(java.lang.String string)
      Trims string and sets to null if trimmed string is empty.
      static void trimDownAll​(java.lang.String... strings)
      Trims array of strings where empty strings are set to null.
      static java.lang.String trimLeft​(java.lang.String src)
      Trim whitespaces from the left.
      static java.lang.String trimRight​(java.lang.String src)
      Trim whitespaces from the right.
      static java.lang.String truncate​(java.lang.String string, int length)
      Sets the maximum length of the string.
      static java.lang.String uncapitalize​(java.lang.String str)
      Uncapitalizes a String, changing the first letter to lower case.
      static java.lang.String unescapeJava​(java.lang.String str)
      Unescapes a string using java rules.
      • Methods inherited from class java.lang.Object

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

      • StringUtil

        public StringUtil()
    • Method Detail

      • replace

        public static java.lang.String replace​(java.lang.String s,
                                               java.lang.String sub,
                                               java.lang.String with)
        Replaces all occurrences of a certain pattern in a string with a replacement string. This is the fastest replace function known to author.
        Parameters:
        s - string to be inspected
        sub - string pattern to be replaced
        with - string that should go where the pattern was
      • replaceChar

        public static java.lang.String replaceChar​(java.lang.String s,
                                                   char sub,
                                                   char with)
        Replaces all occurrences of a character in a string.
        Parameters:
        s - input string
        sub - character to replace
        with - character to replace with
      • replaceChars

        public static java.lang.String replaceChars​(java.lang.String s,
                                                    char[] sub,
                                                    char[] with)
        Replaces all occurrences of a characters in a string.
        Parameters:
        s - input string
        sub - characters to replace
        with - characters to replace with
      • replaceFirst

        public static java.lang.String replaceFirst​(java.lang.String s,
                                                    java.lang.String sub,
                                                    java.lang.String with)
        Replaces the very first occurrence of a substring with supplied string.
        Parameters:
        s - source string
        sub - substring to replace
        with - substring to replace with
      • replaceFirst

        public static java.lang.String replaceFirst​(java.lang.String s,
                                                    char sub,
                                                    char with)
        Replaces the very first occurrence of a character in a string.
        Parameters:
        s - string
        sub - char to replace
        with - char to replace with
      • replaceLast

        public static java.lang.String replaceLast​(java.lang.String s,
                                                   java.lang.String sub,
                                                   java.lang.String with)
        Replaces the very last occurrence of a substring with supplied string.
        Parameters:
        s - source string
        sub - substring to replace
        with - substring to replace with
      • replaceLast

        public static java.lang.String replaceLast​(java.lang.String s,
                                                   char sub,
                                                   char with)
        Replaces the very last occurrence of a character in a string.
        Parameters:
        s - string
        sub - char to replace
        with - char to replace with
      • remove

        public static java.lang.String remove​(java.lang.String s,
                                              java.lang.String sub)
        Removes all substring occurrences from the string.
        Parameters:
        s - source string
        sub - substring to remove
      • removeChars

        public static java.lang.String removeChars​(java.lang.String src,
                                                   java.lang.String chars)
        Removes all characters contained in provided string.
        Parameters:
        src - source string
        chars - string containing characters to remove
      • removeChars

        public static java.lang.String removeChars​(java.lang.String src,
                                                   char... chars)
        Removes set of characters from string.
        Parameters:
        src - string
        chars - characters to remove
      • remove

        public static java.lang.String remove​(java.lang.String string,
                                              char ch)
        Removes a single character from string.
        Parameters:
        string - source string
        ch - character to remove
      • equals

        public static boolean equals​(java.lang.String s1,
                                     java.lang.String s2)
        Compares 2 strings. If one of the strings is null, false is returned. if both string are null, true is returned.
        Parameters:
        s1 - first string to compare
        s2 - second string
        Returns:
        true if strings are equal, otherwise false
      • isEmpty

        public static boolean isEmpty​(java.lang.CharSequence string)
        Determines if a string is empty (null or zero-length).
      • isAllEmpty

        public static boolean isAllEmpty​(java.lang.String... strings)
        Determines if string array contains empty strings.
        See Also:
        isEmpty(CharSequence)
      • isNotBlank

        public static boolean isNotBlank​(java.lang.CharSequence string)
        Determines if string is not blank.
      • isAllBlank

        public static boolean isAllBlank​(java.lang.String... strings)
        Determines if string array contains just blank strings.
      • containsOnlyWhitespaces

        public static boolean containsOnlyWhitespaces​(java.lang.CharSequence string)
        Returns true if string contains only white spaces.
      • containsOnlyDigits

        public static boolean containsOnlyDigits​(java.lang.CharSequence string)
        Returns true if string contains only digits.
      • containsOnlyDigitsAndSigns

        public static boolean containsOnlyDigitsAndSigns​(java.lang.CharSequence string)
        Returns true if string contains only digits or signs plus or minus.
      • isNotEmpty

        public static boolean isNotEmpty​(java.lang.CharSequence string)
        Determines if a string is not empty.
      • toString

        public static java.lang.String toString​(java.lang.Object value)
        Converts safely an object to a string.
      • toSafeString

        public static java.lang.String toSafeString​(java.lang.Object value)
        Converts safely an object to a string. If object is null an empty string is returned.
      • toStringArray

        public static java.lang.String[] toStringArray​(java.lang.Object value)
        Converts an array object to array of strings, where every element of input array is converted to a string. If input is not an array, the result will still be an array with one element.
      • capitalize

        public static java.lang.String capitalize​(java.lang.String str)
        Capitalizes a string, changing the first letter to upper case. No other letters are changed.
        Parameters:
        str - string to capitalize, may be null
        See Also:
        uncapitalize(String)
      • uncapitalize

        public static java.lang.String uncapitalize​(java.lang.String str)
        Uncapitalizes a String, changing the first letter to lower case. No other letters are changed.
        Parameters:
        str - the String to uncapitalize, may be null
        Returns:
        the uncapitalized String, null if null
        See Also:
        capitalize(String)
      • decapitalize

        public static java.lang.String decapitalize​(java.lang.String name)
        Utility method to take a string and convert it to normal Java variable name capitalization. This normally means converting the first character from upper case to lower case, but in the (unusual) special case when there is more than one character and both the first and second characters are upper case, we leave it alone.

        Thus "FooBah" becomes "fooBah" and "X" becomes "x", but "URL" stays as "URL".

        Parameters:
        name - The string to be decapitalized.
        Returns:
        The decapitalized version of the string.
      • title

        public static java.lang.String title​(java.lang.String string)
        Makes a title-cased string from given input.
      • truncate

        public static java.lang.String truncate​(java.lang.String string,
                                                int length)
        Sets the maximum length of the string. Longer strings will be simply truncated.
      • substring

        public static java.lang.String substring​(java.lang.String string,
                                                 int fromIndex,
                                                 int toIndex)
        Returns a new string that is a substring of this string. The substring begins at the specified fromIndex and extends to the character at index toIndex - 1. However, index values can be negative, and then the real index will be calculated from the strings end. This allows to specify, e.g. substring(1,-1) to cut one character from both ends of the string. If fromIndex is negative and toIndex is 0, it will return last characters of the string. Also, this method will never throw an exception if index is out of range.
      • isSubstringAt

        public static boolean isSubstringAt​(java.lang.String string,
                                            java.lang.String substring,
                                            int offset)
        Returns true if substring exist at given offset in a string.
      • split

        public static java.lang.String[] split​(java.lang.String src,
                                               java.lang.String delimiter)
        Splits a string in several parts (tokens) that are separated by delimiter. Delimiter is always surrounded by two strings! If there is no content between two delimiters, empty string will be returned for that token. Therefore, the length of the returned array will always be: #delimiters + 1.

        Method is much, much faster then regexp String.split(), and a bit faster then StringTokenizer.

        Parameters:
        src - string to split
        delimiter - split delimiter
        Returns:
        array of split strings
      • splitc

        public static java.lang.String[] splitc​(java.lang.String src,
                                                java.lang.String d)
        Splits a string in several parts (tokens) that are separated by delimiter characters. Delimiter may contains any number of character and it is always surrounded by two strings.
        Parameters:
        src - source to examine
        d - string with delimiter characters
        Returns:
        array of tokens
      • splitc

        public static java.lang.String[] splitc​(java.lang.String src,
                                                char[] delimiters)
        Splits a string in several parts (tokens) that are separated by delimiter characters. Delimiter may contains any number of character and it is always surrounded by two strings.
        Parameters:
        src - source to examine
        delimiters - char array with delimiter characters
        Returns:
        array of tokens
      • splitc

        public static java.lang.String[] splitc​(java.lang.String src,
                                                char delimiter)
        Splits a string in several parts (tokens) that are separated by single delimiter characters. Delimiter is always surrounded by two strings.
        Parameters:
        src - source to examine
        delimiter - delimiter character
        Returns:
        array of tokens
      • compressChars

        public static java.lang.String compressChars​(java.lang.String s,
                                                     char c)
        Compress multiple occurrences of given char into one appearance.
      • indexOf

        public static int indexOf​(java.lang.String src,
                                  java.lang.String sub,
                                  int startIndex,
                                  int endIndex)
        Finds first occurrence of a substring in the given source but within limited range [start, end). It is fastest possible code, but still original String.indexOf(String, int) is much faster (since it uses char[] value directly) and should be used when no range is needed.
        Parameters:
        src - source string for examination
        sub - substring to find
        startIndex - starting index
        endIndex - ending index
        Returns:
        index of founded substring or -1 if substring not found
      • indexOf

        public static int indexOf​(java.lang.String src,
                                  char c,
                                  int startIndex,
                                  int endIndex)
        Finds the first occurrence of a character in the given source but within limited range (start, end].
      • indexOfIgnoreCase

        public static int indexOfIgnoreCase​(java.lang.String src,
                                            char c,
                                            int startIndex,
                                            int endIndex)
        Finds the first occurrence of a character in the given source but within limited range (start, end].
      • indexOfIgnoreCase

        public static int indexOfIgnoreCase​(java.lang.String src,
                                            java.lang.String subS)
        Finds first index of a substring in the given source string with ignored case.
        Parameters:
        src - source string for examination
        subS - substring to find
        Returns:
        index of founded substring or -1 if substring is not found
        See Also:
        indexOfIgnoreCase(String, String, int)
      • indexOfIgnoreCase

        public static int indexOfIgnoreCase​(java.lang.String src,
                                            java.lang.String subS,
                                            int startIndex)
        Finds first index of a substring in the given source string with ignored case. This seems to be the fastest way doing this, with common string length and content (of course, with no use of Boyer-Mayer type of algorithms). Other implementations are slower: getting char array first, lower casing the source string, using String.regionMatch etc.
        Parameters:
        src - source string for examination
        subS - substring to find
        startIndex - starting index from where search begins
        Returns:
        index of founded substring or -1 if substring is not found
      • indexOfIgnoreCase

        public static int indexOfIgnoreCase​(java.lang.String src,
                                            java.lang.String sub,
                                            int startIndex,
                                            int endIndex)
        Finds first index of a substring in the given source string and range with ignored case.
        Parameters:
        src - source string for examination
        sub - substring to find
        startIndex - starting index from where search begins
        endIndex - endint index
        Returns:
        index of founded substring or -1 if substring is not found
        See Also:
        indexOfIgnoreCase(String, String, int)
      • lastIndexOfIgnoreCase

        public static int lastIndexOfIgnoreCase​(java.lang.String s,
                                                java.lang.String subS)
        Finds last index of a substring in the given source string with ignored case.
        Parameters:
        s - source string
        subS - substring to find
        Returns:
        last index of founded substring or -1 if substring is not found
        See Also:
        indexOfIgnoreCase(String, String, int), lastIndexOfIgnoreCase(String, String, int)
      • lastIndexOfIgnoreCase

        public static int lastIndexOfIgnoreCase​(java.lang.String src,
                                                java.lang.String subS,
                                                int startIndex)
        Finds last index of a substring in the given source string with ignored case.
        Parameters:
        src - source string for examination
        subS - substring to find
        startIndex - starting index from where search begins
        Returns:
        last index of founded substring or -1 if substring is not found
        See Also:
        indexOfIgnoreCase(String, String, int)
      • lastIndexOfIgnoreCase

        public static int lastIndexOfIgnoreCase​(java.lang.String src,
                                                java.lang.String sub,
                                                int startIndex,
                                                int endIndex)
        Finds last index of a substring in the given source string with ignored case in specified range.
        Parameters:
        src - source to examine
        sub - substring to find
        startIndex - starting index
        endIndex - end index
        Returns:
        last index of founded substring or -1 if substring is not found
      • lastIndexOf

        public static int lastIndexOf​(java.lang.String src,
                                      java.lang.String sub,
                                      int startIndex,
                                      int endIndex)
        Finds last index of a substring in the given source string in specified range [end, start] See indexOf(String, String, int, int) for details about the speed.
        Parameters:
        src - source to examine
        sub - substring to find
        startIndex - starting index
        endIndex - end index
        Returns:
        last index of founded substring or -1 if substring is not found
      • lastIndexOf

        public static int lastIndexOf​(java.lang.String src,
                                      char c,
                                      int startIndex,
                                      int endIndex)
        Finds last index of a character in the given source string in specified range [end, start]
      • lastIndexOfIgnoreCase

        public static int lastIndexOfIgnoreCase​(java.lang.String src,
                                                char c,
                                                int startIndex,
                                                int endIndex)
        Finds last index of a character in the given source string in specified range [end, start]
      • lastIndexOfWhitespace

        public static int lastIndexOfWhitespace​(java.lang.String src)
      • lastIndexOfWhitespace

        public static int lastIndexOfWhitespace​(java.lang.String src,
                                                int startIndex)
        Returns last index of a whitespace.
      • lastIndexOfWhitespace

        public static int lastIndexOfWhitespace​(java.lang.String src,
                                                int startIndex,
                                                int endIndex)
        Returns last index of a whitespace.
      • lastIndexOfNonWhitespace

        public static int lastIndexOfNonWhitespace​(java.lang.String src)
      • lastIndexOfNonWhitespace

        public static int lastIndexOfNonWhitespace​(java.lang.String src,
                                                   int startIndex)
      • lastIndexOfNonWhitespace

        public static int lastIndexOfNonWhitespace​(java.lang.String src,
                                                   int startIndex,
                                                   int endIndex)
      • startsWithIgnoreCase

        public static boolean startsWithIgnoreCase​(java.lang.String src,
                                                   java.lang.String subS)
        Tests if this string starts with the specified prefix with ignored case.
        Parameters:
        src - source string to test
        subS - starting substring
        Returns:
        true if the character sequence represented by the argument is a prefix of the character sequence represented by this string; false otherwise.
      • startsWithIgnoreCase

        public static boolean startsWithIgnoreCase​(java.lang.String src,
                                                   java.lang.String subS,
                                                   int startIndex)
        Tests if this string starts with the specified prefix with ignored case and with the specified prefix beginning a specified index.
        Parameters:
        src - source string to test
        subS - starting substring
        startIndex - index from where to test
        Returns:
        true if the character sequence represented by the argument is a prefix of the character sequence represented by this string; false otherwise.
      • endsWithIgnoreCase

        public static boolean endsWithIgnoreCase​(java.lang.String src,
                                                 java.lang.String subS)
        Tests if this string ends with the specified suffix.
        Parameters:
        src - String to test
        subS - suffix
        Returns:
        true if the character sequence represented by the argument is a suffix of the character sequence represented by this object; false otherwise.
      • startsWithChar

        public static boolean startsWithChar​(java.lang.String s,
                                             char c)
        Returns if string starts with given character.
      • endsWithChar

        public static boolean endsWithChar​(java.lang.String s,
                                           char c)
        Returns if string ends with provided character.
      • count

        public static int count​(java.lang.String source,
                                java.lang.String sub)
        Counts substring occurrences in a source string.
        Parameters:
        source - source string
        sub - substring to count
        Returns:
        number of substring occurrences
      • count

        public static int count​(java.lang.String source,
                                java.lang.String sub,
                                int start)
      • count

        public static int count​(java.lang.String source,
                                char c)
      • count

        public static int count​(java.lang.String source,
                                char c,
                                int start)
      • countIgnoreCase

        public static int countIgnoreCase​(java.lang.String source,
                                          java.lang.String sub)
        Count substring occurrences in a source string, ignoring case.
        Parameters:
        source - source string
        sub - substring to count
        Returns:
        number of substring occurrences
      • indexOf

        public static int[] indexOf​(java.lang.String s,
                                    java.lang.String... arr)
        Finds the very first index of a substring from the specified array. It returns an int[2] where int[0] represents the substring index and int[1] represents position where substring was found. Returns null if noting found.
        Parameters:
        s - source string
        arr - string array
      • indexOf

        public static int[] indexOf​(java.lang.String s,
                                    java.lang.String[] arr,
                                    int offset)
        Finds the very first index of a substring from the specified array. It returns an int[2] where int[0] represents the substring index and int[1] represents position where substring was found. Returns null if noting found.
        Parameters:
        s - source string
        arr - string array
        offset - starting position
      • indexOfIgnoreCase

        public static int[] indexOfIgnoreCase​(java.lang.String s,
                                              java.lang.String... arr)
        Finds the very first index of a substring from the specified array. It returns an int[2] where int[0] represents the substring index and int[1] represents position where substring was found. Returns null if noting found.
        Parameters:
        s - source string
        arr - string array
      • indexOfIgnoreCase

        public static int[] indexOfIgnoreCase​(java.lang.String s,
                                              java.lang.String[] arr,
                                              int start)
        Finds the very first index of a substring from the specified array. It returns an int[2] where int[0] represents the substring index and int[1] represents position where substring was found. Returns null if noting found.
        Parameters:
        s - source string
        arr - string array
        start - starting position
      • lastIndexOf

        public static int[] lastIndexOf​(java.lang.String s,
                                        java.lang.String... arr)
        Finds the very last index of a substring from the specified array. It returns an int[2] where int[0] represents the substring index and int[1] represents position where substring was found. Returns null if noting found.
        Parameters:
        s - source string
        arr - string array
      • lastIndexOf

        public static int[] lastIndexOf​(java.lang.String s,
                                        java.lang.String[] arr,
                                        int fromIndex)
        Finds the very last index of a substring from the specified array. It returns an int[2] where int[0] represents the substring index and int[1] represents position where substring was found. Returns null if noting found.
        Parameters:
        s - source string
        arr - string array
        fromIndex - starting position
      • lastIndexOfIgnoreCase

        public static int[] lastIndexOfIgnoreCase​(java.lang.String s,
                                                  java.lang.String... arr)
        Finds the very last index of a substring from the specified array. It returns an int[2] where int[0] represents the substring index and int[1] represents position where substring was found. Returns null if noting found.
        Parameters:
        s - source string
        arr - string array
        Returns:
        int[2]
      • lastIndexOfIgnoreCase

        public static int[] lastIndexOfIgnoreCase​(java.lang.String s,
                                                  java.lang.String[] arr,
                                                  int fromIndex)
        Finds the very last index of a substring from the specified array. It returns an int[2] where int[0] represents the substring index and int[1] represents position where substring was found. Returns null if noting found.
        Parameters:
        s - source string
        arr - string array
        fromIndex - starting position
      • equals

        public static boolean equals​(java.lang.String[] as,
                                     java.lang.String[] as1)
        Compares two string arrays.
        Parameters:
        as - first string array
        as1 - second string array
        Returns:
        true if all array elements matches
      • equalsIgnoreCase

        public static boolean equalsIgnoreCase​(java.lang.String[] as,
                                               java.lang.String[] as1)
        Compares two string arrays.
        Parameters:
        as - first string array
        as1 - second string array
        Returns:
        true if all array elements matches
      • replace

        public static java.lang.String replace​(java.lang.String s,
                                               java.lang.String[] sub,
                                               java.lang.String[] with)
        Replaces many substring at once. Order of string array is important.
        Parameters:
        s - source string
        sub - substrings array
        with - replace with array
        Returns:
        string with all occurrences of substrings replaced
      • replaceIgnoreCase

        public static java.lang.String replaceIgnoreCase​(java.lang.String s,
                                                         java.lang.String[] sub,
                                                         java.lang.String[] with)
        Replaces many substring at once. Order of string array is important.
        Parameters:
        s - source string
        sub - substrings array
        with - replace with array
        Returns:
        string with all occurrences of substrings replaced
      • equalsOne

        public static int equalsOne​(java.lang.String src,
                                    java.lang.String... dest)
        Compares string with at least one from the provided array. If at least one equal string is found, returns its index. Otherwise, -1 is returned.
      • equalsOneIgnoreCase

        public static int equalsOneIgnoreCase​(java.lang.String src,
                                              java.lang.String... dest)
        Compares string with at least one from the provided array, ignoring case. If at least one equal string is found, it returns its index. Otherwise, -1 is returned.
      • startsWithOne

        public static int startsWithOne​(java.lang.String src,
                                        java.lang.String... dest)
        Checks if string starts with at least one string from the provided array. If at least one string is matched, it returns its index. Otherwise, -1 is returned.
      • startsWithOneIgnoreCase

        public static int startsWithOneIgnoreCase​(java.lang.String src,
                                                  java.lang.String... dest)
        Checks if string starts with at least one string from the provided array. If at least one string is matched, it returns its index. Otherwise, -1 is returned.
      • endsWithOne

        public static int endsWithOne​(java.lang.String src,
                                      java.lang.String... dest)
        Checks if string ends with at least one string from the provided array. If at least one string is matched, it returns its index. Otherwise, -1 is returned.
      • endsWithOneIgnoreCase

        public static int endsWithOneIgnoreCase​(java.lang.String src,
                                                java.lang.String... dest)
        Checks if string ends with at least one string from the provided array. If at least one string is matched, it returns its index. Otherwise, -1 is returned.
      • indexOfChars

        public static int indexOfChars​(java.lang.String string,
                                       java.lang.String chars,
                                       int startindex)
        Returns the very first index of any char from provided string, starting from specified index offset. Returns index of founded char, or -1 if nothing found.
      • indexOfChars

        public static int indexOfChars​(java.lang.String string,
                                       char[] chars)
      • indexOfChars

        public static int indexOfChars​(java.lang.String string,
                                       char[] chars,
                                       int startindex)
        Returns the very first index of any char from provided string, starting from specified index offset. Returns index of founded char, or -1 if nothing found.
      • indexOfWhitespace

        public static int indexOfWhitespace​(java.lang.String string)
        Returns first index of a whitespace character.
      • indexOfWhitespace

        public static int indexOfWhitespace​(java.lang.String string,
                                            int startindex)
      • indexOfWhitespace

        public static int indexOfWhitespace​(java.lang.String string,
                                            int startindex,
                                            int endindex)
        Returns first index of a whitespace character, starting from specified index offset.
      • indexOfNonWhitespace

        public static int indexOfNonWhitespace​(java.lang.String string)
      • indexOfNonWhitespace

        public static int indexOfNonWhitespace​(java.lang.String string,
                                               int startindex)
      • indexOfNonWhitespace

        public static int indexOfNonWhitespace​(java.lang.String string,
                                               int startindex,
                                               int endindex)
      • stripLeadingChar

        public static java.lang.String stripLeadingChar​(java.lang.String string,
                                                        char c)
        Strips leading char if string starts with one.
      • stripTrailingChar

        public static java.lang.String stripTrailingChar​(java.lang.String string,
                                                         char c)
        Strips trailing char if string ends with one.
      • stripChar

        public static java.lang.String stripChar​(java.lang.String string,
                                                 char c)
        Strips leading and trailing char from given string.
      • stripToChar

        public static java.lang.String stripToChar​(java.lang.String string,
                                                   char c)
        Strips everything up to the first appearance of given char. Character IS included in the returned string.
      • stripFromChar

        public static java.lang.String stripFromChar​(java.lang.String string,
                                                     char c)
        Strips everything from the first appearance of given char. Character IS NOT included in the returned string.
      • trimAll

        public static void trimAll​(java.lang.String... strings)
        Trims array of strings. null array elements are ignored.
      • trimDownAll

        public static void trimDownAll​(java.lang.String... strings)
        Trims array of strings where empty strings are set to null. null elements of the array are ignored.
        See Also:
        trimDown(String)
      • trimDown

        public static java.lang.String trimDown​(java.lang.String string)
        Trims string and sets to null if trimmed string is empty.
      • crop

        public static java.lang.String crop​(java.lang.String string)
        Crops string by setting empty strings to null.
      • cropAll

        public static void cropAll​(java.lang.String... strings)
        Crops all elements of string array.
      • trimLeft

        public static java.lang.String trimLeft​(java.lang.String src)
        Trim whitespaces from the left.
      • trimRight

        public static java.lang.String trimRight​(java.lang.String src)
        Trim whitespaces from the right.
      • indexOfRegion

        public static int[] indexOfRegion​(java.lang.String string,
                                          java.lang.String leftBoundary,
                                          java.lang.String rightBoundary,
                                          int offset)
        Returns indexes of the first region without escaping character.
        See Also:
        indexOfRegion(String, String, String, char, int)
      • indexOfRegion

        public static int[] indexOfRegion​(java.lang.String string,
                                          java.lang.String leftBoundary,
                                          java.lang.String rightBoundary,
                                          char escape,
                                          int offset)
        Returns indexes of the first string region. Region is defined by its left and right boundary. Return value is an array of the following indexes:
        • start of left boundary index
        • region start index, i.e. end of left boundary
        • region end index, i.e. start of right boundary
        • end of right boundary index

        Escape character may be used to prefix boundaries so they can be ignored. Double escaped region will be found, and first index of the result will be decreased to include one escape character. If region is not founded, null is returned.

      • join

        public static java.lang.String join​(java.lang.Object[] array)
        Joins an array of objects into one string without separators.
      • join

        public static java.lang.String join​(java.lang.Object[] array,
                                            char separator)
        Joins an array of objects into one string with separator.
      • join

        public static java.lang.String join​(java.util.Collection collection,
                                            char separator)
        Joins an collection of objects into one string with separator.
      • join

        public static java.lang.String join​(java.util.Collection collection,
                                            java.lang.String separator)
      • join

        public static java.lang.String join​(java.lang.Object[] array,
                                            java.lang.String separator)
        Joins an array of objects into one string with separator.
      • convertCharset

        public static java.lang.String convertCharset​(java.lang.String source,
                                                      java.nio.charset.Charset sourceCharset,
                                                      java.nio.charset.Charset newCharset)
        Converts string charset. If charsets are the same, the same string is returned.
      • isCharAtEqual

        public static boolean isCharAtEqual​(java.lang.String string,
                                            int index,
                                            char charToCompare)
        Safely compares provided char with char on given location.
      • surround

        public static java.lang.String surround​(java.lang.String string,
                                                java.lang.String prefix,
                                                java.lang.String suffix)
        Surrounds the string with provided prefix and suffix if such missing from string.
      • prefix

        public static java.lang.String prefix​(java.lang.String string,
                                              java.lang.String prefix)
        Inserts prefix if doesn't exist.
      • suffix

        public static java.lang.String suffix​(java.lang.String string,
                                              java.lang.String suffix)
        Appends suffix if doesn't exist.
      • cutToIndexOf

        public static java.lang.String cutToIndexOf​(java.lang.String string,
                                                    java.lang.String substring)
        Cuts the string from beginning to the first index of provided substring.
      • cutToIndexOf

        public static java.lang.String cutToIndexOf​(java.lang.String string,
                                                    char c)
        Cuts the string from beginning to the first index of provided char.
      • cutFromIndexOf

        public static java.lang.String cutFromIndexOf​(java.lang.String string,
                                                      java.lang.String substring)
        Cuts the string from the first index of provided substring to the end.
      • cutFromIndexOf

        public static java.lang.String cutFromIndexOf​(java.lang.String string,
                                                      char c)
        Cuts the string from the first index of provided char to the end.
      • cutPrefix

        public static java.lang.String cutPrefix​(java.lang.String string,
                                                 java.lang.String prefix)
        Cuts prefix if exists.
      • cutSuffix

        public static java.lang.String cutSuffix​(java.lang.String string,
                                                 java.lang.String suffix)
        Cuts sufix if exists.
      • cutSurrounding

        public static java.lang.String cutSurrounding​(java.lang.String string,
                                                      java.lang.String prefix,
                                                      java.lang.String suffix)
        Removes surrounding prefix and suffixes.
      • cutBetween

        public static java.lang.String cutBetween​(java.lang.String string,
                                                  java.lang.String left,
                                                  java.lang.String right)
        Cuts a string between two other strings. If either of left and right is missing, nothing will be cut and null is returned. If indexes of left or right strings are wrong, empty string is returned.
      • isCharAtEscaped

        public static boolean isCharAtEscaped​(java.lang.String src,
                                              int ndx,
                                              char escapeChar)
        Returns true if character at provided index position is escaped by escape character.
      • indexOfUnescapedChar

        public static int indexOfUnescapedChar​(java.lang.String src,
                                               char sub,
                                               char escapeChar)
      • indexOfUnescapedChar

        public static int indexOfUnescapedChar​(java.lang.String src,
                                               char sub,
                                               char escapeChar,
                                               int startIndex)
      • insert

        public static java.lang.String insert​(java.lang.String src,
                                              java.lang.String insert)
      • insert

        public static java.lang.String insert​(java.lang.String src,
                                              java.lang.String insert,
                                              int offset)
        Inserts a string on provided offset.
      • repeat

        public static java.lang.String repeat​(java.lang.String source,
                                              int count)
        Creates a new string that contains the provided string a number of times.
      • repeat

        public static java.lang.String repeat​(char c,
                                              int count)
      • reverse

        public static java.lang.String reverse​(java.lang.String s)
        Reverse a string.
      • maxCommonPrefix

        public static java.lang.String maxCommonPrefix​(java.lang.String one,
                                                       java.lang.String two)
        Returns max common prefix of two strings.
      • findCommonPrefix

        public static java.lang.String findCommonPrefix​(java.lang.String... strings)
        Finds common prefix for several strings. Returns an empty string if arguments do not have a common prefix.
      • shorten

        public static java.lang.String shorten​(java.lang.String s,
                                               int length,
                                               java.lang.String suffix)
        Shorten string to given length.
      • toLowerCase

        public static java.lang.String toLowerCase​(java.lang.String s)
        Converts all of the characters in the string to lower case, based on the portal instance's default locale.
        Parameters:
        s - the string to convert
        Returns:
        the string, converted to lower case, or null if the string is null
      • toLowerCase

        public static java.lang.String toLowerCase​(java.lang.String s,
                                                   java.util.Locale locale)
        Converts all of the characters in the string to lower case, based on the locale. More efficient than String.toLowerCase.
        Parameters:
        s - the string to convert
        locale - apply this locale's rules, if null default locale is used
        Returns:
        the string, converted to lower case, or null if the string is null
      • toUpperCase

        public static java.lang.String toUpperCase​(java.lang.String s)
        Converts all of the characters in the string to upper case, based on the portal instance's default locale.
        Parameters:
        s - the string to convert
        Returns:
        the string, converted to upper case, or null if the string is null
      • toUpperCase

        public static java.lang.String toUpperCase​(java.lang.String s,
                                                   java.util.Locale locale)
        Converts all of the characters in the string to upper case, based on the locale.
        Parameters:
        s - the string to convert
        locale - apply this locale's rules
        Returns:
        the string, converted to upper case, or null if the string is null
      • removeQuotes

        public static java.lang.String removeQuotes​(java.lang.String string)
        Removes starting and ending single or double quotes.
      • toHexString

        public static java.lang.String toHexString​(byte[] bytes)
        Converts bytes to hex string.
      • ifNotNull

        public static java.lang.String ifNotNull​(java.lang.String input,
                                                 java.util.function.Function<java.lang.String,​java.lang.String> stringFunction)
        Executes function on a string if not null. Otherwise returns an empty string.
      • detectQuoteChar

        public static char detectQuoteChar​(java.lang.String str)
        Detects quote character or return 0.
      • fromCamelCase

        public static java.lang.String fromCamelCase​(java.lang.String input,
                                                     char separator)
        Changes CamelCase string to lower case words separated by provided separator character. The following translations are applied:
        • Every upper case letter in the CamelCase name is translated into two characters, a separator and the lower case equivalent of the target character, with three exceptions.
          1. For contiguous sequences of upper case letters, characters after the first character are replaced only by their lower case equivalent, and are not preceded by a separator (theFOO to the_foo).
          2. An upper case character in the first position of the CamelCase name is not preceded by a separator character, and is translated only to its lower case equivalent. (Foo to foo and not _foo)
          3. An upper case character in the CamelCase name that is already preceded by a separator character is translated only to its lower case equivalent, and is not preceded by an additional separator. (user_Name to user_name and not user__name.
        • If the CamelCase name starts with a separator, then that separator is not included in the translated name, unless the CamelCase name is just one character in length, i.e., it is the separator character. This applies only to the first character of the CamelCase name.
      • toCamelCase

        public static java.lang.String toCamelCase​(java.lang.String input,
                                                   boolean firstCharUppercase,
                                                   char separator)
        Converts separated string value to CamelCase.
      • convertTabsToSpaces

        public static java.lang.String convertTabsToSpaces​(java.lang.String line,
                                                           int tabWidth)
        Converts all tabs on a line to spaces according to the provided tab width. This is not a simple tab to spaces replacement, since the resulting indentation remains the same.
      • escapeJava

        public static java.lang.String escapeJava​(java.lang.String string)
        Escapes a string using java rules.
      • unescapeJava

        public static java.lang.String unescapeJava​(java.lang.String str)
        Unescapes a string using java rules.