| java.lang.Object org.mozilla.javascript.Kit
Kit | public class Kit (Code) | | Collection of utilities
|
Method Summary | |
public static Object | addListener(Object bag, Object listener) Add listener to bag of listeners.
The function does not modify bag and return a new collection
containing listener and all listeners from bag.
Bag without listeners always represented as the null value.
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);
}
}
}
Parameters: listener - Listener to add to bag Parameters: bag - Current collection of listeners. | public static Class | classOrNull(String className) | public static Class | classOrNull(ClassLoader loader, String className) | public static RuntimeException | codeBug() Throws RuntimeException to indicate failed assertion. | public 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.
For usage example, see
Kit.addListener(Object bag,Object listener) .
Parameters: bag - Current collection of listeners. Parameters: index - Index of the listener to access. | public static RuntimeException | initCause(RuntimeException ex, Throwable cause) If initCause methods exists in Throwable, call
ex.initCause(cause) or otherwise do nothing. | static Object | initHash(Hashtable h, Object key, Object initialValue) | public static Object | makeHashKeyFromPair(Object key1, Object key2) | static Object | newInstanceOrNull(Class cl) | public static String | readReader(Reader r) | public static byte[] | readStream(InputStream is, int initialBufferCapacity) | public static Object | removeListener(Object bag, Object listener) Remove listener from bag of listeners.
The function does not modify bag and return a new collection
containing all listeners from bag except listener.
If bag does not contain listener, the function returns
bag.
For usage example, see
Kit.addListener(Object bag,Object listener) .
Parameters: listener - Listener to remove from bag Parameters: bag - Current collection of listeners. | public static String[] | semicolonSplit(String s) Split string into array of strings using semicolon as string terminator
(; after the last string is required). | static boolean | testIfCanLoadRhinoClasses(ClassLoader loader) Check that testClass is accesible from the given loader. | public static int | xDigitToInt(int c, int accumulator) If character c is a hexadecimal digit, return
accumulator * 16 plus corresponding
number. |
addListener | public static Object addListener(Object bag, Object listener)(Code) | | Add listener to bag of listeners.
The function does not modify bag and return a new collection
containing listener and all listeners from bag.
Bag without listeners always represented as the null value.
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);
}
}
}
Parameters: listener - Listener to add to bag Parameters: bag - Current collection of listeners. A new bag containing all listeners from bag andlistener. See Also: Kit.removeListener(Object bag,Object listener) See Also: Kit.getListener(Object bag,int index) |
codeBug | public static RuntimeException codeBug() throws RuntimeException(Code) | | Throws RuntimeException to indicate failed assertion.
The function never returns and its return type is RuntimeException
only to be able to write throw Kit.codeBug() if plain
Kit.codeBug() triggers unreachable code error.
|
semicolonSplit | public static String[] semicolonSplit(String s)(Code) | | Split string into array of strings using semicolon as string terminator
(; after the last string is required).
|
testIfCanLoadRhinoClasses | static boolean testIfCanLoadRhinoClasses(ClassLoader loader)(Code) | | Check that testClass is accesible from the given loader.
|
xDigitToInt | public static int xDigitToInt(int c, int accumulator)(Code) | | If character c is a hexadecimal digit, return
accumulator * 16 plus corresponding
number. Otherise return -1.
|
|
|