Package org.mozilla.javascript
Class Kit
- java.lang.Object
- 
- org.mozilla.javascript.Kit
 
- 
 public class Kit extends java.lang.ObjectCollection of utilities
- 
- 
Constructor SummaryConstructors Constructor Description Kit()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.ObjectaddListener(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.RuntimeExceptioncodeBug()Throws RuntimeException to indicate failed assertion.static java.lang.RuntimeExceptioncodeBug(java.lang.String msg)Throws RuntimeException to indicate failed assertion.static java.lang.ObjectgetListener(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.ObjectmakeHashKeyFromPair(java.lang.Object key1, java.lang.Object key2)static java.lang.StringreadReader(java.io.Reader reader)static byte[]readStream(java.io.InputStream is, int initialBufferCapacity)static java.lang.ObjectremoveListener(java.lang.Object bag, java.lang.Object listener)Remove listener from bag of listeners.static intxDigitToInt(int c, int accumulator)If charactercis a hexadecimal digit, returnaccumulator* 16 plus corresponding number.
 
- 
- 
- 
Method Detail- 
classOrNullpublic static java.lang.Class<?> classOrNull(java.lang.String className) 
 - 
classOrNullpublic static java.lang.Class<?> classOrNull(java.lang.ClassLoader loader, java.lang.String className)Attempt to load the class of the given name. Note that the type parameter isn't checked.
 - 
xDigitToIntpublic static int xDigitToInt(int c, int accumulator)If charactercis a hexadecimal digit, returnaccumulator* 16 plus corresponding number. Otherise return -1.
 - 
addListenerpublic static java.lang.Object addListener(java.lang.Object bag, java.lang.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
- bag- Current collection of listeners.
- Returns:
- A new bag containing all listeners from bag and listener.
- See Also:
- removeListener(Object bag, Object listener),- getListener(Object bag, int index)
 
 - 
removeListenerpublic static java.lang.Object removeListener(java.lang.Object bag, java.lang.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 addListener(Object bag, Object listener).- Parameters:
- listener- Listener to remove from bag
- bag- Current collection of listeners.
- Returns:
- A new bag containing all listeners from bag except listener.
- See Also:
- addListener(Object bag, Object listener),- getListener(Object bag, int index)
 
 - 
getListenerpublic 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.For usage example, see addListener(Object bag, Object listener).- Parameters:
- bag- Current collection of listeners.
- index- Index of the listener to access.
- Returns:
- Listener at the given index or null.
- See Also:
- addListener(Object bag, Object listener),- removeListener(Object bag, Object listener)
 
 - 
makeHashKeyFromPairpublic static java.lang.Object makeHashKeyFromPair(java.lang.Object key1, java.lang.Object key2)
 - 
readReaderpublic static java.lang.String readReader(java.io.Reader reader) throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
readStreampublic static byte[] readStream(java.io.InputStream is, int initialBufferCapacity) throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
codeBugpublic static java.lang.RuntimeException codeBug() throws java.lang.RuntimeExceptionThrows RuntimeException to indicate failed assertion. The function never returns and its return type is RuntimeException only to be able to writethrow Kit.codeBug()if plainKit.codeBug()triggers unreachable code error.- Throws:
- java.lang.RuntimeException
 
 - 
codeBugpublic static java.lang.RuntimeException codeBug(java.lang.String msg) throws java.lang.RuntimeExceptionThrows RuntimeException to indicate failed assertion. The function never returns and its return type is RuntimeException only to be able to writethrow Kit.codeBug()if plainKit.codeBug()triggers unreachable code error.- Throws:
- java.lang.RuntimeException
 
 
- 
 
-