public class Tools extends Object
| Modifier and Type | Field and Description |
|---|---|
static boolean |
EXPAND_CASE_INSENSITIVE |
static boolean |
EXPAND_CASE_SENSITIVE |
| Constructor and Description |
|---|
Tools() |
| Modifier and Type | Method and Description |
|---|---|
static String |
appendTrailingSeparator(String aPath)
Checks if a path has trailing separator, if not it appends the correct
one according to the operating system.
|
static String |
base64Encode(byte[] aBA) |
static Object |
castGenericToJava(Object aValue,
String aFromType,
String aToType)
Tries to convert a given object into the given java data type
|
static String |
DateToISO8601(Date aDate) |
static String |
DateToISO8601WithMillis(Date aDate) |
static String |
expandEnvVars(String aString)
Replaces all pattern ${name} in a string by the values of the
corresponding environment variable.
|
static String |
expandEnvVarsAndProps(String aString)
Replaces all pattern ${name} in a string by the values of the
corresponding environment variable or system property.
|
static String |
expandProps(String aString)
Replaces all pattern ${name} in a string by the values of the
corresponding system property.
|
static String |
expandVars(String aString,
Map<String,String> aVars,
boolean aIgnoreCase) |
static String |
getGenericTypeStringFromJavaClassname(String aClassname)
Tries to convert a given object into the given java data type
|
static String |
getJavaClassnameFromGenericType(String aGenericType)
Tries to convert a generic type to the correspondant java type
|
static String |
getMD5(String aMsg)
Returns the MD5 sum of the given string.
|
static String |
getSHA1(String aMsg)
Returns the SHA1 sum of the given string.
|
static Timer |
getTimer() |
static String |
hexByteArrayToString(byte[] aByteArray)
From http://www.rgagnon.com/javadetails/java-0596.html
|
static byte[] |
hexStringToByteArray(String aString)
From
http://stackoverflow.com/questions/140131/convert-a-string-representation-of-a-hex-dump-to-a-byte-array-using-java
|
static String |
intToHex(int aInt,
int aLen)
Returns the hex value of the given int as a string.
|
static String |
intToString(int aInt,
int aLen)
Returns the hex value of the given int as a string.
|
static Object |
invoke(Class aClass,
String aMethodName,
Object... aArgs) |
static Object |
invoke(Object aInstance,
String aMethodName,
Object... aArgs) |
static Object |
invoke(String aClassName,
String aMethodName,
Object... aArgs) |
static Object |
invokeUnique(Class aClass,
String aMethodName,
Object... aArgs) |
static Object |
invokeUnique(Class aClass,
String aMethodName,
Object[] aArgs,
Class[] aClasses) |
static boolean |
isCookieValid(URI aURI,
HttpCookie aCookie)
Indicates if a cookie is valid for a given URI
|
static Date |
ISO8601ToDate(String aISO8601Date) |
static List<String> |
parseStringArrayToList(String[] aArray) |
static void |
startUtilityTimer() |
static void |
stopUtilityTimer() |
static int |
stringToInt(String aString,
int aDefault)
Converts a string into an integer value and automatically sets it to a
given default value if the string could not be parsed.
|
static long |
stringToLong(String aString,
long aDefault)
Converts a string into a long value and automatically sets it to a given
default value if the string could not be parsed.
|
public static final boolean EXPAND_CASE_SENSITIVE
public static final boolean EXPAND_CASE_INSENSITIVE
public static String getMD5(String aMsg)
aMsg - String the string to calculate the MD5 sum for.public static String getSHA1(String aMsg)
aMsg - String the string to calculate the MD5 sum for.public static String intToHex(int aInt, int aLen)
aLen is
greater than zero the output is cut or filled to the given length
otherwise the exact number of digits is returned.aInt - Integer to be converted into a hex-string.aLen - Number of hex digits (optionally filled or cut if needed)public static String intToString(int aInt, int aLen)
aLen is
greater than zero the output is cut or filled to the given length
otherwise the exact number of digits is returned.aInt - Integer to be converted into a string.aLen - Number of digits (optionally filled or cut if needed)public static int stringToInt(String aString, int aDefault)
aString - string to be converted into an integer.aDefault - default value assigned to the result in case of an
exception.public static long stringToLong(String aString, long aDefault)
aString - string to be converted into a long.aDefault - default value assigned to the result in case of an
exception.public static Date ISO8601ToDate(String aISO8601Date)
aISO8601Date - public static String DateToISO8601WithMillis(Date aDate)
aDate - public static String getJavaClassnameFromGenericType(String aGenericType)
aGenericType - public static Object castGenericToJava(Object aValue, String aFromType, String aToType)
aValue - aFromType - aToType - public static String getGenericTypeStringFromJavaClassname(String aClassname)
aClassname - public static String expandVars(String aString, Map<String,String> aVars, boolean aIgnoreCase)
aString - aVars - aIgnoreCase - public static String expandEnvVars(String aString)
aString - public static String expandProps(String aString)
aString - public static String expandEnvVarsAndProps(String aString)
aString - public static Object invoke(String aClassName, String aMethodName, Object... aArgs) throws Exception
aClassName - aMethodName - aArgs - Exceptionpublic static Object invoke(Class aClass, String aMethodName, Object... aArgs) throws Exception
aClass - aMethodName - aArgs - Exceptionpublic static Object invokeUnique(Class aClass, String aMethodName, Object... aArgs) throws Exception
aClass - aMethodName - aArgs - Exceptionpublic static Object invokeUnique(Class aClass, String aMethodName, Object[] aArgs, Class[] aClasses) throws Exception
aClass - aMethodName - aArgs - aClasses - Exceptionpublic static Object invoke(Object aInstance, String aMethodName, Object... aArgs) throws Exception
aInstance - aMethodName - aArgs - Exceptionpublic static String base64Encode(byte[] aBA)
aBA - public static List<String> parseStringArrayToList(String[] aArray)
aArray - public static void startUtilityTimer()
public static void stopUtilityTimer()
public static Timer getTimer()
public static byte[] hexStringToByteArray(String aString)
aString - public static String hexByteArrayToString(byte[] aByteArray)
aByteArray - public static boolean isCookieValid(URI aURI, HttpCookie aCookie)
aURI - aCookie - public static String appendTrailingSeparator(String aPath)
aPath - the path to be checked for the trailing separator.Copyright © 2013. All Rights Reserved.