类 StringUtils

java.lang.Object
com.alibaba.nacos.api.utils.StringUtils

public class StringUtils extends Object
StringUtils. copy from apache common-lang3.
作者:
lin-mt
  • 字段详细资料

    • EMPTY

      public static final String EMPTY
      The empty String "".
      从以下版本开始:
      2.0
      另请参阅:
      常量字段值
  • 构造器详细资料

    • StringUtils

      public StringUtils()
  • 方法详细资料

    • isEmpty

      public static boolean isEmpty(CharSequence cs)

      Checks if a CharSequence 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 CharSequence. That functionality is available in isBlank().

      参数:
      cs - the CharSequence to check, may be null
      返回:
      true if the CharSequence is empty or null
      从以下版本开始:
      3.0 Changed signature from isEmpty(String) to isEmpty(CharSequence)
    • isBlank

      public static boolean isBlank(CharSequence cs)

      Checks if a CharSequence is whitespace, empty ("") or null.

       StringUtils.isBlank(null)      = true
       StringUtils.isBlank("")        = true
       StringUtils.isBlank(" ")       = true
       StringUtils.isBlank("bob")     = false
       StringUtils.isBlank("  bob  ") = false
       
      参数:
      cs - the CharSequence to check, may be null
      返回:
      true if the CharSequence is null, empty or whitespace
      从以下版本开始:
      2.0, 3.0 Changed signature from isBlank(String) to isBlank(CharSequence)
    • trim

      public static String trim(String str)

      Removes control characters (char <= 32) from both ends of this String, handling null by returning null.

      The String is trimmed using String.trim(). Trim removes start and end characters <= 32.

       StringUtils.trim(null)          = null
       StringUtils.trim("")            = ""
       StringUtils.trim("     ")       = ""
       StringUtils.trim("abc")         = "abc"
       StringUtils.trim("    abc    ") = "abc"
       
      参数:
      str - the String to be trimmed, may be null
      返回:
      the trimmed string, null if null String input
    • equals

      public static boolean equals(CharSequence cs1, CharSequence cs2)

      Compares two CharSequences, returning true if they represent equal sequences of characters.

      nulls are handled without exceptions. Two null references are considered to be equal. The comparison is case sensitive.

       StringUtils.equals(null, null)   = true
       StringUtils.equals(null, "abc")  = false
       StringUtils.equals("abc", null)  = false
       StringUtils.equals("abc", "abc") = true
       StringUtils.equals("abc", "ABC") = false
       
      参数:
      cs1 - the first CharSequence, may be null
      cs2 - the second CharSequence, may be null
      返回:
      true if the CharSequences are equal (case-sensitive), or both null
      从以下版本开始:
      3.0 Changed signature from equals(String, String) to equals(CharSequence, CharSequence)
      另请参阅:
      Object.equals(Object)
    • regionMatches

      public static boolean regionMatches(CharSequence cs, boolean ignoreCase, int thisStart, CharSequence substring, int start, int length)
      Green implementation of regionMatches.
      参数:
      cs - the CharSequence to be processed
      ignoreCase - whether or not to be case insensitive
      thisStart - the index to start on the cs CharSequence
      substring - the CharSequence to be looked for
      start - the index to start on the substring CharSequence
      length - character length of the region
      返回:
      whether the region matched