Class TextUtil

java.lang.Object
org.openremote.model.util.TextUtil

public class TextUtil extends Object
  • Field Details

  • Constructor Details

    • TextUtil

      public TextUtil()
  • Method Details

    • convertPollingIntervalString

      public static int convertPollingIntervalString(String pollingInterval)
      Converts a String which represents a pollingInterval into an int which can be used as delay for Thread.sleep();

      Following conversion will happen:

      null || "" = -1
      500 = 500
      1s = 1000 * 1 = 1000
      1m = 1000 * 60 = 60000
      1h = 1000 * 60 * 60 = 3600000

      Parameters:
      pollingInterval - interval string, such as '1m' as millisecond value
      Returns:
      interval in milliseconds
    • toCommaSeparated

      public static String toCommaSeparated(String... strings)
    • fromCommaSeparated

      public static String[] fromCommaSeparated(String commaWords)
    • getEnumFromString

      public static <T extends Enum<T>> T getEnumFromString(Class<T> c, String string)
      Get an enum value from a string without throwing exception. Enum should be in uppercase to use this method.
    • toLowerCaseDash

      public static String toLowerCaseDash(String camelCase)
      Transforms EXFooBar123 into ex-foo-bar-123 and attributeX into attribute-x without regex.
    • ellipsize

      public static String ellipsize(String text, int max)
    • pad

      public static String pad(String s, int size)
    • truncate

      public static String truncate(String s, int maxLength, boolean alignRight)
    • isNullOrEmpty

      public static boolean isNullOrEmpty(String str)
    • asNonNullAndNonEmpty

      public static Optional<String> asNonNullAndNonEmpty(String str)
    • requireNonNullAndNonEmpty

      public static String requireNonNullAndNonEmpty(String str)
    • requireNonNullAndNonEmpty

      public static String requireNonNullAndNonEmpty(String str, String exceptionMessage)
    • toLowerCamelCase

      public static String toLowerCamelCase(String s)
    • toUpperCamelCase

      public static String toUpperCamelCase(String s)
    • toProperCase

      public static String toProperCase(String s)
    • toProperCase

      public static String toProperCase(String s, boolean convertUnderscoreToSpace)
    • asInteger

      public static Optional<Integer> asInteger(String str)