| Modifier and Type | Class and Description |
|---|---|
| public static interface | Utils.
The utility methods will try to use the provided class factories to convert binary name of class to Class object. |
| Modifier and Type | Field and Description |
|---|---|
| public static final byte[] | EMPTY_BYTES
An 0-size byte array. |
| public static final int[] | EMPTY_INT_ARRAY
An 0-size int array. |
| private static final HashMap |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static Object | Returns: the return value from this callthe instance on which the call is done instance, String a string with the method name methodName, Object... the method parameters params)Calls an instance method via reflection. |
| private static Object | |
| public static Object | Returns: the return value from this calla string with the entire class and method name, eg.
"java.lang.System.gc" classAndMethod, Object... the method parameters params)Calls a static method via reflection. |
| public static byte[] | Returns: a new byte arraythe byte array (may not be null) b)Create a new byte array and copy all the data. |
| public static synchronized void | |
| public static boolean | Returns: true if both byte arrays contain the same bytesthe first array test, byte[] the second array good)Compare two byte arrays. |
| public static byte[] | Returns: the target array or a new one if the target array was too smallthe source array source, byte[] the target array target)Copy the contents of the source array to the target array. |
| public static byte[] | Returns: the byte arraysource array bytes, int the number of bytes in the new array len)Creates a copy of array of bytes with the new size. |
| public static ThreadPoolExecutor | |
| public static ThreadPoolExecutor | |
| public static long | Returns: time in nanoseconds, never equal to 0Returns the current value of the high-resolution time source. |
| public static long | Returns: time in nanoseconds, never equal to 0additional offset in milliseconds ms)Returns the current value of the high-resolution time source plus the specified offset. |
| public static void | flushExecutor(ThreadPoolExecutor
to flush executor)Makes sure that all currently submitted tasks are processed before this method returns. |
| public static int | Returns: the hash codethe byte array value)Calculate the hash code of the given byte array. |
| public static long | |
| public static long | |
| public static long | |
| public static long | |
| public static long | |
| public static Class | Returns: the non-primitive class (for example: java.lang.Integer)the class (for example: int) clazz)Convert primitive class names to java.lang.* class names. |
| public static String | Returns: the valuethe key key, String the default value defaultValue)Get the system property. |
| public static int | Returns: the valuethe key key, int the default value defaultValue)Get the system property. |
| public static boolean | Returns: the valuethe key key, boolean the default value defaultValue)Get the system property. |
| public static byte[] | Returns: the resource datathe name of the resource name)Get a resource from the resource map. |
| public static int | Returns: the indexthe byte array bytes, byte[] the pattern pattern, int the start index from where to search start)Calculate the index of the first occurrence of the pattern in the byte array, starting with the given index. |
| private static byte[] | |
| private static int | |
| public static long | Returns: time in nanoseconds, never equal to 0time in nanoseconds nanoTime, int additional offset in milliseconds ms)Returns the current value of the high-resolution time source plus the specified offset. |
| public static byte[] | Returns: the byte arraythe number of bytes requested len)Create an array of bytes with the given size. |
| public static Object | Returns: the newly created objecta string with the entire class, eg. "java.lang.Integer" className, Object... the constructor parameters params)Creates a new instance. |
| public static < the type T> ArrayList | |
| public static boolean | Returns: parsed or default valuestring to parse value, boolean value to return if value is null or on parsing error defaultValue, boolean throw exception on parsing error or return default value instead throwException)Parses the specified string to boolean value. |
| private static < the type of elements X> void | partialQuickSort(X[]
the array to sort array, int the lower index with data, inclusive low, int the higher index with data, inclusive, high, Comparator<? super X> high > lowthe comparator comp, int the start index of requested region, inclusive start, int the end index of requested region, inclusive, end)end >= startPartial quick sort. |
| public static int | Returns: the scaled valuethe value to scale value)Scale the value with the available memory. |
| public static void | |
| public static < the type of elements X> void | sortTopN(X[]
the array. array, int the start index, inclusive fromInclusive, int the end index, exclusive toExclusive, Comparator<? super X> the comparator. comp)Find the top limit values using given comparator and place them as in a full array sort, in descending order. |
| EMPTY_BYTES | back to summary |
|---|---|
| public static final byte[] EMPTY_BYTES An 0-size byte array. | |
| EMPTY_INT_ARRAY | back to summary |
|---|---|
| public static final int[] EMPTY_INT_ARRAY An 0-size int array. | |
| RESOURCES | back to summary |
|---|---|
| private static final HashMap<String, byte[]> RESOURCES | |
| Utils | back to summary |
|---|---|
| private Utils() | |
| callMethod | back to summary |
|---|---|
| public static Object callMethod(Object instance, String methodName, Object... params) throws Exception Calls an instance method via reflection. This will try to use the method where the most parameter classes match exactly (this algorithm is simpler than the one in the Java specification, but works well for most cases). | |
| callMethod | back to summary |
|---|---|
| private static Object callMethod(Object instance, Class<?> clazz, String methodName, Object... params) throws Exception | |
| callStaticMethod | back to summary |
|---|---|
| public static Object callStaticMethod(String classAndMethod, Object... params) throws Exception Calls a static method via reflection. This will try to use the method where the most parameter classes match exactly (this algorithm is simpler than the one in the Java specification, but works well for most cases). | |
| cloneByteArray | back to summary |
|---|---|
| public static byte[] cloneByteArray(byte[] b) Create a new byte array and copy all the data. If the size of the byte array is zero, the same array is returned.
| |
| collectGarbage | back to summary |
|---|---|
| public static synchronized void collectGarbage() Run Java memory garbage collection. | |
| compareSecure | back to summary |
|---|---|
| public static boolean compareSecure(byte[] test, byte[] good) Compare two byte arrays. This method will always loop over all bytes and doesn't use conditional operations in the loop to make sure an attacker can not use a timing attack when trying out passwords.
| |
| copy | back to summary |
|---|---|
| public static byte[] copy(byte[] source, byte[] target) Copy the contents of the source array to the target array. If the size if the target array is too small, a larger array is created.
| |
| copyBytes | back to summary |
|---|---|
| public static byte[] copyBytes(byte[] bytes, int len) Creates a copy of array of bytes with the new size. If this is not possible because not enough memory is available, an OutOfMemoryError with the requested size in the message is thrown. This method should be used if the size of the array is user defined, or stored in a file, so wrong size data can be distinguished from regular out-of-memory.
| |
| createSingleThreadExecutor | back to summary |
|---|---|
| public static ThreadPoolExecutor createSingleThreadExecutor(String threadName) | |
| createSingleThreadExecutor | back to summary |
|---|---|
| public static ThreadPoolExecutor createSingleThreadExecutor(String threadName, BlockingQueue<Runnable> workQueue) | |
| currentNanoTime | back to summary |
|---|---|
| public static long currentNanoTime() Returns the current value of the high-resolution time source.
| |
| currentNanoTimePlusMillis | back to summary |
|---|---|
| public static long currentNanoTimePlusMillis(int ms) Returns the current value of the high-resolution time source plus the specified offset.
| |
| flushExecutor | back to summary |
|---|---|
| public static void flushExecutor(ThreadPoolExecutor executor) Makes sure that all currently submitted tasks are processed before this method returns. It is assumed that there will be no new submissions to this executor, once this method has started. It is assumed that executor is single-threaded, and flush is done by submitting a dummy task and waiting for its completion.
| |
| getByteArrayHash | back to summary |
|---|---|
| public static int getByteArrayHash(byte[] value) Calculate the hash code of the given byte array.
| |
| getGarbageCollectionCount | back to summary |
|---|---|
| public static long getGarbageCollectionCount() | |
| getGarbageCollectionTime | back to summary |
|---|---|
| public static long getGarbageCollectionTime() | |
| getMemoryFree | back to summary |
|---|---|
| public static long getMemoryFree() Get the free memory in KB. This method possibly calls System.gc().
| |
| getMemoryMax | back to summary |
|---|---|
| public static long getMemoryMax() Get the maximum memory in KB.
| |
| getMemoryUsed | back to summary |
|---|---|
| public static long getMemoryUsed() Get the used memory in KB. This method possibly calls System.gc().
| |
| getNonPrimitiveClass | back to summary |
|---|---|
| public static Class Convert primitive class names to java.lang.* class names. | |
| getProperty | back to summary |
|---|---|
| public static String getProperty(String key, String defaultValue) Get the system property. If the system property is not set, or if a security exception occurs, the default value is returned. | |
| getProperty | back to summary |
|---|---|
| public static int getProperty(String key, int defaultValue) Get the system property. If the system property is not set, or if a security exception occurs, the default value is returned.
| |
| getProperty | back to summary |
|---|---|
| public static boolean getProperty(String key, boolean defaultValue) Get the system property. If the system property is not set, or if a security exception occurs, the default value is returned.
| |
| getResource | back to summary |
|---|---|
| public static byte[] getResource(String name) throws IOException Get a resource from the resource map.
| |
| indexOf | back to summary |
|---|---|
| public static int indexOf(byte[] bytes, byte[] pattern, int start) Calculate the index of the first occurrence of the pattern in the byte array, starting with the given index. This methods returns -1 if the pattern has not been found, and the start position if the pattern is empty.
| |
| loadResource | back to summary |
|---|---|
| private static byte[] loadResource(String name) throws IOException | |
| match | back to summary |
|---|---|
| private static int match(Class<?>[] params, Object[] values) | |
| nanoTimePlusMillis | back to summary |
|---|---|
| public static long nanoTimePlusMillis(long nanoTime, int ms) Returns the current value of the high-resolution time source plus the specified offset.
| |
| newBytes | back to summary |
|---|---|
| public static byte[] newBytes(int len) Create an array of bytes with the given size. If this is not possible because not enough memory is available, an OutOfMemoryError with the requested size in the message is thrown. This method should be used if the size of the array is user defined, or stored in a file, so wrong size data can be distinguished from regular out-of-memory.
| |
| newInstance | back to summary |
|---|---|
| public static Object newInstance(String className, Object... params) throws Exception Creates a new instance. This will try to use the constructor where the most parameter classes match exactly (this algorithm is simpler than the one in the Java specification, but works well for most cases). | |
| newSmallArrayList | back to summary |
|---|---|
| public static <T> ArrayList Create a new ArrayList with an initial capacity of 4.
| |
| parseBoolean | back to summary |
|---|---|
| public static boolean parseBoolean(String value, boolean defaultValue, boolean throwException) Parses the specified string to boolean value.
| |
| partialQuickSort | back to summary |
|---|---|
| private static <X> void partialQuickSort(X[] array, int low, int high, Comparator<? super X> comp, int start, int end) Partial quick sort.
Works with elements from
Moves smallest elements to
| |
| scaleForAvailableMemory | back to summary |
|---|---|
| public static int scaleForAvailableMemory(int value) Scale the value with the available memory. If 1 GB of RAM is available, the value is returned, if 2 GB are available, then twice the value, and so on.
| |
| shutdownExecutor | back to summary |
|---|---|
| public static void shutdownExecutor(ThreadPoolExecutor executor) | |
| sortTopN | back to summary |
|---|---|
| public static <X> void sortTopN(X[] array, int fromInclusive, int toExclusive, Comparator<? super X> comp) Find the top limit values using given comparator and place them as in a full array sort, in descending order.
| |
| Modifier and Type | Method and Description |
|---|---|
| public Class | |
| public boolean |
| loadClass | back to summary |
|---|---|
| public Class Load the class.
| |
| match | back to summary |
|---|---|
| public boolean match(String name) Check whether the factory can return the named class.
| |