Package org.apache.ivy.util
Class StringUtils
java.lang.Object
org.apache.ivy.util.StringUtils
Convenient class used only for uncapitalization. Usually use commons lang but here we do not want
to have such a dependency for only one feature
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
assertNotNullNorEmpty
(String value, String errorMessage) Asserts that the passedvalue
is not null and not an emptyString
.static void
assertNotNullNotEmpty
(String value, String errorMessage) Deprecated.static final String
Decrypts a string encrypted with encrypt.static final String
Encrypt the given string in a way which anybody having access to this method algorithm can easily decrypt.static String
Returns the error message associated with the given Throwable.static String
Returns the exception stack trace as a String.static boolean
static String
Deprecated.static String
Joins the given string array in one string, each separated by the given separator.static String
static String[]
splitToArray
(String list) Splits the given string into a string array using comma as a separator.static String
uncapitalize
(String string)
-
Method Details
-
uncapitalize
-
getErrorMessage
Returns the error message associated with the given Throwable. The error message returned will try to be as precise as possible, handling cases where e.getMessage() is not meaningful, likeNullPointerException
for instance.- Parameters:
t
- the throwable to get the error message from- Returns:
- the error message of the given exception
-
getStackTrace
Returns the exception stack trace as a String.- Parameters:
e
- the exception to get the stack trace from.- Returns:
- the exception stack trace
-
join
Deprecated. -
joinArray
Joins the given string array in one string, each separated by the given separator. Example:joinArray(new String[] {"one", "two", "three"}, ", ") -> "one, two, three"
- Parameters:
objs
- The array of strings.sep
- The separator to use.- Returns:
- The concatenated string.
-
splitToArray
Splits the given string into a string array using comma as a separator. Every array member getstrimmed
.- Parameters:
list
- the string- Returns:
- String[]
-
isNullOrEmpty
Checks that a string is not null or consists of whitespace bytrimming
and checking thelength
of the result.- Parameters:
s
- the string to check- Returns:
- boolean
-
assertNotNullNorEmpty
Asserts that the passedvalue
is not null and not an emptyString
. The implementation of this methodtrims
the (non-null)value
to check whether the value is an empty string. If thevalue
is either null or empty, then this method throws anIllegalArgumentException
with the passederrorMessage
as the message in the exception.- Parameters:
value
- The value to check forerrorMessage
- The error message
-
assertNotNullNotEmpty
Deprecated. -
encrypt
Encrypt the given string in a way which anybody having access to this method algorithm can easily decrypt. This is useful only to avoid clear string storage in a file for example, but shouldn't be considered as a real mean of security. This only works with simple characters (char < 256).- Parameters:
str
- the string to encrypt- Returns:
- the encrypted version of the string
-
decrypt
Decrypts a string encrypted with encrypt.- Parameters:
str
- the encrypted string to decrypt- Returns:
- The decrypted string.
-
repeat
-