Class StringUtil


  • public final class StringUtil
    extends java.lang.Object
    Author:
    Sebastian Menski
    • Constructor Summary

      Constructors 
      Constructor Description
      StringUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String defaultString​(java.lang.String text)
      Returns either the passed in String, or if the String is null, an empty String ("").
      static java.lang.String getStackTrace​(java.lang.Throwable throwable)
      Fetches the stack trace of an exception as a String.
      static boolean isExpression​(java.lang.String text)
      Checks whether a String seams to be an expression or not
      static java.lang.String join​(java.lang.String delimiter, java.lang.String... parts)
      Joins a list of Strings to a single one.
      static java.lang.String[] split​(java.lang.String text, java.lang.String regex)
      Splits a String by an expression.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StringUtil

        public StringUtil()
    • Method Detail

      • isExpression

        public static boolean isExpression​(java.lang.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 java.lang.String[] split​(java.lang.String text,
                                               java.lang.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 java.lang.String join​(java.lang.String delimiter,
                                            java.lang.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 java.lang.String defaultString​(java.lang.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 java.lang.String getStackTrace​(java.lang.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