CharSet instances.
This class handles null input gracefully.
An exception will not be thrown for a null input.
Each method documents its behavior in more detail.
#ThreadSafe#
CharSet
| Access | Constructor and Description |
|---|---|
| public | CharSetUtils()
Deprecated
TODO Make private in 4.0.
CharSetUtils instances should NOT be constructed in standard programming. |
| Modifier and Type | Method and Description |
|---|---|
| public static boolean | Returns: whether or not the characters in the set are in the primary stringString to look for characters in, may be null str, final String... String[] set of characters to identify, may be null set)Takes an argument in set-syntax, see evaluateSet, and identifies whether any of the characters are present in the specified string. |
| public static int | Returns: the character count, zero if null string inputString to count characters in, may be null str, final String... String[] set of characters to count, may be null set)Takes an argument in set-syntax, see evaluateSet, and returns the number of characters present in the specified string. |
| private static boolean | |
| public static String | Returns: the modified String,null if null string inputString to delete characters from, may be null str, final String... String[] set of characters to delete, may be null set)Takes an argument in set-syntax, see evaluateSet, and deletes any of characters present in the specified string. |
| public static String | |
| private static String | |
| public static String |
| CharSetUtils | back to summary |
|---|---|
| public CharSetUtils()
Deprecated TODO Make private in 4.0. CharSetUtils instances should NOT be constructed in standard programming.
Instead, the class should be used as This constructor is public to permit tools that require a JavaBean instance to operate.
| |
| containsAny | back to summary |
|---|---|
| public static boolean containsAny(final String str, final String... set) Takes an argument in set-syntax, see evaluateSet, and identifies whether any of the characters are present in the specified string.
CharSetUtils.containsAny(null, *) = false
CharSetUtils.containsAny("", *) = false
CharSetUtils.containsAny(*, null) = false
CharSetUtils.containsAny(*, "") = false
CharSetUtils.containsAny("hello", "k-p") = true
CharSetUtils.containsAny("hello", "a-d") = false
| |
| count | back to summary |
|---|---|
| public static int count(final String str, final String... set) Takes an argument in set-syntax, see evaluateSet, and returns the number of characters present in the specified string.
CharSetUtils.count(null, *) = 0
CharSetUtils.count("", *) = 0
CharSetUtils.count(*, null) = 0
CharSetUtils.count(*, "") = 0
CharSetUtils.count("hello", "k-p") = 3
CharSetUtils.count("hello", "a-e") = 1
| |
| deepEmpty | back to summary |
|---|---|
| private static boolean deepEmpty(final String[] strings) Determines whether or not all the Strings in an array are empty or not.
| |
| delete | back to summary |
|---|---|
| public static String delete(final String str, final String... set) Takes an argument in set-syntax, see evaluateSet, and deletes any of characters present in the specified string.
CharSetUtils.delete(null, *) = null
CharSetUtils.delete("", *) = ""
CharSetUtils.delete(*, null) = *
CharSetUtils.delete(*, "") = *
CharSetUtils.delete("hello", "hl") = "eo"
CharSetUtils.delete("hello", "le") = "ho"
| |
| keep | back to summary |
|---|---|
| public static String keep(final String str, final String... set) Takes an argument in set-syntax, see evaluateSet, and keeps any of characters present in the specified string.
CharSetUtils.keep(null, *) = null
CharSetUtils.keep("", *) = ""
CharSetUtils.keep(*, null) = ""
CharSetUtils.keep(*, "") = ""
CharSetUtils.keep("hello", "hl") = "hll"
CharSetUtils.keep("hello", "le") = "ell"
| |
| modify | back to summary |
|---|---|
| private static String modify(final String str, final String[] set, final boolean expect) Implements delete and keep. | |
| squeeze | back to summary |
|---|---|
| public static String squeeze(final String str, final String... set) Squeezes any repetitions of a character that is mentioned in the supplied set.
CharSetUtils.squeeze(null, *) = null
CharSetUtils.squeeze("", *) = ""
CharSetUtils.squeeze(*, null) = *
CharSetUtils.squeeze(*, "") = *
CharSetUtils.squeeze("hello", "k-p") = "helo"
CharSetUtils.squeeze("hello", "a-e") = "hello"
| |