Module: mdeterman/utils-string

mdeterman/utils-string

A port of Apache Commons StringUtils
Version:
  • 1.0.0
Author:
Source:

Methods

<static> isAnyBlank(string) → {boolean}

Checks if any one of the String are blank (""), null or undefined.
Parameters:
Name Type Description
string string The strings to validate UtilsString('string1', "string2", ...)
Since:
  • 1.0
Source:
Returns:
true if any of the CharSequences are blank or null undefined or or whitespace only
Type
boolean
Example
StringUtils.isAnyBlank(null)             = true
StringUtils.isAnyBlank(null, "foo")      = true
StringUtils.isAnyBlank(null, null)       = true
StringUtils.isAnyBlank("", "bar")        = true
StringUtils.isAnyBlank("bob", "")        = true
StringUtils.isAnyBlank("  bob  ", null)  = true
StringUtils.isAnyBlank(" ", "bar")       = true
StringUtils.isAnyBlank("foo", "bar")     = false

<static> isAnyEmpty(string) → {boolean}

Checks if any one of the String are empty (""), null or undefined.
Parameters:
Name Type Description
string string The strings to validate UtilsString('string1', "string2", ...)
Since:
  • 1.0
Source:
Returns:
true if any of the string are empty, null, or undefined
Type
boolean
Example
UtilsString.isAnyEmpty(null)             = true
UtilsString.isAnyEmpty(null, "foo")      = true
UtilsString.isAnyEmpty("", "bar")        = true
UtilsString.isAnyEmpty("bob", "")        = true
UtilsString.isAnyEmpty("  bob  ", null)  = true
UtilsString.isAnyEmpty(" ", "bar")       = false
UtilsString.isAnyEmpty("foo", "bar")     = false

<static> isBlank(string) → {boolean}

Checks if a String is whitespace, empty (""), null, or undefined.
Parameters:
Name Type Description
string string The string to validate
Since:
  • 1.0
Source:
Returns:
rue if the CharSequence is null, empty, undefined or whitespace
Type
boolean
Example
UtilsString.isBlank(null)      = true
UtilsString.isBlank("")        = true
UtilsString.isBlank(" ")       = true
UtilsString.isBlank("bob")     = false
UtilsString.isBlank("  bob  ") = false

<static> isEmpty(string) → {boolean}

Checks if a String is empty (""), null or undefined.
Parameters:
Name Type Description
string string The string to validate
Since:
  • 1.0
Source:
Returns:
true if the String is empty, null or undefined
Type
boolean
Example
UtilsString.isEmpty(null)      = true
UtilsString.isEmpty("")        = true
UtilsString.isEmpty(" ")       = false
UtilsString.isEmpty("bob")     = false
UtilsString.isEmpty("  bob  ") = false

<static> isNoneBlank(string) → {boolean}

Checks if none of the String are blank (""), null, undefined and whitespace only..
Parameters:
Name Type Description
string string The strings to validate UtilsString('string1', "string2", ...)
Since:
  • 1.0
Source:
Returns:
true if none of the CharSequences are blank or null or undefined or whitespace only
Type
boolean
Example
StringUtils.isNoneBlank(null)             = false
StringUtils.isNoneBlank(null, "foo")      = false
StringUtils.isNoneBlank(null, null)       = false
StringUtils.isNoneBlank("", "bar")        = false
StringUtils.isNoneBlank("bob", "")        = false
StringUtils.isNoneBlank("  bob  ", null)  = false
StringUtils.isNoneBlank(" ", "bar")       = false
StringUtils.isNoneBlank("foo", "bar")     = true

<static> isNoneEmpty(string) → {boolean}

Checks if none of the CharSequences are empty (""), null and undefined.
Parameters:
Name Type Description
string string The strings to validate UtilsString('string1', "string2", ...)
Since:
  • 1.0
Source:
Returns:
true if none of the CharSequences are empty, null or undefined
Type
boolean
Example
UtilsString.isNoneEmpty(null)             = false
UtilsString.isNoneEmpty(null, "foo")      = false
UtilsString.isNoneEmpty("", "bar")        = false
UtilsString.isNoneEmpty("bob", "")        = false
UtilsString.isNoneEmpty("  bob  ", null)  = false
UtilsString.isNoneEmpty(" ", "bar")       = true
UtilsString.isNoneEmpty("foo", "bar")     = true

<static> isNotBlank(string) → {boolean}

Checks if a String is not empty (""), not null, not undefined, and not whitespace only.
Parameters:
Name Type Description
string string The strings to validate UtilsString('string1', "string2", ...)
Since:
  • 1.0
Source:
Returns:
if the CharSequence is not empty and not null and not undefined, and not whitespace
Type
boolean
Example
UtilsString.isNotBlank(null)      = false
UtilsString.isNotBlank("")        = false
UtilsString.isNotBlank(" ")       = false
UtilsString.isNotBlank("bob")     = true
UtilsString.isNotBlank("  bob  ") = true

<static> isNotEmpty(string) → {boolean}

Checks if a String is not empty (""), not null and not undefined.
Parameters:
Name Type Description
string string The string to validate
Since:
  • 1.0
Source:
Returns:
true if the String is not empty, not null and not undefined
Type
boolean
Example
UtilsString.isNotEmpty(null)      = false
UtilsString.isNotEmpty("")        = false
UtilsString.isNotEmpty(" ")       = true
UtilsString.isNotEmpty("bob")     = true
UtilsString.isNotEmpty("  bob  ") = true

<static> trim(string) → {string}

The String is trimmed using String.trim().
Parameters:
Name Type Description
string string the String to be trimmed, may be null or undefined
Since:
  • 1.0
Source:
Returns:
the trimmed String, null if only chars <= 32, empty or null or undefined String input
Type
string
Example
StringUtils.trim(null)          = null
StringUtils.trim("")            = ""
StringUtils.trim("     ")       = ""
StringUtils.trim("abc")         = "abc"
StringUtils.trim("    abc    ") = "abc"

<static> trimToEmpty(string) → {string}

The String is trimmed using String.trim().
Parameters:
Name Type Description
string string he String to be trimmed, may be null or undefined
Since:
  • 1.0
Source:
Returns:
the trimmed String, or an empty String if null or undefined input
Type
string
Example
StringUtils.trimToEmpty(null)          = ""
StringUtils.trimToEmpty("")            = ""
StringUtils.trimToEmpty("     ")       = ""
StringUtils.trimToEmpty("abc")         = "abc"
StringUtils.trimToEmpty("    abc    ") = "abc"

<static> trimToNull(string) → {string}

The String is trimmed using String.trim().
Parameters:
Name Type Description
string string the String to be trimmed, may be null or undefined
Since:
  • 1.0
Source:
Returns:
the trimmed String, null if only chars <= 32, empty or null String input
Type
string
Example
StringUtils.trimToNull(null)          = null
StringUtils.trimToNull("")            = null
StringUtils.trimToNull("     ")       = null
StringUtils.trimToNull("abc")         = "abc"
StringUtils.trimToNull("    abc    ") = "abc"