Class Text

java.lang.Object
is.codion.common.Text

public final class Text extends Object
A utility class for working with text, such as collating and padding.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final PropertyValue<String>
    Specifies the default collator locale language.
    Value type: String
    Default value: Locale.getDefault().getLanguage().
    static final PropertyValue<Character>
    Specifies the wildcard character used
    Value type: Character
    Default value: %
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> List<T>
    collate(List<T> values)
    Sorts the string representations of the list contents, using the space aware collator
    static <T> Comparator<T>
    Creates a Comparator which compares the string representations of the objects using the default Collator, taking spaces into account.
    static <T> Comparator<T>
    collator(Locale locale)
    Creates a Comparator which compares the string representations of the objects using the default Collator, taking spaces into account.
    static String
    leftPad(String string, int length, char padChar)
    Left pads the given string with the given pad character until a length of length has been reached
    static boolean
    Returns true if the given string is null or empty.
    static boolean
    nullOrEmpty(String... strings)
    Returns true if any of the given strings is null or empty.
    static List<String>
    parseCommaSeparatedValues(String commaSeparatedValues)
    Parses, splits and trims the given comma separated string.
    static String
    rightPad(String string, int length, char padChar)
    Right pads the given string with the given pad character until a length of length has been reached

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_COLLATOR_LANGUAGE

      public static final PropertyValue<String> DEFAULT_COLLATOR_LANGUAGE
      Specifies the default collator locale language.
      Value type: String
      Default value: Locale.getDefault().getLanguage().
      See Also:
    • WILDCARD_CHARACTER

      public static final PropertyValue<Character> WILDCARD_CHARACTER
      Specifies the wildcard character used
      Value type: Character
      Default value: %
  • Method Details

    • collate

      public static <T> List<T> collate(List<T> values)
      Sorts the string representations of the list contents, using the space aware collator
      Type Parameters:
      T - the list element type
      Parameters:
      values - the list to sort (collate)
      Returns:
      the sorted list
      See Also:
    • collator

      public static <T> Comparator<T> collator()
      Creates a Comparator which compares the string representations of the objects using the default Collator, taking spaces into account.
      Type Parameters:
      T - the type of the objects to compare
      Returns:
      a space aware collator
      See Also:
    • collator

      public static <T> Comparator<T> collator(Locale locale)
      Creates a Comparator which compares the string representations of the objects using the default Collator, taking spaces into account.
      Type Parameters:
      T - the type of the objects to compare
      Parameters:
      locale - the collator locale
      Returns:
      a space aware collator
      See Also:
    • rightPad

      public static String rightPad(String string, int length, char padChar)
      Right pads the given string with the given pad character until a length of length has been reached
      Parameters:
      string - the string to pad
      length - the desired length
      padChar - the character to use for padding
      Returns:
      the padded string
    • leftPad

      public static String leftPad(String string, int length, char padChar)
      Left pads the given string with the given pad character until a length of length has been reached
      Parameters:
      string - the string to pad
      length - the desired length
      padChar - the character to use for padding
      Returns:
      the padded string
    • parseCommaSeparatedValues

      public static List<String> parseCommaSeparatedValues(String commaSeparatedValues)
      Parses, splits and trims the given comma separated string. Returns an empty list in case of null or empty string argument.
      Parameters:
      commaSeparatedValues - a String with comma separated values
      Returns:
      the trimmed values
    • nullOrEmpty

      public static boolean nullOrEmpty(String string)
      Returns true if the given string is null or empty.
      Parameters:
      string - the string to check
      Returns:
      true if the given string is null or empty, false otherwise
    • nullOrEmpty

      public static boolean nullOrEmpty(String... strings)
      Returns true if any of the given strings is null or empty.
      Parameters:
      strings - the strings to check
      Returns:
      true if one of the given strings is null or empty or if no arguments are provided, false otherwise