Top Description Constructors Methods
org.glassfish.hk2.utilities.general

public Class GeneralUtilities

extends Object
Class Inheritance
Imports
java.lang.reflect.Array, org.glassfish.hk2.utilities.general.internal.WeakHashClockImpl, .WeakHashLRUImpl

This class contains utilities useful for any code
Author
jwells

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static <K, V> WeakHashClock<K, V>

Returns:

A weak hash clock implementation
getWeakHashClock
(boolean
if true this will keep weak keyes, if false the keys will be hard and will not go away even if they do not exist anywhere else but this cache
isWeak
)

Creates a weak hash clock

public static <K> WeakHashLRU<K>

Returns:

A weak hash clock implementation
getWeakHashLRU
(boolean
if true this will keep weak keyes, if false the keys will be hard and will not go away even if they do not exist anywhere else but this cache
isWeak
)

Creates a weak hash clock

private static Class<?>
public static Class<?>

Returns:

The class if it could be loaded from the classloader, or null if it could not be found for any reason
loadClass
(ClassLoader
The non-null classloader to load the class from
cl
,
String
The fully qualified non-null name of the class to load
cName
)

Loads the class from the given classloader or returns null (does not throw).

public static String

Returns:

A string that has the bytes pretty-printed
prettyPrintBytes
(byte[]
A non-null string of bytes
bytes
)

Pretty prints a string of bytes in a hexadecimal format with byte number at the start of the line

public static boolean

Returns:

true if equal, false if not
safeEquals
(Object
A possibly null object to compare
a
,
Object
A possibly null object to compare
b
)

Returns true if a is equals to b, or both and and b are null.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

GeneralUtilitiesback to summary
public GeneralUtilities()

Method Detail

getWeakHashClockback to summary
public static <K, V> WeakHashClock<K, V> getWeakHashClock(boolean isWeak)

Creates a weak hash clock

Parameters
isWeak:boolean

if true this will keep weak keyes, if false the keys will be hard and will not go away even if they do not exist anywhere else but this cache

Returns:WeakHashClock<K, V>

A weak hash clock implementation

getWeakHashLRUback to summary
public static <K> WeakHashLRU<K> getWeakHashLRU(boolean isWeak)

Creates a weak hash clock

Parameters
isWeak:boolean

if true this will keep weak keyes, if false the keys will be hard and will not go away even if they do not exist anywhere else but this cache

Returns:WeakHashLRU<K>

A weak hash clock implementation

loadArrayClassback to summary
private static Class<?> loadArrayClass(ClassLoader cl, String aName)
loadClassback to summary
public static Class<?> loadClass(ClassLoader cl, String cName)

Loads the class from the given classloader or returns null (does not throw). Property handles array classes as well

Parameters
cl:ClassLoader

The non-null classloader to load the class from

cName:String

The fully qualified non-null name of the class to load

Returns:Class<?>

The class if it could be loaded from the classloader, or null if it could not be found for any reason

prettyPrintBytesback to summary
public static String prettyPrintBytes(byte[] bytes)

Pretty prints a string of bytes in a hexadecimal format with byte number at the start of the line

Parameters
bytes:byte[]

A non-null string of bytes

Returns:String

A string that has the bytes pretty-printed

safeEqualsback to summary
public static boolean safeEquals(Object a, Object b)

Returns true if a is equals to b, or both and and b are null. Is safe even if a or b is null. If a or b is null but the other is not null, this returns false

Parameters
a:Object

A possibly null object to compare

b:Object

A possibly null object to compare

Returns:boolean

true if equal, false if not