org.apache.ivy.util

Class StringUtils

public final class StringUtils extends Object

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
static Stringdecrypt(String str)
Decrypts a string encrypted with encrypt.
static Stringencrypt(String str)
Encrypt the given string in a way which anybody having access to this method algorithm can easily decrypt.
static StringgetErrorMessage(Throwable t)
Returns the error message associated with the given Throwable.
static StringgetStackTrace(Exception e)
Returns the exception stack trace as a String.
static Stringjoin(Object[] objs, String sep)
Joins the given object array in one string, each separated by the given separator.
static Stringrepeat(String str, int count)
static Stringuncapitalize(String string)

Method Detail

decrypt

public static final String decrypt(String str)
Decrypts a string encrypted with encrypt.

Parameters: str the encrypted string to decrypt

Returns: The decrypted string.

encrypt

public static final String encrypt(String str)
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

getErrorMessage

public static String getErrorMessage(Throwable t)
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, like NullPointerException for instance.

Parameters: t the throwable to get the error message from

Returns: the error message of the given exception

getStackTrace

public static String getStackTrace(Exception e)
Returns the exception stack trace as a String.

Parameters: e the exception to get the stack trace from.

Returns: the exception stack trace

join

public static String join(Object[] objs, String sep)
Joins the given object array in one string, each separated by the given separator. Example:
 join(new String[] {"one", "two", "three"}, ", ") -> "one, two, three"
 

Parameters: objs The array of objects (toString() is used). sep The separator to use.

Returns: The concatinated string.

repeat

public static String repeat(String str, int count)

uncapitalize

public static String uncapitalize(String string)