public class Tools extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_BUFFER_SIZE |
static ResourceBundle |
EMPTY_BUNDLE |
static Enumeration |
EMPTY_ENUMERATION |
static Iterator |
EMPTY_ITERATOR |
static Logger |
log |
static String |
VMID
16 chars long VMID.
|
| Constructor and Description |
|---|
Tools() |
| Modifier and Type | Method and Description |
|---|---|
static <E> E[] |
appendTo(E[] array,
E o)
Append an object to an array of objects.
|
static String |
buildClassLoaderInfo(ClassLoader loader) |
static int |
computeStringHash(int hash,
String s) |
static boolean |
confirmTemporaryHash(String hash,
String value,
long time) |
static String |
dumpClassLoaderHierarchyInfo(ClassLoader loader) |
static void |
dumpClassLoaderHierarchyInfo(Writer writer,
ClassLoader loader) |
static <E> Enumeration<E> |
emptyEnumeration() |
static <E> Iterator<E> |
emptyIterator() |
static <T> MultiValuedPropertyMap<T> |
emptyMultiValuedPropertyMap() |
static byte[] |
fromHexString(String hex)
Returns a byte array converted from the hexadecimal format.
|
static String |
generateTemporaryHash(String value,
long time) |
static String |
getPackageOf(Class clazz) |
static String |
getShortNameOf(Class clazz) |
static String |
hashAndEncodeString(String text,
String algorithm,
String encoding)
Computes a hash with specified algorighm and returns the result as a string in hexadecimal format
|
static boolean |
isContainedIn(Object value,
Object[] array)
Determines if value is contained in array.
|
static <E> Iterator<E> |
iterator(E... objects)
Returns an iterator over the array elements.
|
static <E> Iterator<E> |
iterator(E o)
Returns a singleton iterator.
|
static <E> Iterator<E> |
iterator(E[] objects,
int from,
int to)
Returns an iterator over the array elements within the specified range.
|
static byte[] |
md5(String text)
Computes an md5 hash of a string.
|
static String |
md5AsHexString(String text)
Computes an md5 hash and returns the result as a string in hexadecimal format.
|
static <T> T |
safeCast(Object value,
Class<T> type)
Attempt to cast the value argument to the provided type argument.
|
static boolean |
safeEquals(Object o1,
Object o2)
Return true if o1 is null and o2 is null o1 is not null and the invocation of
equals(Object o) on o1 wit o2 as argument returns true |
static Object[] |
toArray(Iterator i)
Deprecated.
|
static <E> Enumeration<E> |
toEnumeration(E o) |
static <E> Enumeration<E> |
toEnumeration(E[] objects) |
static <E> Enumeration<E> |
toEnumeration(Iterator<E> iterator) |
static String |
toHexString(byte[] bytes)
Returns a string in the hexadecimal format.
|
static <E> List<E> |
toList(E... objects) |
static <E> List<E> |
toList(Enumeration<E> e) |
static <E> List<E> |
toList(Iterator<E> iterator) |
static <E> Set<E> |
toSet(E... objects) |
static <E> Set<E> |
toSet(Enumeration<E> e) |
static <E> Set<E> |
toSet(Iterator<E> iterator)
Transforms an iterator into an unordered Set
|
static <E> Set<E> |
toSet(Iterator<E> iterator,
boolean preserveOrder)
Transforms an iterator into a Set
|
public static final int DEFAULT_BUFFER_SIZE
public static final Logger log
public static final String VMID
public static final Enumeration EMPTY_ENUMERATION
public static final Iterator EMPTY_ITERATOR
public static final ResourceBundle EMPTY_BUNDLE
public static <E> Enumeration<E> emptyEnumeration()
public static <E> Iterator<E> emptyIterator()
public static <E> Enumeration<E> toEnumeration(Iterator<E> iterator)
public static <E> Enumeration<E> toEnumeration(E[] objects)
public static <E> Enumeration<E> toEnumeration(E o)
public static <E> Set<E> toSet(Enumeration<E> e)
public static <E> Set<E> toSet(E... objects)
public static <E> Set<E> toSet(Iterator<E> iterator)
iterator - The iterator to transformpublic static <E> Set<E> toSet(Iterator<E> iterator, boolean preserveOrder)
iterator - The iterator to transformpreserveOrder - true if the set must respect the ordering of the iteratorpublic static <E> List<E> toList(Enumeration<E> e)
public static <E> List<E> toList(E... objects)
@Deprecated public static Object[] toArray(Iterator i)
i - public static <E> Iterator<E> iterator(E o)
o - the singleton objectpublic static <E> Iterator<E> iterator(E... objects) throws IllegalArgumentException
objects - the array containing the objects to iterate onIllegalArgumentException - if the object array is null or the specified range is not validpublic static <E> Iterator<E> iterator(E[] objects, int from, int to) throws IllegalArgumentException
objects - the array containing the objects to iterate onfrom - the inclusive start indexto - the exclusive stop indexIllegalArgumentException - if the object array is null or the specified range is not valid or if the range
is not validpublic static int computeStringHash(int hash,
String s)
public static byte[] md5(String text)
text - the hashed stringNullPointerException - if text is nullpublic static String md5AsHexString(String text)
text - the hashed stringNullPointerException - if text is nullpublic static String hashAndEncodeString(String text, String algorithm, String encoding) throws NoSuchAlgorithmException
text - algorithm - encoding - NoSuchAlgorithmExceptionpublic static String toHexString(byte[] bytes)
bytes - the converted bytesIllegalArgumentException - if the byte array is nullpublic static byte[] fromHexString(String hex)
hex - the string to convertIllegalArgumentException - if the string is null or does not have the good formatpublic static boolean confirmTemporaryHash(String hash, String value, long time)
public static String buildClassLoaderInfo(ClassLoader loader)
public static String dumpClassLoaderHierarchyInfo(ClassLoader loader)
public static void dumpClassLoaderHierarchyInfo(Writer writer, ClassLoader loader)
public static <E> E[] appendTo(E[] array,
E o)
throws IllegalArgumentException,
ClassCastException
array - the array to augmento - the object to appendIllegalArgumentException - if the array is nullClassCastException - if the appended object class prevents it from being added to the arraypublic static boolean safeEquals(Object o1, Object o2)
equals(Object o) on o1 wit o2 as argument returns trueo1 - the first argumento2 - the second argumentpublic static boolean isContainedIn(Object value, Object[] array)
value - array - public static <T> T safeCast(Object value, Class<T> type)
value - the value to casttype - the type to downcastpublic static <T> MultiValuedPropertyMap<T> emptyMultiValuedPropertyMap()
Copyright © 2025 JBoss by Red Hat. All Rights Reserved.