public class Kit extends Object
| Constructor and Description |
|---|
Kit() |
| Modifier and Type | Method and Description |
|---|---|
static Object |
addListener(Object bag,
Object listener)
Add listener to bag of listeners.
|
static Class<?> |
classOrNull(ClassLoader loader,
String className)
Attempt to load the class of the given name.
|
static Class<?> |
classOrNull(String className) |
static RuntimeException |
codeBug()
Throws RuntimeException to indicate failed assertion.
|
static RuntimeException |
codeBug(String msg)
Throws RuntimeException to indicate failed assertion.
|
static Object |
getListener(Object bag,
int index)
Get listener at index position in bag or null if index equals to number
of listeners in bag.
|
static Object |
makeHashKeyFromPair(Object key1,
Object key2) |
static String |
readReader(Reader reader) |
static byte[] |
readStream(InputStream is,
int initialBufferCapacity) |
static Object |
removeListener(Object bag,
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 Class<?> classOrNull(ClassLoader loader, String className)
public static int xDigitToInt(int c,
int accumulator)
c is a hexadecimal digit, return accumulator * 16 plus
corresponding number. Otherise return -1.public static Object addListener(Object bag, 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 Object removeListener(Object bag, 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 Object getListener(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 String readReader(Reader reader) throws IOException
IOExceptionpublic static byte[] readStream(InputStream is, int initialBufferCapacity) throws IOException
IOExceptionpublic static RuntimeException codeBug() throws RuntimeException
throw Kit.codeBug() if
plain Kit.codeBug() triggers unreachable code error.RuntimeExceptionpublic static RuntimeException codeBug(String msg) throws RuntimeException
throw Kit.codeBug() if
plain Kit.codeBug() triggers unreachable code error.RuntimeExceptionCopyright © 2023 HtmlUnit. All rights reserved.