Class StringUtil

java.lang.Object
liquibase.util.StringUtil

public class StringUtil extends Object
Deprecated.
use StringUtils instead
Various utility methods for working with strings.
  • Constructor Details

    • StringUtil

      public StringUtil()
      Deprecated.
  • Method Details

    • trimToEmpty

      @Deprecated public static String trimToEmpty(String string)
      Deprecated.
      use StringUtils.trimToEmpty(String) instead
      Returns the trimmed (left and right) version of the input string. If null is passed, an empty string is returned.
      Parameters:
      string - the input string to trim
      Returns:
      the trimmed string, or an empty string if the input was null.
    • trimToNull

      @Deprecated public static String trimToNull(String string)
      Deprecated.
      use StringUtils.trimToNull(String) instead
      Returns the trimmed (left and right) form of the input string. If the string is empty after trimming (or null was passed in the first place), null is returned, i.e. the input string is reduced to nothing.
      Parameters:
      string - the string to trim
      Returns:
      the trimmed string or null
    • processMultiLineSQL

      public static String[] processMultiLineSQL(String multiLineSQL, boolean stripComments, boolean splitStatements, String endDelimiter)
      Deprecated.
      Removes any comments from multiple line SQL using stripComments(String, ChangeSet) and then extracts each individual statement using splitSQL(String, String, ChangeSet).
      Parameters:
      multiLineSQL - A String containing all the SQL statements
      stripComments - If true then comments will be stripped, if false then they will be left in the code
    • processMultiLineSQL

      public static String[] processMultiLineSQL(String multiLineSQL, boolean stripComments, boolean splitStatements, String endDelimiter, ChangeSet changeSet)
      Deprecated.
      Removes any comments from multiple line SQL using stripComments(String, ChangeSet) and then extracts each individual statement using splitSQL(String, String, ChangeSet).
      Parameters:
      multiLineSQL - A String containing all the SQL statements
      stripComments - If true then comments will be stripped, if false then they will be left in the code
      changeSet - the changeset associated with the sql being parsed
    • processMutliLineSQL

      @Deprecated public static String[] processMutliLineSQL(String multiLineSQL, boolean stripComments, boolean splitStatements, String endDelimiter)
      Removes any comments from multiple line SQL using stripComments(String, ChangeSet) and then extracts each individual statement using splitSQL(String, String, ChangeSet).
      Parameters:
      multiLineSQL - A String containing all the SQL statements
      stripComments - If true then comments will be stripped, if false then they will be left in the code
    • processMutliLineSQL

      @Deprecated public static String[] processMutliLineSQL(String multiLineSQL, boolean stripComments, boolean splitStatements, String endDelimiter, ChangeSet changeSet)
      Removes any comments from multiple line SQL using stripComments(String, ChangeSet) and then extracts each individual statement using splitSQL(String, String, ChangeSet).
      Parameters:
      multiLineSQL - A String containing all the SQL statements
      stripComments - If true then comments will be stripped, if false then they will be left in the code
      changeSet - the changeset associated with the sql being parsed
    • isDelimiter

      protected static boolean isDelimiter(String piece, String previousPiece, String endDelimiter)
      Deprecated.
      Returns true if the input is a delimiter in one of the popular RDBMSs. Recognized delimiters are: semicolon (;), a slash (as the only content) or the word GO (as the only content).
      Parameters:
      piece - the input line to test
      previousPiece - the characters in the input stream that came before piece
      endDelimiter - ??? (need to see this in a debugger to find out)
    • wrap

      @Deprecated public static String wrap(String inputStr, int wrapPoint, int extraLinePadding)
      Deprecated.
      Liquibase does not wrap any console output, and instead lets the terminal handle its own wrapping. If you wish to use this method, consider whether its usage is truly necessary.
      Add new lines to the input string to cause output to wrap. Optional line padding can be passed in for the additional lines that are created
      Parameters:
      inputStr - The string to split and wrap
      wrapPoint - The point at which to split the lines
      extraLinePadding - Any additional spaces to add
      Returns:
      String Output string with new lines
    • splitSQL

      public static String[] splitSQL(String multiLineSQL, String endDelimiter)
      Deprecated.
      Splits a candidate multi-line SQL statement along ;'s and "go"'s.
    • splitSQL

      public static String[] splitSQL(String multiLineSQL, String endDelimiter, ChangeSet changeSet)
      Deprecated.
      Splits a candidate multi-line SQL statement along ;'s and "go"'s.
      Parameters:
      changeSet - the changeset associated with the sql being parsed
    • stripComments

      public static String stripComments(String multiLineSQL)
      Deprecated.
      Searches through a String which contains SQL code and strips out any comments that are between \/**\/ or anything that matches SP--SP\n (to support the ANSI standard commenting of -- at the end of a line).
      Returns:
      The String without the comments in
    • stripComments

      public static String stripComments(String multiLineSQL, ChangeSet changeSet)
      Deprecated.
      Searches through a String which contains SQL code and strips out any comments that are between \/**\/ or anything that matches SP--SP\n (to support the ANSI standard commenting of -- at the end of a line).
      Parameters:
      changeSet - the changeset associated with the sql being parsed
      Returns:
      The String without the comments in
    • join

      public static String join(Object[] array, String delimiter, StringUtil.StringUtilFormatter formatter)
      Deprecated.
    • join

      public static String join(String[] array, String delimiter)
      Deprecated.
    • join

      public static String join(Collection<String> collection, String delimiter)
      Deprecated.
    • join

      public static String join(Collection collection, String delimiter, StringUtil.StringUtilFormatter formatter)
      Deprecated.
    • join

      public static String join(Collection collection, String delimiter, StringUtil.StringUtilFormatter formatter, boolean sorted)
      Deprecated.
    • join

      public static String join(Collection<String> collection, String delimiter, boolean sorted)
      Deprecated.
    • join

      public static String join(Map map, String delimiter)
      Deprecated.
    • join

      public static String join(Map map, String delimiter, StringUtil.StringUtilFormatter formatter)
      Deprecated.
    • join

      public static String join(ExtensibleObject extensibleObject, String delimiter)
      Deprecated.
    • join

      public static String join(ExtensibleObject extensibleObject, String delimiter, StringUtil.StringUtilFormatter formatter)
      Deprecated.
    • splitAndTrim

      public static List<String> splitAndTrim(String s, String regex)
      Deprecated.
    • repeat

      @Deprecated public static String repeat(String string, int times)
      Deprecated.
      use StringUtils.repeat(String, int) instead
    • join

      @Deprecated public static String join(Integer[] array, String delimiter)
      Deprecated.
      use StringUtils.join(Object[], String) instead
    • join

      @Deprecated public static String join(int[] array, String delimiter)
      Deprecated.
      use StringUtils.join(int[], char) instead
    • indent

      public static String indent(String string)
      Deprecated.
    • indent

      public static String indent(String string, int padding)
      Deprecated.
    • lowerCaseFirst

      @Deprecated public static String lowerCaseFirst(String string)
      Deprecated.
      use StringUtils.uncapitalize(String) instead
    • upperCaseFirst

      @Deprecated public static String upperCaseFirst(String string)
      Deprecated.
      use StringUtils.capitalize(String) instead
    • hasUpperCase

      public static boolean hasUpperCase(String string)
      Deprecated.
    • hasLowerCase

      public static boolean hasLowerCase(String string)
      Deprecated.
    • standardizeLineEndings

      public static String standardizeLineEndings(String string)
      Deprecated.
    • isAscii

      public static boolean isAscii(String string)
      Deprecated.
    • isAscii

      @Deprecated public static boolean isAscii(char ch)
      Deprecated.
      use CharUtils.isAscii(char) instead
      Returns true if ch is a "7-bit-clean" ASCII character (ordinal number < 128).
      Parameters:
      ch - the character to test
      Returns:
      true if 7 bit-clean, false otherwise.
    • escapeHtml

      public static String escapeHtml(String str)
      Deprecated.
    • pad

      public static String pad(String value, int length)
      Deprecated.
      Adds spaces to the right of the input value until the string has reached the given length. Nothing is done if the string already has the given length or if the string is even longer.
      Parameters:
      value - The string to pad (if necessary)
      length - the desired length
      Returns:
      the input string, padded if necessary.
    • leftPad

      public static String leftPad(String value, int length)
      Deprecated.
      Adds spaces to the left of the input value until the string has reached the given length. Nothing is done if the string already has the given length or if the string is even longer.
      Parameters:
      value - The string to pad (if necessary)
      length - the desired length
      Returns:
      the input string, padded if necessary.
    • contains

      @Deprecated public static boolean contains(String value, String containsValue)
      Deprecated.
      use StringUtils.contains(CharSequence, CharSequence) instead
      Returns true if the input string contains the specified value
      Parameters:
      value - String to be checked
      containsValue - String to look for
      Returns:
      true if String contains the value
    • isEmpty

      @Deprecated public static boolean isEmpty(String value)
      Deprecated.
      use StringUtils.isEmpty(CharSequence) instead
      Returns true if the input string is the empty string (null-safe).
      Parameters:
      value - String to be checked
      Returns:
      true if String is null or empty
    • isNotEmpty

      @Deprecated public static boolean isNotEmpty(String value)
      Deprecated.
      use StringUtils.isNotEmpty(CharSequence) instead
      Returns true if the input string is NOT the empty string. If the string is null, false is returned.
      Parameters:
      value - String to be checked
      Returns:
      true if string is not null and not empty (length > 0)
    • startsWith

      @Deprecated public static boolean startsWith(String value, String startsWith)
      Deprecated.
      use StringUtils.startsWith(CharSequence, CharSequence) instead
      Checks whether the given value starts with the specified startsWith string.
      Parameters:
      value - the string to check
      startsWith - the prefix to check for
      Returns:
      true if value starts with startsWith, false otherwise. Returns false if either argument is null.
    • endsWith

      @Deprecated public static boolean endsWith(String value, String endsWith)
      Deprecated.
      use StringUtils.endsWith(CharSequence, CharSequence) instead
      Checks whether the given value ends with the specified endsWith string.
      Parameters:
      value - the string to check
      endsWith - the prefix to check for
      Returns:
      true if value ends with endsWith, false otherwise. Returns false if either argument is null.
    • isWhitespace

      public static boolean isWhitespace(CharSequence string)
      Deprecated.
      Returns true if the given string only consists of whitespace characters (null-safe)
      Parameters:
      string - the string to test
      Returns:
      true if the string is null or only consists of whitespaces.
    • isMinimumVersion

      public static boolean isMinimumVersion(String minimumVersion, int candidateMajor, int candidateMinor, int candidatePatch)
      Deprecated.
      Compares a minimum version number given in string form (only the first three parts are considered) with a candidate version given as the three ints major, minor and patch.
      Parameters:
      minimumVersion - The minimum version that is required, given as a string with up to 3 parts, e.g. "7.4" or "9.6.3"
      candidateMajor - the version number to be tested, major part
      candidateMinor - the version number to be tested, minor part
      candidatePatch - the version number to be tested, patch part
      Returns:
      true if candidateMajor.candidateMinor.candidatePatch >= minimumVersion or false if not
    • limitSize

      public static String limitSize(String string, int maxLength)
      Deprecated.
    • randomIdentifer

      @Deprecated public static String randomIdentifer(int len)
      Deprecated.
      Produce a random identifier of the given length, consisting only of uppercase letters.
      Parameters:
      len - desired length of the string
      Returns:
      an identifier of the desired length
    • randomIdentifier

      public static String randomIdentifier(int len)
      Deprecated.
      Produce a random identifier of the given length, consisting only of uppercase letters.
      Parameters:
      len - desired length of the string
      Returns:
      an identifier of the desired length
    • toKabobCase

      public static String toKabobCase(String string)
      Deprecated.
      Converts a camelCase string to a kabob-case one
    • toCamelCase

      public static String toCamelCase(String string)
      Deprecated.
      Converts a kabob-case or underscore_case string to a camel-case one
    • equalsIgnoreCaseAndEmpty

      public static boolean equalsIgnoreCaseAndEmpty(String s1, String s2)
      Deprecated.
      Returns if two strings are equal, ignoring:
      • case (uppercase/lowercase)
      • difference between null, and empty string, and a string that only has spaces
      Parameters:
      s1 - the first String to compare (or null)
      s2 - the second String to compare (or null)
      Returns:
      true if the Strings are equal by the above criteria, false in all other cases
    • trimRight

      public static String trimRight(String string)
      Deprecated.
      Trims whitespace characters from the end of specified string
      Parameters:
      string - String to trim
      Returns:
      new String without the whitespace at the end
    • getLastBlockComment

      public static String getLastBlockComment(String sqlString)
      Deprecated.
      Retrieves the last block comment in a SQL string, if any.
      Parameters:
      sqlString - the SQL string to search for the last block comment
      Returns:
      the last block comment in the SQL string, or null if none was found
    • getLastLineComment

      public static String getLastLineComment(String sqlString)
      Deprecated.
      Returns the last line comment from a given SQL string, if there is one.
      Parameters:
      sqlString - the SQL string to search
      Returns:
      the last line comment from the SQL string, or null if there is no line comment
    • stripSqlCommentsAndWhitespacesFromTheEnd

      public static String stripSqlCommentsAndWhitespacesFromTheEnd(String sqlString)
      Deprecated.
      Strips the comments and white spaces from the end of given SQL string.
      Parameters:
      sqlString - the SQL string to strip
      Returns:
      the stripped SQL string
    • concatConsistentCase

      public static String concatConsistentCase(String baseString, String addition)
      Deprecated.
      Concatenates the addition string to the baseString string, adjusting the case of "addition" to match the base string. If the string is all caps, append addition in all caps. If all lower case, append in all lower case. If baseString is mixed case, make no changes to addition.
    • stripEnclosingQuotes

      public static String stripEnclosingQuotes(String string)
      Deprecated.
    • equalsWordNull

      public static boolean equalsWordNull(String value)
      Deprecated.
      Check whether the value is 'null' (case insensitive)
    • splitCamelCase

      @Deprecated public static String[] splitCamelCase(String str)
      Deprecated.
      use StringUtils.splitByCharacterTypeCamelCase(String) instead

      Splits a camel-case string into words based on the came casing.

      Parameters:
      str - the String to split, may be null
      Returns:
      an array of parsed Strings, null if null String input
    • getBytesWithEncoding

      public static byte[] getBytesWithEncoding(String string)
      Deprecated.
    • toLowerWithoutWhitespaces

      @Deprecated public static String toLowerWithoutWhitespaces(String value)
      Deprecated.
      use StringUtils.toRootLowerCase(String) and StringUtils.deleteWhitespace(String) instead
      Parameters:
      value - string to process
      Returns:
      string without any whitespaces formatted to lowercase.
    • isNumeric

      @Deprecated public static boolean isNumeric(CharSequence cs)
      Deprecated.
      use StringUtils.isNumeric(CharSequence) instead

      Checks whether the char sequence is numeric by checking that all chars in the sequence are numbers, so (-1, 1.0 and 1F) will return false

      Parameters:
      cs - the arg to check if it is numeric
      Returns:
      true if convertible to numeric and false otherwise
    • isEmpty

      @Deprecated public static boolean isEmpty(CharSequence cs)
      Deprecated.
      use StringUtils.isEmpty(CharSequence)
    • splitToChunks

      public static List<String> splitToChunks(String input, int chunkSize)
      Deprecated.
      Split the input string into chunks no larger than the supplied chunkSize. If the string is shorter than the chunkSize, the resultant list will contain only a single entry.