com.aliyun.oss.common.utils

## 类 StringUtils

- java.lang.Object
- - com.aliyun.oss.common.utils.StringUtils

-     public class StringUtils
      extends Object

  Utilities for converting objects to strings.

- - ### 字段概要

    字段
    限定符和类型 | 字段和说明
    --- | ---
    `static String` | `COMMA_SEPARATOR`
    `static String` | `DEFAULT_ENCODING`
    `static Charset` | `UTF8`

  - ### 构造器概要

    构造器
    构造器和说明
    `StringUtils()`

  - ### 方法概要

    方法
    限定符和类型 | 方法和说明
    --- | ---
    `static void` | `appendCompactedString(StringBuilder destination, String source)` This method appends a string to a string builder and collapses contiguous white space is a single space.
    `static boolean` | `beginsWithIgnoreCase(String data, String seq)` Performs a case insensitive comparison and returns true if the data begins with the given sequence.
    `static int` | `compare(String str1, String str2)` Compare two strings with Locale.ENGLISH This method is preferred over String.compareTo() method.
    `static String` | `fromBigDecimal(BigDecimal value)`
    `static String` | `fromBigInteger(BigInteger value)`
    `static String` | `fromBoolean(Boolean value)`
    `static String` | `fromByte(Byte b)` Returns the string representation of the specified Byte.
    `static String` | `fromDouble(Double d)` Returns the string representation of the specified double.
    `static String` | `fromFloat(Float value)`
    `static String` | `fromInteger(Integer value)`
    `static String` | `fromLong(Long value)`
    `static String` | `fromString(String value)`
    `static boolean` | `hasValue(String str)`
    `static boolean` | `isNullOrEmpty(String value)`
    `static String` | `join(String joiner, Collection<String> collection)` Joins the strings in collection with joiner between each string
    `static String` | `join(String joiner, String... parts)` Joins the strings in parts with joiner between each string
    `static String` | `lowerCase(String str)` Converts a given String to lower case with Locale.ENGLISH
    `static String` | `replace(String originalString, String partToMatch, String replacement)`
    `static BigDecimal` | `toBigDecimal(String s)`
    `static BigInteger` | `toBigInteger(String s)`
    `static Boolean` | `toBoolean(StringBuilder value)`
    `static Integer` | `toInteger(StringBuilder value)`
    `static String` | `toString(StringBuilder value)`
    `static String` | `trim(String value)` A null-safe trim method.
    `static String` | `upperCase(String str)` Converts a given String to upper case with Locale.ENGLISH

    - ### 从类继承的方法 java.lang.Object

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

- - ### 字段详细资料

    - #### DEFAULT_ENCODING

          public static final String DEFAULT_ENCODING

      另请参阅:
        常量字段值

    - #### COMMA_SEPARATOR

          public static final String COMMA_SEPARATOR

      另请参阅:
        常量字段值

    - #### UTF8

          public static final Charset UTF8

  - ### 构造器详细资料

    - #### StringUtils

          public StringUtils()

  - ### 方法详细资料

    - #### toInteger

          public static Integer toInteger(StringBuilder value)

    - #### toString

          public static String toString(StringBuilder value)

    - #### toBoolean

          public static Boolean toBoolean(StringBuilder value)

    - #### fromInteger

          public static String fromInteger(Integer value)

    - #### fromLong

          public static String fromLong(Long value)

    - #### fromString

          public static String fromString(String value)

    - #### fromBoolean

          public static String fromBoolean(Boolean value)

    - #### fromBigInteger

          public static String fromBigInteger(BigInteger value)

    - #### fromBigDecimal

          public static String fromBigDecimal(BigDecimal value)

    - #### toBigInteger

          public static BigInteger toBigInteger(String s)

    - #### toBigDecimal

          public static BigDecimal toBigDecimal(String s)

    - #### fromFloat

          public static String fromFloat(Float value)

    - #### fromDouble

          public static String fromDouble(Double d)

      Returns the string representation of the specified double.
      参数:
        `d` - The double to represent as a string.
      返回:
        The string representation of the specified double.

    - #### fromByte

          public static String fromByte(Byte b)

      Returns the string representation of the specified Byte.
      参数:
        `b` - The Byte to represent as a string.
      返回:
        The string representation of the specified Byte.

    - #### replace

          public static String replace(String originalString,
                       String partToMatch,
                       String replacement)

    - #### join

          public static String join(String joiner,
                    String... parts)

      Joins the strings in parts with joiner between each string
      参数:
        `joiner` - the string to insert between the strings in parts
        `parts` - the parts to join

    - #### join

          public static String join(String joiner,
                    Collection<String> collection)

      Joins the strings in collection with joiner between each string
      参数:
        `joiner` - the string to insert between the strings in collection
        `collection` - the collection to join

    - #### trim

          public static String trim(String value)

      A null-safe trim method. If the input string is null, returns null; otherwise returns a trimmed version of the input.

    - #### isNullOrEmpty

          public static boolean isNullOrEmpty(String value)

      返回:
        true if the given value is either null or the empty string

    - #### hasValue

          public static boolean hasValue(String str)

      返回:
        true if the given value is non-null and non-empty

    - #### lowerCase

          public static String lowerCase(String str)

      Converts a given String to lower case with Locale.ENGLISH
      参数:
        `str` - the string to be converted to lower case
      返回:
        the lower case of string, or itself if string is null/empty

    - #### upperCase

          public static String upperCase(String str)

      Converts a given String to upper case with Locale.ENGLISH
      参数:
        `str` - the string to be converted to upper case
      返回:
        the upper case of string, or itself if string is null/empty

    - #### compare

          public static int compare(String str1,
                    String str2)

      Compare two strings with Locale.ENGLISH This method is preferred over String.compareTo() method.
      参数:
        `str1` - String 1
        `str2` - String 2
      返回:
        negative integer if str1 lexicographically precedes str2 positive integer if str1 lexicographically follows str2 0 if both strings are equal
      抛出:
        `IllegalArgumentException` - throws exception if both or either of the strings is null

    - #### appendCompactedString

          public static void appendCompactedString(StringBuilder destination,
                                   String source)

      This method appends a string to a string builder and collapses contiguous white space is a single space. This is equivalent to: destination.append(source.replaceAll("\\s+", " ")) but does not create a Pattern object that needs to compile the match string; it also prevents us from having to make a Matcher object as well.

    - #### beginsWithIgnoreCase

          public static boolean beginsWithIgnoreCase(String data,
                                     String seq)

      Performs a case insensitive comparison and returns true if the data begins with the given sequence.

Copyright © 2020. All Rights Reserved.