Class StringUtils

java.lang.Object
ch.systemsx.cisd.common.shared.basic.string.StringUtils

public final class StringUtils extends Object
Some utilities for String.

Can be used from GWT code.

  • Field Details

  • Method Details

    • isBlank

      public static final boolean isBlank(String value)
      Whether given value is blank or not.
    • isBlank

      public static final boolean isBlank(Object value)
      Whether given value is blank or not.
    • isNotBlank

      public static final boolean isNotBlank(String value)
      Whether given value is not blank.
    • joinList

      public static final String joinList(List<String> list)
      Joins the elements using comma as a separator.
      Example: "a", "b", "c" -> "a, b, c"
    • joinList

      public static final String joinList(List<String> list, String separator)
      Joins the elements using comma as a separator.
      Example: "a", "b", "c" -> "a, b, c"
    • join

      public static final String join(Object[] array, String separator)
      Joins the elements of the provided array into a single String containing the provided list of elements.
    • capitalize

      public static final String capitalize(String word)
    • abbreviate

      public static final String abbreviate(String value, int maxLength)
    • trimToNull

      public static final String trimToNull(String value)
      Trims given value to null.
      Returns:
      null if given value is blank.
    • nullIfBlank

      public static final String nullIfBlank(String value)
      Returns null if given value is blank.
    • emptyIfNull

      public static final String emptyIfNull(String stringOrNull)
      Returns an empty string if given stringOrNull is null, otherwise it returns stringOrNull itself.
    • toStringEmptyIfNull

      public static final String toStringEmptyIfNull(Object objectOrNull)
      Returns an empty string if given objectOrNull is null, otherwise it returns result of Object.toString() on the object.
    • toStringOrNull

      public static final String toStringOrNull(Object objectOrNull)
      Returns null if given objectOrNull is null, otherwise it returns result of Object.toString() on the object.
    • defaultIfBlank

      public static final String defaultIfBlank(String str, String defaultStr)
      Returns defaultStr, if str is blank, or otherwise it returns str itself.
    • escape

      public static final String escape(String text, char... escapedChars)
      Escapes escapedChars characters in specified text.
    • tokenize

      public static final List<String> tokenize(String str)
      Returns the tokens found in str, where tokens are separated by white spaces.
    • matches

      public static final boolean matches(String regExp, String value, String modifiers)
      Returns true if given regExp could be found in given value.

      Allowed modifiers are:

      • i - Perform case-insensitive matching
      • g - Perform a global match (find all matches rather than stopping after the first match)
      • m - Perform multiline matching
    • matches

      public static final boolean matches(String regExp, String value)
      Returns true if given regExp could be found in given value.