org.springframework.shell.support.util

## Class StringUtils

- java.lang.Object
- - org.springframework.shell.support.util.StringUtils

-     public class StringUtils
      extends Object

  Utility methods for Strings focused on the use in formatting of tables. padLeft methods taken from Commons Lang 2.6 to avoid an extra compile time dependency.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `StringUtils()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static boolean` | `isEmpty(String str)` Checks if a String is empty ("") or null.
    `static String` | `padLeft(String str, int size)` Left pad a String with spaces (' ').
    `static String` | `padLeft(String str, int size, char padChar)` Left pad a String with a specified character.
    `static String` | `padLeft(String str, int size, String padStr)` Left pad a String with a specified String.
    `static String` | `padRight(String string, int size)` Right-pad the provided String with empty spaces.
    `static String` | `padRight(String inputString, int size, char paddingChar)` Right-pad a String with a configurable padding character.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### StringUtils

          public StringUtils()

  - ### Method Detail

    - #### padLeft

          public static String padLeft(String str,
                       int size)

      Left pad a String with spaces (' ').

      The String is padded to the size of `size`.

           StringUtils.leftPad(null, *) = null
           StringUtils.leftPad("", 3) = " "
           StringUtils.leftPad("bat", 3) = "bat"
           StringUtils.leftPad("bat", 5) = " bat"
           StringUtils.leftPad("bat", 1) = "bat"
           StringUtils.leftPad("bat", -1) = "bat"

      Parameters:
        `str` - the String to pad out, may be null
        `size` - the size to pad to
      Returns:
        left padded String or original String if no padding is necessary, `null` if null String input

    - #### padLeft

          public static String padLeft(String str,
                       int size,
                       char padChar)

      Left pad a String with a specified character.

      Pad to a size of `size`.

           StringUtils.leftPad(null, *, *) = null
           StringUtils.leftPad("", 3, 'z') = "zzz"
           StringUtils.leftPad("bat", 3, 'z') = "bat"
           StringUtils.leftPad("bat", 5, 'z') = "zzbat"
           StringUtils.leftPad("bat", 1, 'z') = "bat"
           StringUtils.leftPad("bat", -1, 'z') = "bat"

      Parameters:
        `str` - the String to pad out, may be null
        `size` - the size to pad to
        `padChar` - the character to pad with
      Returns:
        left padded String or original String if no padding is necessary, `null` if null String input
      Since:
        2.0

    - #### padLeft

          public static String padLeft(String str,
                       int size,
                       String padStr)

      Left pad a String with a specified String.

      Pad to a size of `size`.

           StringUtils.leftPad(null, *, *) = null
           StringUtils.leftPad("", 3, "z") = "zzz"
           StringUtils.leftPad("bat", 3, "yz") = "bat"
           StringUtils.leftPad("bat", 5, "yz") = "yzbat"
           StringUtils.leftPad("bat", 8, "yz") = "yzyzybat"
           StringUtils.leftPad("bat", 1, "yz") = "bat"
           StringUtils.leftPad("bat", -1, "yz") = "bat"
           StringUtils.leftPad("bat", 5, null) = " bat"
           StringUtils.leftPad("bat", 5, "") = " bat"

      Parameters:
        `str` - the String to pad out, may be null
        `size` - the size to pad to
        `padStr` - the String to pad with, null or empty treated as single space
      Returns:
        left padded String or original String if no padding is necessary, `null` if null String input

    - #### isEmpty

          public static boolean isEmpty(String str)

      Checks if a String is empty ("") or null.

           StringUtils.isEmpty(null) = true
           StringUtils.isEmpty("") = true
           StringUtils.isEmpty(" ") = false
           StringUtils.isEmpty("bob") = false
           StringUtils.isEmpty(" bob ") = false

      NOTE: This method changed in Lang version 2.0. It no longer trims the String. That functionality is available in isBlank().

      Parameters:
        `str` - the String to check, may be null
      Returns:
        `true` if the String is empty or null

    - #### padRight

          public static String padRight(String inputString,
                        int size,
                        char paddingChar)

      Right-pad a String with a configurable padding character.
      Parameters:
        `inputString` - The String to pad. A `null` String will be treated like an empty String.
        `size` - Pad String by the number of characters.
        `paddingChar` - The character to pad the String with.
      Returns:
        The padded String. If the provided String is null, an empty String is returned.

    - #### padRight

          public static String padRight(String string,
                        int size)

      Right-pad the provided String with empty spaces.
      Parameters:
        `string` - The String to pad
        `size` - Pad String by the number of characters.
      Returns:
        The padded String. If the provided String is null, an empty String is returned.