Class StringUtils

java.lang.Object
com.dlsc.gemsfx.util.StringUtils

public final class StringUtils extends Object
Minimal string utility methods that cover the subset of org.apache.commons.lang3.StringUtils used by GemsFX.
  • Method Details

    • isEmpty

      public static boolean isEmpty(String str)
      Returns true if str is null or its length is 0.
      Parameters:
      str - the string to test
      Returns:
      true if the string is empty
    • isNotEmpty

      public static boolean isNotEmpty(String str)
      Returns true if str is neither null nor empty.
      Parameters:
      str - the string to test
      Returns:
      true if the string is not empty
    • isBlank

      public static boolean isBlank(String str)
      Returns true if str is null, empty, or contains only whitespace characters (as defined by Character.isWhitespace(char)).
      Parameters:
      str - the string to test
      Returns:
      true if the string is blank
    • isNotBlank

      public static boolean isNotBlank(String str)
      Returns true if str is not blank (see isBlank(String)).
      Parameters:
      str - the string to test
      Returns:
      true if the string is not blank
    • capitalize

      public static String capitalize(String str)
      Capitalises the first character of str using Character.toTitleCase(char). Returns str unchanged when it is null or empty.
      Parameters:
      str - the string to capitalize
      Returns:
      the capitalized string
    • split

      public static String[] split(String str)
      Splits str on whitespace, discarding empty tokens. Returns null when str is null and an empty array when str is empty or all-whitespace.
      Parameters:
      str - the string to split
      Returns:
      the split parts
    • join

      public static String join(String[] array, String separator)
      Joins the elements of array with separator between each pair. A null separator is treated as an empty string. Returns null when array is null.
      Parameters:
      array - the strings to join
      separator - the separator to use
      Returns:
      the joined string
    • startsWithIgnoreCase

      public static boolean startsWithIgnoreCase(String str, String prefix)
      Returns true if str starts with prefix, ignoring case. Null-safe: two null values are considered equal, otherwise a null argument yields false.
      Parameters:
      str - the string to test
      prefix - the prefix to look for
      Returns:
      true if the string starts with the prefix
    • equals

      public static boolean equals(String str1, String str2)
      Returns true if the two strings are equal. Two null values are considered equal.
      Parameters:
      str1 - the first string
      str2 - the second string
      Returns:
      true if both strings are equal
    • equalsIgnoreCase

      public static boolean equalsIgnoreCase(String str1, String str2)
      Returns true if the two strings are equal ignoring case. Two null values are considered equal.
      Parameters:
      str1 - the first string
      str2 - the second string
      Returns:
      true if both strings are equal ignoring case
    • replaceEach

      public static String replaceEach(String text, String[] searchList, String[] replacementList)
      Replaces each string in searchList with the corresponding entry in replacementList within text. Replacements are applied in order; each operates on the result of the previous one. Returns text unchanged when any argument is null or the two lists have different lengths.
      Parameters:
      text - the text to process
      searchList - the strings to search for
      replacementList - the replacement strings
      Returns:
      the processed string
    • splitByCharacterTypeCamelCase

      public static String[] splitByCharacterTypeCamelCase(String str)
      Splits str at boundaries where the character type (as returned by Character.getType(char)) changes, with the additional camel-case rule: when transitioning from Character.UPPERCASE_LETTER to Character.LOWERCASE_LETTER, the split is placed before the last uppercase character so that acronym prefixes are kept together with the following word (e.g. "ASFRules"["ASF", "Rules"]).

      Returns null when str is null and an empty array when str is empty.

      Parameters:
      str - the string to split
      Returns:
      the split parts