public class StringUtils2
extends java.lang.Object
StringUtils class.| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
abbreviate(java.lang.String str,
int max)
Abbreviates a String using ellipses.
|
static void |
appendEscapedNonAlphaNumericChars(java.lang.String str,
boolean escapeDot,
java.lang.StringBuilder result)
Escape all non 'a' to 'z','A' to 'Z', '0' to '9' and '-' with a '_'.
|
static void |
appendEscapedNonAlphaNumericChars(java.lang.String str,
java.lang.StringBuilder result)
Escape all non 'a' to 'z','A' to 'Z', '0' to '9' and '-' with a '_'.
|
static java.util.List<java.lang.String> |
delimitedStringToList(java.lang.String delimitedString)
Split given String.
|
static boolean |
isNullOrEmpty(java.lang.String value) |
static java.lang.String |
join(java.util.List<java.lang.String> tokens,
java.lang.String delimiter)
Join given
tokens with given delimiter. |
static java.lang.String |
reverseTokens(java.lang.String str,
java.lang.String delimiter)
Reverse tokens of given tokenized
str. |
static java.lang.String |
trimToEmpty(java.lang.String str)
if the given string is
null, return "", else return String.trim(). |
public static java.util.List<java.lang.String> delimitedStringToList(@Nullable
java.lang.String delimitedString)
",", ";" and "\n".delimitedString - null if given delimitedString is nullpublic static java.lang.String join(@Nullable
java.util.List<java.lang.String> tokens,
@Nonnull
java.lang.String delimiter)
tokens with given delimiter.
Sample: tokens "com", "mycompany, "ecommerce", "server1" with delimiter "."
returns "com.mycompany.ecommerce.server1".tokens - delimiter - null if given tokens is nullpublic static java.lang.String reverseTokens(@Nullable
java.lang.String str,
@Nonnull
java.lang.String delimiter)
Reverse tokens of given tokenized str.
Sample: "server1.ecommerce.mycompany.com" returns "com.mycompany.ecommerce.server1".
str - delimiter - null if given string is nullpublic static void appendEscapedNonAlphaNumericChars(@Nullable
java.lang.String str,
boolean escapeDot,
@Nonnull
java.lang.StringBuilder result)
escapeDot is true.str - the string to escapeescapeDot - indicates whether '.' should be escaped into '_' or not.result - the StringBuilder in which the escaped string is appendedpublic static void appendEscapedNonAlphaNumericChars(@Nonnull
java.lang.String str,
@Nonnull
java.lang.StringBuilder result)
str - the string to escaperesult - the StringBuilder in which the escaped string is appendedpublic static boolean isNullOrEmpty(@Nullable
java.lang.String value)
@Nonnull
public static java.lang.String abbreviate(java.lang.String str,
int max)
str - the String to abbreviatemax - the max number of chars of the abbreviated String@Nonnull
public static java.lang.String trimToEmpty(@Nullable
java.lang.String str)
null, return "", else return String.trim().str - the string to trimCopyright © 2019. All Rights Reserved.