public class Kit
extends java.lang.Object
Constructor and Description |
---|
Kit() |
Modifier and Type | Method and Description |
---|---|
static java.lang.Object |
addListener(java.lang.Object bag,
java.lang.Object listener)
Add listener to bag of listeners.
|
static java.lang.Class<?> |
classOrNull(java.lang.ClassLoader loader,
java.lang.String className)
Attempt to load the class of the given name.
|
static java.lang.Class<?> |
classOrNull(java.lang.String className) |
static java.lang.RuntimeException |
codeBug()
Throws RuntimeException to indicate failed assertion.
|
static java.lang.RuntimeException |
codeBug(java.lang.String msg)
Throws RuntimeException to indicate failed assertion.
|
static java.lang.Object |
getListener(java.lang.Object bag,
int index)
Get listener at index position in bag or null if
index equals to number of listeners in bag.
|
static java.lang.RuntimeException |
initCause(java.lang.RuntimeException ex,
java.lang.Throwable cause)
If initCause methods exists in Throwable, call
ex.initCause(cause) or otherwise do nothing.
|
static java.lang.Object |
makeHashKeyFromPair(java.lang.Object key1,
java.lang.Object key2) |
static java.lang.String |
readReader(java.io.Reader r) |
static byte[] |
readStream(java.io.InputStream is,
int initialBufferCapacity) |
static java.lang.Object |
removeListener(java.lang.Object bag,
java.lang.Object listener)
Remove listener from bag of listeners.
|
static int |
xDigitToInt(int c,
int accumulator)
If character c is a hexadecimal digit, return
accumulator * 16 plus corresponding
number.
|
public static java.lang.Class<?> classOrNull(java.lang.String className)
public static java.lang.Class<?> classOrNull(java.lang.ClassLoader loader, java.lang.String className)
public static java.lang.RuntimeException initCause(java.lang.RuntimeException ex, java.lang.Throwable cause)
public static int xDigitToInt(int c, int accumulator)
public static java.lang.Object addListener(java.lang.Object bag, java.lang.Object listener)
Usage example:
private volatile Object changeListeners; public void addMyListener(PropertyChangeListener l) { synchronized (this) { changeListeners = Kit.addListener(changeListeners, l); } } public void removeTextListener(PropertyChangeListener l) { synchronized (this) { changeListeners = Kit.removeListener(changeListeners, l); } } public void fireChangeEvent(Object oldValue, Object newValue) { // Get immune local copy Object listeners = changeListeners; if (listeners != null) { PropertyChangeEvent e = new PropertyChangeEvent( this, "someProperty" oldValue, newValue); for (int i = 0; ; ++i) { Object l = Kit.getListener(listeners, i); if (l == null) break; ((PropertyChangeListener)l).propertyChange(e); } } }
listener
- Listener to add to bagbag
- Current collection of listeners.removeListener(Object bag, Object listener)
,
getListener(Object bag, int index)
public static java.lang.Object removeListener(java.lang.Object bag, java.lang.Object listener)
For usage example, see addListener(Object bag, Object listener)
.
listener
- Listener to remove from bagbag
- Current collection of listeners.addListener(Object bag, Object listener)
,
getListener(Object bag, int index)
public static java.lang.Object getListener(java.lang.Object bag, int index)
For usage example, see addListener(Object bag, Object listener)
.
bag
- Current collection of listeners.index
- Index of the listener to access.addListener(Object bag, Object listener)
,
removeListener(Object bag, Object listener)
public static java.lang.Object makeHashKeyFromPair(java.lang.Object key1, java.lang.Object key2)
public static java.lang.String readReader(java.io.Reader r) throws java.io.IOException
java.io.IOException
public static byte[] readStream(java.io.InputStream is, int initialBufferCapacity) throws java.io.IOException
java.io.IOException
public static java.lang.RuntimeException codeBug() throws java.lang.RuntimeException
java.lang.RuntimeException
public static java.lang.RuntimeException codeBug(java.lang.String msg) throws java.lang.RuntimeException
java.lang.RuntimeException