Class CmsClientStringUtil

java.lang.Object
org.opencms.gwt.client.util.CmsClientStringUtil

public final class CmsClientStringUtil extends Object
Additional string related helper methods.

Since:
8.0.0
See Also:
  • CmsStringUtil
  • Method Details

    • checkIsPathOrLinkToSvg

      public static boolean checkIsPathOrLinkToSvg(String path)
      Checks if the given string looks like a path or link to an SVG file.

      Parameters:
      path - the path to check
      Returns:
      true if the path looks like a path or link to an SVG file
    • getMessage

      public static String getMessage(Throwable t)
      Returns the exception message.

      Parameters:
      t - the exception to get the message for
      Returns:
      the exception message
    • getStackTrace

      public static String getStackTrace(Throwable t, String separator)
      Returns the stack trace of the Throwable as a string.

      Parameters:
      t - the Throwable for which the stack trace should be returned
      separator - the separator between the lines of the stack trace
      Returns:
      a string representing a stack trace
    • getStackTraceAsString

      public static String getStackTraceAsString(StackTraceElement[] trace, String separator)
      Returns the stack trace as a string.

      Parameters:
      trace - the stack trace
      separator - the separator between the lines of the stack trace
      Returns:
      a string representing a stack trace
    • parseFloat

      public static double parseFloat(String str)
      The parseFloat() function parses a string and returns a float.

      Only the first number in the string is returned. Leading and trailing spaces are allowed.

      Parameters:
      str - the string to be parsed
      Returns:
      the parsed number
    • parseInt

      public static int parseInt(String str)
      The parseInt() function parses a string and returns an integer.

      Only the first number in the string is returned. Leading and trailing spaces are allowed. If the first character cannot be converted to a number, parseInt() returns zero.

      Parameters:
      str - the string to be parsed
      Returns:
      the parsed number
    • pushArray

      public static void pushArray(com.google.gwt.core.client.JavaScriptObject array, String s)
      Pushes a String into a javascript array.

      Parameters:
      array - the array to push the String into
      s - the String to push into the array
    • randomUUID

      public static String randomUUID()
      Generates a purely random uuid.

      Returns:
      the generated uuid
    • shortenString

      public static String shortenString(String text, int maxLength)
      Shortens the string to the given maximum length.

      Will include HTML entity ellipses replacing the cut off text.

      Parameters:
      text - the string to shorten
      maxLength - the maximum length
      Returns:
      the shortened string