Class StringUtil

java.lang.Object
org.camunda.commons.utils.StringUtil

public final class StringUtil extends Object
Author:
Sebastian Menski
  • Constructor Details

    • StringUtil

      public StringUtil()
  • Method Details

    • isExpression

      public static boolean isExpression(String text)
      Checks whether a String seams to be an expression or not
      Parameters:
      text - the text to check
      Returns:
      true if the text seams to be an expression false otherwise
    • split

      public static String[] split(String text, String regex)
      Splits a String by an expression.
      Parameters:
      text - the text to split
      regex - the regex to split by
      Returns:
      the parts of the text or null if text was null
    • join

      public static String join(String delimiter, String... parts)
      Joins a list of Strings to a single one.
      Parameters:
      delimiter - the delimiter between the joined parts
      parts - the parts to join
      Returns:
      the joined String or null if parts was null
    • defaultString

      public static String defaultString(String text)
      Returns either the passed in String, or if the String is null, an empty String ("").
       StringUtils.defaultString(null)  = ""
       StringUtils.defaultString("")    = ""
       StringUtils.defaultString("bat") = "bat"
       
      Parameters:
      text - the String to check, may be null
      Returns:
      the passed in String, or the empty String if it was null
    • getStackTrace

      public static String getStackTrace(Throwable throwable)
      Fetches the stack trace of an exception as a String.
      Parameters:
      throwable - to get the stack trace from
      Returns:
      the stack trace as String