public class Util
extends java.lang.Object
| Constructor and Description |
|---|
Util() |
| Modifier and Type | Method and Description |
|---|---|
static java.util.Map<java.lang.Object,java.lang.Object> |
calculateDifferences(java.util.Map<?,?> map1,
java.util.Map<?,?> map2) |
static java.lang.Class<?>[] |
getImplementedInterfaces(java.lang.Class<?> clazz)
Retrieves a list with all interfaces implemented by the given class.
|
static java.lang.Object |
getInstance(java.lang.String className,
java.lang.Class<?>[] argTypes,
java.lang.Object[] args,
ExceptionInterceptor exceptionInterceptor) |
static java.lang.Object |
getInstance(java.lang.String className,
java.lang.Class<?>[] argTypes,
java.lang.Object[] args,
ExceptionInterceptor exceptionInterceptor,
java.lang.String errorMessage) |
static int |
getJVMUpdateNumber() |
static int |
getJVMVersion() |
static java.lang.String |
getPackageName(java.lang.Class<?> clazz)
Returns the package name of the given class.
|
static java.lang.Object |
handleNewInstance(java.lang.reflect.Constructor<?> ctor,
java.lang.Object[] args,
ExceptionInterceptor exceptionInterceptor)
Handles constructing new instance with the given constructor and wrapping
(or not, as required) the exceptions that could possibly be generated
|
static boolean |
interfaceExists(java.lang.String hostname)
Does a network interface exist locally with the given hostname?
|
static boolean |
isCommunityEdition(java.lang.String serverVersion)
Checks whether the given server version string is a MySQL Community edition
|
static boolean |
isEnterpriseEdition(java.lang.String serverVersion)
Checks whether the given server version string is a MySQL Enterprise edition
|
static boolean |
isJdbcInterface(java.lang.Class<?> clazz)
Recursively checks for interfaces on the given class to determine if it implements a java.sql, javax.sql or com.mysql.cj.jdbc interface.
|
static boolean |
isJdbcPackage(java.lang.String packageName)
Check if the package name is a known JDBC package.
|
static boolean |
isNullOrEmpty(java.util.List<?> list) |
static boolean |
isRunningOnWindows()
Checks if the JVM is running on Windows Operating System.
|
static boolean |
jvmMeetsMinimum(int version,
int updateNumber) |
static <T> java.util.List<T> |
loadClasses(java.lang.String extensionClassNames,
java.lang.String errorMessageKey,
ExceptionInterceptor exceptionInterceptor) |
static int |
readBlock(java.io.InputStream i,
byte[] b,
ExceptionInterceptor exceptionInterceptor) |
static int |
readBlock(java.io.InputStream i,
byte[] b,
int length,
ExceptionInterceptor exceptionInterceptor) |
static int |
readFully(java.io.Reader reader,
char[] buf,
int length)
Reads length bytes from reader into buf.
|
static long |
secondsSinceMillis(long timeInMillis)
Computes the number of seconds elapsed since the given time in milliseconds.
|
static java.lang.String |
stackTraceToString(java.lang.Throwable ex)
Converts a nested exception into a nicer message
|
static int |
truncateAndConvertToInt(long longValue)
Converts long to int, truncating to maximum/minimum value if needed.
|
static int[] |
truncateAndConvertToInt(long[] longArray)
Converts long[] to int[], truncating to maximum/minimum value if needed.
|
public static int getJVMVersion()
public static boolean jvmMeetsMinimum(int version,
int updateNumber)
public static int getJVMUpdateNumber()
public static boolean isCommunityEdition(java.lang.String serverVersion)
serverVersion - full server version stringpublic static boolean isEnterpriseEdition(java.lang.String serverVersion)
serverVersion - full server version stringpublic static java.lang.String stackTraceToString(java.lang.Throwable ex)
ex - the exception to expand into a message.public static java.lang.Object getInstance(java.lang.String className,
java.lang.Class<?>[] argTypes,
java.lang.Object[] args,
ExceptionInterceptor exceptionInterceptor,
java.lang.String errorMessage)
public static java.lang.Object getInstance(java.lang.String className,
java.lang.Class<?>[] argTypes,
java.lang.Object[] args,
ExceptionInterceptor exceptionInterceptor)
public static java.lang.Object handleNewInstance(java.lang.reflect.Constructor<?> ctor,
java.lang.Object[] args,
ExceptionInterceptor exceptionInterceptor)
ctor - constructorargs - arguments for constructorexceptionInterceptor - exception interceptorpublic static boolean interfaceExists(java.lang.String hostname)
hostname - the hostname (or IP address in string form) to checkpublic static java.util.Map<java.lang.Object,java.lang.Object> calculateDifferences(java.util.Map<?,?> map1,
java.util.Map<?,?> map2)
public static <T> java.util.List<T> loadClasses(java.lang.String extensionClassNames,
java.lang.String errorMessageKey,
ExceptionInterceptor exceptionInterceptor)
public static boolean isJdbcInterface(java.lang.Class<?> clazz)
clazz - The class to investigate.public static boolean isJdbcPackage(java.lang.String packageName)
packageName - The package name to check.public static java.lang.Class<?>[] getImplementedInterfaces(java.lang.Class<?> clazz)
clazz - The class from which the interface list will be retrieved.public static long secondsSinceMillis(long timeInMillis)
timeInMillis - The past instant in milliseconds.public static int truncateAndConvertToInt(long longValue)
longValue - long valuepublic static int[] truncateAndConvertToInt(long[] longArray)
longArray - log valuespublic static java.lang.String getPackageName(java.lang.Class<?> clazz)
clazz - the Class from which to get the package namepublic static boolean isRunningOnWindows()
true if currently running on Windows, false otherwise.public static int readFully(java.io.Reader reader,
char[] buf,
int length)
throws java.io.IOException
reader - Readerbuf - char array to read intolength - number of chars to readjava.io.IOException - if an error occurspublic static final int readBlock(java.io.InputStream i,
byte[] b,
ExceptionInterceptor exceptionInterceptor)
public static final int readBlock(java.io.InputStream i,
byte[] b,
int length,
ExceptionInterceptor exceptionInterceptor)
public static boolean isNullOrEmpty(java.util.List<?> list)