Class StringUtils

java.lang.Object
com.nomagic.magicreport.helper.StringUtils

@OpenApiAll public final class StringUtils extends Object
Contains collection of String utilities.
Since:
Jun 15, 2007
  • Field Details

    • LINE_SEPARATOR

      public static final String LINE_SEPARATOR
      A line separator string. The line separator string is defined by the system property line.separator, and is not necessarily a single newline ('\n') character.
  • Method Details

    • replaceAll

      public static StringBuffer replaceAll(CharSequence input, String regex, String replacement)
      Replaces each substring of this subsequence that matches the given regular expression with the given replacement.
      Parameters:
      input - The character sequence to be matched
      regex - the regular expression to which this string is to be matched
      replacement - The replacement string
      Returns:
      The StringBuffer constructed by replacing each matching subsequence by the replacement string, substituting captured subsequences as needed
    • replaceAllBuilder

      public static StringBuilder replaceAllBuilder(CharSequence input, String regex, String replacement)
      Replaces each substring of this subsequence that matches the given regular expression with the given replacement.
      Parameters:
      input - The character sequence to be matched
      regex - the regular expression to which this string is to be matched
      replacement - The replacement string
      Returns:
      The StringBuilder constructed by replacing each matching subsequence by the replacement string, substituting captured subsequences as needed
    • replace

      public static StringBuffer replace(CharSequence input, String target, String replacement)
      Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence. The replacement proceeds from the beginning of the string to the end.
      Parameters:
      input - The character sequence to be matched
      target - The sequence of char values to be replaced
      replacement - The replacement string
      Returns:
      The StringBuffer constructed by replacing each matching subsequence by the replacement string, substituting captured subsequences as needed
    • replaceBuilder

      public static StringBuilder replaceBuilder(CharSequence input, String target, String replacement)
      Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence. The replacement proceeds from the beginning of the string to the end.
      Parameters:
      input - The character sequence to be matched
      target - The sequence of char values to be replaced
      replacement - The replacement string
      Returns:
      The StringBuilder constructed by replacing each matching subsequence by the replacement string, substituting captured subsequences as needed
    • leftTrim

      public static CharSequence leftTrim(CharSequence input)
      Returns a copy of the string, with leading whitespace omitted. This method may be used to trim whitespace from the beginning of a string.
      Parameters:
      input - string to be trim.
      Returns:
      A copy of this string with leading white space removed, or this string if it has no leading white space
    • rightTrim

      public static CharSequence rightTrim(CharSequence input)
      Returns a copy of the string, with trailing whitespace omitted. This method may be used to trim whitespace from the end of a string.
      Parameters:
      input - string to be trim.
      Returns:
      A copy of this string with trailing white space removed, or this string if it has no trailing white space
    • trim

      public static CharSequence trim(CharSequence input)
      Returns a copy of the string, with leading whitespace and trailing whitespace are omitted.
      Parameters:
      input - string to be trim.
      Returns:
      A copy of this string with leading whitespace trailing white space removed, or this string if it has no leading whitespace and trailing white space
    • lPad

      public static String lPad(CharSequence src, char pad, int length)
      Padding a character to left of string.
      Parameters:
      src - String to padding
      pad - Pad character
      length - Final length of string
      Returns:
      new string
    • rPad

      public static String rPad(CharSequence src, char pad, int length)
      Padding a character to right of string.
      Parameters:
      src - String to padding
      pad - Pad character
      length - Final length of string
      Returns:
      new string