org.beangle.commons.lang

Strings

Related Doc: package lang

object Strings

Operations on java.lang.String that are null safe.

Since

3.0

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Strings
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. val DELIMITER: String

    Constant DELIMITER=","

    Constant DELIMITER=","

  5. def abbreviate(str: String, offset: Int, maxWidth: Int): String

  6. def abbreviate(str: String, maxWidth: Int): String

  7. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  8. def capitalize(str: String): String

    Capitalizes a String changing the first letter to title case as per Character#toTitleCase(char).

    Capitalizes a String changing the first letter to title case as per Character#toTitleCase(char). No other letters are changed. For a word based algorithm, see returns null.

    capitalize(null)  = null
    capitalize("")    = ""
    capitalize("cat") = "Cat"
    capitalize("cAt") = "CAt"
    

    str

    the String to capitalize, may be null

    returns

    the capitalized String, null if null String input

    Since

    2.0

    See also

    #uncapitalize(String)

  9. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  10. def concat(seq: Any*): String

    concat.

    concat.

    seq

    a java.lang.String object.

    returns

    a java.lang.String object.

  11. def contains(seq: CharSequence, searchChar: Int): Boolean

    Checks if CharSequence contains a search character, handling null.

    Checks if CharSequence contains a search character, handling null. This method uses String#indexOf(int) if possible. A null or empty ("") CharSequence will return false.

    contains(null, *)    = false
    contains("", *)      = false
    contains("abc", 'a') = true
    contains("abc", 'z') = false
    

    seq

    the CharSequence to check, may be null

    searchChar

    the character to find

    returns

    true if the CharSequence contains the search character, false if not or null string input

    Since

    2.0

  12. def contains(seq: CharSequence, searchSeq: CharSequence): Boolean

    Checks if CharSequence contains a search CharSequence, handling null.

    Checks if CharSequence contains a search CharSequence, handling null. This method uses String#indexOf(String) if possible. A null CharSequence will return false.

    contains(null, *)     = false
    contains(*, null)     = false
    contains("", "")      = true
    contains("abc", "")   = true
    contains("abc", "a")  = true
    contains("abc", "z")  = false
    

    seq

    the CharSequence to check, may be null

    searchSeq

    the CharSequence to find, may be null

    returns

    true if the CharSequence contains the search CharSequence, false if not or null string input

  13. def count(host: String, searchStr: String): Int

    count inner string in host string

    count inner string in host string

    host

    a java.lang.String object.

    searchStr

    a java.lang.String object.

    returns

    a int.

  14. def count(host: String, charactor: Char): Int

    count char in host string

    count char in host string

    host

    java.lang.String object.

    charactor

    a char.

    returns

    a int.

  15. def defaultIfBlank[T <: CharSequence](str: T, defaultStr: T): T

    Returns either the passed in CharSequence, or if the CharSequence is whitespace, empty ("") or null, the value of defaultStr.

    Returns either the passed in CharSequence, or if the CharSequence is whitespace, empty ("") or null, the value of defaultStr.

    str
    defaultStr

  16. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  17. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  18. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  19. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  20. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  21. def insert(str: String, given: String, begin: Int, end: Int): String

    replace [bigen,end] [1...end] with givenStr 可以使用StringBuilder的replace方法替换该方法

    replace [bigen,end] [1...end] with givenStr 可以使用StringBuilder的replace方法替换该方法

    str

    a java.lang.String object.

    given

    a java.lang.String object.

    begin

    a int.

    end

    a int.

    returns

    a java.lang.String object.

  22. def insert(str: String, c: String, pos: Int): String

    insert.

    insert.

    str

    a java.lang.String object.

    c

    a java.lang.String object.

    pos

    a int.

    returns

    a java.lang.String object.

  23. def intersectSeq(first: String, second: String, delimiter: String): String

    返回一个新的逗号相隔字符串,实现其中的单词a-b的功能

    返回一个新的逗号相隔字符串,实现其中的单词a-b的功能

    first

    a java.lang.String object.

    second

    a java.lang.String object.

    delimiter

    a java.lang.String object.

    returns

    a java.lang.String object.

  24. def intersectSeq(first: String, second: String): String

    intersectSeq.

    intersectSeq.

    first

    a java.lang.String object.

    second

    a java.lang.String object.

    returns

    a java.lang.String object.

  25. def isBlank(cs: CharSequence): Boolean

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

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

    isBlank(null)      = true
    isBlank("")        = true
    isBlank(" ")       = true
    isBlank("bob")     = false
    isBlank("  bob  ") = false
    

    cs

    the CharSequence to check, may be null

    returns

    true if the CharSequence is null, empty or whitespace

    Since

    3.0

  26. def isEmpty(cs: CharSequence): Boolean

    Returns true is cs is null or cs.length equals 0.

    Returns true is cs is null or cs.length equals 0.

    Annotations
    @inline()
  27. def isEqualSeq(first: String, second: String, delimiter: String): Boolean

    判断两个","逗号相隔的字符串中的单词是否完全等同.

    判断两个","逗号相隔的字符串中的单词是否完全等同.

    first

    a java.lang.String object.

    second

    a java.lang.String object.

    delimiter

    a java.lang.String object.

    returns

    a boolean.

  28. def isEqualSeq(first: String, second: String): Boolean

    isEqualSeq.

    isEqualSeq.

    first

    not null

    second

    not null

    returns

    a boolean.

  29. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  30. def isNotBlank(cs: CharSequence): Boolean

    Checks if a CharSequence is not empty (""), not null and not whitespace only.

    Checks if a CharSequence is not empty (""), not null and not whitespace only.

    isNotBlank(null)      = false
    isNotBlank("")        = false
    isNotBlank(" ")       = false
    isNotBlank("bob")     = true
    isNotBlank("  bob  ") = true
    

    cs

    the CharSequence to check, may be null

    returns

    true if the CharSequence is not empty and not null and not whitespace

    Since

    3.0

  31. def isNotEmpty(cs: CharSequence): Boolean

    Return true if cs not null and cs has length.

    Return true if cs not null and cs has length.

    Annotations
    @inline()
  32. def join(seq: Array[String], delimiter: String): String

    将数组中的字符串,用delimiter串接起来.
    首尾不加delimiter

    将数组中的字符串,用delimiter串接起来.
    首尾不加delimiter

    seq

    an array of java.lang.String objects.

    delimiter

    a java.lang.String object.

    returns

    a java.lang.String object.

  33. def join(seq: String*): String

    join.

    join.

    seq

    a java.lang.String object.

    returns

    a java.lang.String object.

  34. def join(seq: Iterable[_], delimiter: String): String

    join.

    join.

    seq
    delimiter

    a java.lang.String object.

    returns

    a java.lang.String object.

  35. def keepSeqUnique(keyString: String): String

    保持逗号分隔的各个单词都是唯一的。并且按照原来的顺序存放。

    保持逗号分隔的各个单词都是唯一的。并且按照原来的顺序存放。

    returns

    a java.lang.String object.

  36. def leftPad(str: String, size: Int, padChar: Char): String

    Left pad a String with a specified character.

    Left pad a String with a specified character. Pad to a size of size.

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

    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

    3.0

  37. def lowerCase(s: String): String

  38. def mergeSeq(first: String, second: String, delimiter: String): String

    将两个用delimiter串起来的字符串,合并成新的串,重复的"单词"只出现一次.

    将两个用delimiter串起来的字符串,合并成新的串,重复的"单词"只出现一次. 如果第一个字符串以delimiter开头,第二个字符串以delimiter结尾,
    合并后的字符串仍以delimiter开头和结尾.

    mergeSeq(",1,2,", "") = ",1,2,";
    mergeSeq(",1,2,", null) = ",1,2,";
    mergeSeq("1,2", "3") = "1,2,3";
    mergeSeq("1,2", "3,") = "1,2,3,";
    mergeSeq(",1,2", "3,") = ",1,2,3,";
    mergeSeq(",1,2,", ",3,") = ",1,2,3,";
    

    first

    a java.lang.String object.

    second

    a java.lang.String object.

    delimiter

    a java.lang.String object.

    returns

    a java.lang.String object.

  39. def mergeSeq(first: String, second: String): String

    mergeSeq.

    mergeSeq.

    first

    a java.lang.String object.

    second

    a java.lang.String object.

    returns

    a java.lang.String object.

  40. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  41. final def notify(): Unit

    Definition Classes
    AnyRef
  42. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  43. def remove(str: String, remove: Char): String

    Removes all occurrences of a character from within the source string.

    Removes all occurrences of a character from within the source string. A null source string will return null. An empty ("") source string will return the empty string.

    StringUtils.remove(null, *) = null
    StringUtils.remove("", *) = ""
    StringUtils.remove("queued", 'u') = "qeed"
    StringUtils.remove("queued", 'z') = "queued"
    

    str

    the source String to search, may be null

    remove

    the char to search for and remove, may be null

    returns

    the substring with the char removed if found, null if null String input

  44. def removeWord(host: String, word: String, delimiter: String): String

    removeWord.

    removeWord.

    host

    a java.lang.String object.

    word

    a java.lang.String object.

    delimiter

    a java.lang.String object.

    returns

    a java.lang.String object.

  45. def removeWord(host: String, word: String): String

    removeWord.

    removeWord.

    host

    a java.lang.String object.

    word

    a java.lang.String object.

    returns

    a java.lang.String object.

  46. def repeat(str: String, repeat: Int): String

    Repeat a String repeat times to form a new String.

    Repeat a String repeat times to form a new String.

    repeat(null, 2) = null
    repeat("", 0)   = ""
    repeat("", 2)   = ""
    repeat("a", 3)  = "aaa"
    repeat("ab", 2) = "abab"
    repeat("a", -2) = ""
    

    str

    the String to repeat, may be null

    repeat

    number of times to repeat str, negative treated as zero

    returns

    a new String consisting of the original String repeated, null if null String input

    Since

    3.0

  47. def repeat(ch: Char, repeat: Int): String

    Returns padding using the specified delimiter repeated to a given length.

    Returns padding using the specified delimiter repeated to a given length.

    repeat(0, 'e')  = ""
    repeat(3, 'e')  = "eee"
    repeat(-2, 'e') = ""
    

    ch

    character to repeat

    repeat

    number of times to repeat char, negative treated as zero

    returns

    String with repeated character

    See also

    #repeat(String, int)

  48. def replace(text: String, searchString: String, replacement: String): String

    Replaces all occurrences of a String within another String.

    Replaces all occurrences of a String within another String. A null reference passed to this method is a no-op.

    replace(null, *, *)        = null
    replace("", *, *)          = ""
    replace("any", null, *)    = "any"
    replace("any", *, null)    = "any"
    replace("any", "", *)      = "any"
    replace("aba", "a", null)  = "aba"
    replace("aba", "a", "")    = "b"
    replace("aba", "a", "z")   = "zbz"
    

    text

    text to search and replace in, may be null

    searchString

    the String to search for, may be null

    replacement

    the String to replace it with, may be null

    returns

    the text with any replacements processed, null if null String input

  49. def rightPad(str: String, size: Int, padChar: Char): String

    Right pad a String with a specified character.

    Right pad a String with a specified character. The String is padded to the size of size.

    rightPad(null, *, *)     = null
    rightPad("", 3, 'z')     = "zzz"
    rightPad("bat", 3, 'z')  = "bat"
    rightPad("bat", 5, 'z')  = "batzz"
    rightPad("bat", 1, 'z')  = "bat"
    rightPad("bat", -1, 'z') = "bat"
    

    str

    the String to pad out, may be null

    size

    the size to pad to

    padChar

    the character to pad with

    returns

    right padded String or original String if no padding is necessary, null if null String input

    Since

    3.0

  50. def split(str: String, separatorChars: String): Array[String]

    Splits the provided text into an array, separators specified.

    Splits the provided text into an array, separators specified. This is an alternative to using StringTokenizer. A null input String returns null. A null separatorChars splits on whitespace.

    split(null, *)         = null
    split("", *)           = []
    split("abc def", null) = ["abc", "def"]
    split("abc def", " ")  = ["abc", "def"]
    split("abc  def", " ") = ["abc", "def"]
    split("ab:cd:ef", ":") = ["ab", "cd", "ef"]
    

  51. def split(target: String, separatorChars: Array[Char]): Array[String]

    split with separators

    split with separators

    target

    a java.lang.String object.

    separatorChars

    an array of char.

    returns

    an array of java.lang.String objects.

  52. def split(str: String, separatorChar: Char): Array[String]

    Splits the provided text into an array, separator specified.

    Splits the provided text into an array, separator specified. This is an alternative to using StringTokenizer. A null input String returns null.

    split(null, *)         = null
    split("", *)           = []
    split("a.b.c", '.')    = ["a", "b", "c"]
    split("a..b.c", '.')   = ["a", "b", "c"]
    split("a:b:c", '.')    = ["a:b:c"]
    split("a b c", ' ')    = ["a", "b", "c"]
    

  53. def split(target: String): Array[String]

    split.

    split.

    target

    a java.lang.String object.

    returns

    an array of java.lang.String objects.

  54. def splitNumSeq(numSeq: String): Array[Int]

    将1-2,3,4-9之类的序列拆分成数组

    将1-2,3,4-9之类的序列拆分成数组

    numSeq

    a java.lang.String object.

    returns

    an array of Int objects.

  55. def splitToInt(ids: String): Array[Int]

    splitToInteger.

  56. def splitToInteger(ids: String): Array[Integer]

    splitToInteger.

  57. def splitToLong(ids: String): Array[Long]

    splitToLong.

  58. def stripEnd(str: String, stripChars: String): String

    Strips any of a set of characters from the end of a String.

    Strips any of a set of characters from the end of a String.

    A null input String returns null. An empty string ("") input returns the empty string.

    If the stripChars String is null, whitespace is stripped as defined by Character#isWhitespace(char).

    stripEnd(null, *)          = null
    stripEnd("", *)            = ""
    stripEnd("abc", "")        = "abc"
    stripEnd(*, null)    = *
    stripEnd("  abcyx", "xyz") = "  abc"
    

    str

    the String to remove characters from, may be null

    stripChars

    the characters to remove, null treated as whitespace

    returns

    the stripped String, null if null String input

  59. def substring(str: String, startIndex: Int, endIndex: Int): String

    Gets a substring from the specified String avoiding exceptions.

    Gets a substring from the specified String avoiding exceptions. A negative start position can be used to start/end n characters from the end of the String. The returned substring starts with the character in the start position and ends before the end position. All position counting is zero-based -- i.e., to start at the beginning of the string use start = 0. Negative start and end positions can be used to specify offsets relative to the end of the String. If start is not strictly to the left of end, "" is returned.

    substring(null, *, *)    = null
    substring("", * ,  *)    = "";
    substring("abc", 0, 2)   = "ab"
    substring("abc", 2, 0)   = ""
    substring("abc", 2, 4)   = "c"
    substring("abc", 4, 6)   = ""
    substring("abc", 2, 2)   = ""
    substring("abc", -2, -1) = "b"
    substring("abc", -4, 2)  = "ab"
    

    str

    the String to get the substring from, may be null

    returns

    substring from start position to end position, null if null String input

  60. def substringAfter(str: String, separator: String): String

    Gets the substring after the first occurrence of a separator.

    Gets the substring after the first occurrence of a separator. The separator is not returned. A null string input will return null. An empty ("") string input will return the empty string. A null separator will return the empty string if the input string is not null. If nothing is found, the empty string is returned.

    substringAfter(null, *)      = null
    substringAfter("", *)        = ""
    substringAfter(*, null)      = ""
    substringAfter("abc", "a")   = "bc"
    substringAfter("abcba", "b") = "cba"
    substringAfter("abc", "c")   = ""
    substringAfter("abc", "d")   = ""
    substringAfter("abc", "")    = "abc"
    

    str

    the String to get a substring from, may be null

    separator

    the String to search for, may be null

    returns

    the substring after the first occurrence of the separator, null if null String input

    Since

    2.0

  61. def substringAfterLast(str: String, separator: String): String

    Gets the substring after the last occurrence of a separator.

    Gets the substring after the last occurrence of a separator. The separator is not returned. A null string input will return null. An empty ("") string input will return the empty string. An empty or null separator will return the empty string if the input string is not null. If nothing is found, the empty string is returned.

    substringAfterLast(null, *)      = null
    substringAfterLast("", *)        = ""
    substringAfterLast(*, "")        = ""
    substringAfterLast(*, null)      = ""
    substringAfterLast("abc", "a")   = "bc"
    substringAfterLast("abcba", "b") = "a"
    substringAfterLast("abc", "c")   = ""
    substringAfterLast("a", "a")     = ""
    substringAfterLast("a", "z")     = ""
    

    str

    the String to get a substring from, may be null

    separator

    the String to search for, may be null

    returns

    the substring after the last occurrence of the separator, null if null String input

    Since

    3.0

  62. def substringBefore(str: String, separator: String): String

    Gets the substring before the first occurrence of a separator.

    Gets the substring before the first occurrence of a separator. The separator is not returned. A null string input will return null. An empty ("") string input will return the empty string. A null separator will return the input string. If nothing is found, the string input is returned.

    substringBefore(null, *)      = null
    substringBefore("", *)        = ""
    substringBefore("abc", "a")   = ""
    substringBefore("abcba", "b") = "a"
    substringBefore("abc", "c")   = "ab"
    substringBefore("abc", "d")   = "abc"
    substringBefore("abc", "")    = ""
    substringBefore("abc", null)  = "abc"
    

    str

    the String to get a substring from, may be null

    separator

    the String to search for, may be null

    returns

    the substring before the first occurrence of the separator, null if null String input

    Since

    2.0

  63. def substringBeforeLast(str: String, separator: String): String

    Gets the substring before the last occurrence of a separator.

    Gets the substring before the last occurrence of a separator. The separator is not returned. A null string input will return null. An empty ("") string input will return the empty string. An empty or null separator will return the input string. If nothing is found, the string input is returned.

    substringBeforeLast(null, *)      = null
    substringBeforeLast("", *)        = ""
    substringBeforeLast("abcba", "b") = "abc"
    substringBeforeLast("abc", "c")   = "ab"
    substringBeforeLast("a", "a")     = ""
    substringBeforeLast("a", "z")     = "a"
    substringBeforeLast("a", null)    = "a"
    substringBeforeLast("a", "")      = "a"
    

    str

    the String to get a substring from, may be null

    separator

    the String to search for, may be null

    returns

    the substring before the last occurrence of the separator, null if null String input

    Since

    3.0

  64. def substringBetween(str: String, open: String, close: String): String

    Gets the String that is nested in between two Strings.

    Gets the String that is nested in between two Strings. Only the first match is returned. A null input String returns null. A null open/close returns null (no match). An empty ("") open and close returns an empty string.

    substringBetween("wx[b]yz", "[", "]") = "b"
    substringBetween(null, *, *)          = null
    substringBetween(*, null, *)          = null
    substringBetween(*, *, null)          = null
    substringBetween("", "", "")          = ""
    substringBetween("", "", "]")         = null
    substringBetween("", "[", "]")        = null
    substringBetween("yabcz", "", "")     = ""
    substringBetween("yabcz", "y", "z")   = "abc"
    substringBetween("yabczyabcz", "y", "z")   = "abc"
    

    str

    the String containing the substring, may be null

    open

    the String before the substring, may be null

    close

    the String after the substring, may be null

    returns

    the substring, null if no match

    Since

    3.0

  65. def subtractSeq(first: String, second: String, delimiter: String): String

    返回一个新的逗号相隔字符串,实现其中的单词a-b的功能.

    返回一个新的逗号相隔字符串,实现其中的单词a-b的功能. 新的字符串将以,开始,结束

  66. def subtractSeq(first: String, second: String): String

    subtractSeq.

    subtractSeq.

    first

    a java.lang.String object.

    second

    a java.lang.String object.

    returns

    a java.lang.String object.

  67. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  68. def toString(): String

    Definition Classes
    AnyRef → Any
  69. def transformToInt(ids: Array[String]): Array[Int]

    transformToInt.

    transformToInt.

    ids

    an array of java.lang.String objects.

    returns

    an array of java.lang.Integer objects.

  70. def transformToInteger(ids: Array[String]): Array[Integer]

  71. def transformToLong(ids: Array[String]): Array[Long]

    transformToJLong.

    transformToJLong.

    ids

    an array of java.lang.String objects.

    returns

    an array of java.lang.Long objects.

  72. def trim(str: String): String

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

    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.

    trim(null)          = null
    trim("")            = ""
    trim("     ")       = ""
    trim("abc")         = "abc"
    trim("    abc    ") = "abc"
    

    str

    the String to be trimmed, may be null

    returns

    the trimmed string, null if null String input

    Since

    3.0

  73. def unCamel(str: String, seperator: Char, lowercase: Boolean): String

    将驼峰表示法转换为下划线小写表示

    将驼峰表示法转换为下划线小写表示

    str

    a java.lang.String object.

    seperator

    a char.

    lowercase

    a boolean.

    returns

    a java.lang.String object.

  74. def unCamel(str: String, seperator: Char): String

    unCamel.

    unCamel.

    str

    a java.lang.String object.

    seperator

    a char.

    returns

    a java.lang.String object.

  75. def unCamel(str: String): String

    unCamel.

  76. def uncapitalize(str: String): String

    Uncapitalizes a String changing the first letter to title case as per Character#toLowerCase(char).

    Uncapitalizes a String changing the first letter to title case as per Character#toLowerCase(char). No other letters are changed. For a word based algorithm, see String returns null.

    uncapitalize(null)  = null
    uncapitalize("")    = ""
    uncapitalize("Cat") = "cat"
    uncapitalize("CAT") = "cAT"
    

    str

    the String to uncapitalize, may be null

    returns

    the uncapitalized String, null if null String input

    Since

    3.0

    See also

    #capitalize(String)

  77. def upperCase(s: String): String

  78. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  79. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  80. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped