< prev index next >

src/jdk.jsobject/share/classes/netscape/javascript/JSObject.java

Print this page
rev 14722 : imported patch 8153362


 133      * "this[index] = value" in JavaScript.
 134      *
 135      * @param index The index of the array to be accessed.
 136      * @param value The value to set
 137      * @throws JSException when an error is reported from the browser or
 138      * JavaScript engine.
 139      */
 140     public abstract void setSlot(int index, Object value) throws JSException;
 141 
 142     /**
 143      * Returns a JSObject for the window containing the given applet. This
 144      * method only works when the Java code is running in a browser as an
 145      * applet. The object returned may be used to access the HTML DOM directly.
 146      *
 147      * @param applet The applet.
 148      * @return JSObject representing the window containing the given applet or
 149      * {@code null} if we are not connected to a browser.
 150      * @throws JSException when an error is reported from the browser or
 151      * JavaScript engine or if applet is {@code null}
 152      */

 153     public static JSObject getWindow(Applet applet) throws JSException {
 154         return ProviderLoader.callGetWindow(applet);
 155     }
 156 
 157     private static class ProviderLoader {
 158         private static final JSObjectProvider provider;
 159 
 160         static {
 161             provider = AccessController.doPrivileged(
 162                 new PrivilegedAction<>() {
 163                     @Override
 164                     public JSObjectProvider run() {
 165                         Iterator<JSObjectProvider> providers =
 166                             ServiceLoader.loadInstalled(JSObjectProvider.class).iterator();
 167                         if (providers.hasNext()) {
 168                             return providers.next();
 169                         }
 170                         return null;
 171                     }
 172                 }


 133      * "this[index] = value" in JavaScript.
 134      *
 135      * @param index The index of the array to be accessed.
 136      * @param value The value to set
 137      * @throws JSException when an error is reported from the browser or
 138      * JavaScript engine.
 139      */
 140     public abstract void setSlot(int index, Object value) throws JSException;
 141 
 142     /**
 143      * Returns a JSObject for the window containing the given applet. This
 144      * method only works when the Java code is running in a browser as an
 145      * applet. The object returned may be used to access the HTML DOM directly.
 146      *
 147      * @param applet The applet.
 148      * @return JSObject representing the window containing the given applet or
 149      * {@code null} if we are not connected to a browser.
 150      * @throws JSException when an error is reported from the browser or
 151      * JavaScript engine or if applet is {@code null}
 152      */
 153     @SuppressWarnings("unexportedinapi")
 154     public static JSObject getWindow(Applet applet) throws JSException {
 155         return ProviderLoader.callGetWindow(applet);
 156     }
 157 
 158     private static class ProviderLoader {
 159         private static final JSObjectProvider provider;
 160 
 161         static {
 162             provider = AccessController.doPrivileged(
 163                 new PrivilegedAction<>() {
 164                     @Override
 165                     public JSObjectProvider run() {
 166                         Iterator<JSObjectProvider> providers =
 167                             ServiceLoader.loadInstalled(JSObjectProvider.class).iterator();
 168                         if (providers.hasNext()) {
 169                             return providers.next();
 170                         }
 171                         return null;
 172                     }
 173                 }
< prev index next >