/** * Returns all the keys associated with this JavaScript Object. * Keys associated with the objects prototype are not returned. * * @return The keys associated with this JavaScript Object. */ public String[] getKeys() { v8.checkThread(); checkReleased(); return v8.getKeys(v8.getV8RuntimePtr(), objectHandle); }
/** * Associate NULL with the given key. * * @param key The key to associate NULL with. * * @return The receiver. */ public V8Object addNull(final String key) { v8.checkThread(); checkReleased(); v8.addNull(v8.getV8RuntimePtr(), objectHandle, key); return this; }
/** * Associate UNDEFINED with the given key. * * @param key The key to associate UNDEFINED with. * * @return The receiver. */ public V8Object addUndefined(final String key) { v8.checkThread(); checkReleased(); v8.addUndefined(v8.getV8RuntimePtr(), objectHandle, key); return this; }
/** * Adds a key value pair to the receiver where the value is a double. * * @param key The key to associate the value with. * @param value The value to add. * * @return The receiver. */ public V8Object add(final String key, final double value) { v8.checkThread(); checkReleased(); v8.add(v8.getV8RuntimePtr(), objectHandle, key, value); return this; }
/** * Adds a key value pair to the receiver where the value is an integer. * * @param key The key to associate the value with. * @param value The value to add. * * @return The receiver. */ public V8Object add(final String key, final int value) { v8.checkThread(); checkReleased(); v8.add(v8.getV8RuntimePtr(), objectHandle, key, value); return this; }
/** * Adds a key value pair to the receiver where the value is a boolean. * * @param key The key to associate the value with. * @param value The value to add. * * @return The receiver. */ public V8Object add(final String key, final boolean value) { v8.checkThread(); checkReleased(); v8.add(v8.getV8RuntimePtr(), objectHandle, key, value); return this; }
/** * Register a void Java method as a JavaScript function. When the JS Function is invoked * the Java method will be called. * * @param callback The JavaVoidCallback to call when the JSFunction is invoked. * @param jsFunctionName The name of the JSFunction. * * @return The receiver. */ public V8Object registerJavaMethod(final JavaVoidCallback callback, final String jsFunctionName) { v8.checkThread(); checkReleased(); v8.registerVoidCallback(callback, getHandle(), jsFunctionName); return this; }
/** * Register a Java method as a JavaScript function. When the JS Function is invoked * the Java method will be called. * * @param callback The JavaCallback to call when the JSFunction is invoked. * @param jsFunctionName The name of the JSFunction. * * @return The receiver. */ public V8Object registerJavaMethod(final JavaCallback callback, final String jsFunctionName) { v8.checkThread(); checkReleased(); v8.registerCallback(callback, getHandle(), jsFunctionName); return this; }
/** * Determine if a key/value pair with this key exists in * the Object. * * @param key The key to check * @return True if the key exists, false otherwise. */ public boolean contains(final String key) { v8.checkThread(); checkReleased(); checkKey(key); return v8.contains(v8.getV8RuntimePtr(), objectHandle, key); }
/** * Sets the prototype of the receiver. * * @param value The prototype to associate with this V8Object. * * @return The receiver. */ public V8Object setPrototype(final V8Object value) { v8.checkThread(); checkReleased(); v8.setPrototype(v8.getV8RuntimePtr(), objectHandle, value.getHandle()); return this; }
/** * Returns the type of the value associated with this Key, or * UNDEFINED if the key does not exist. Types are specified as * integer constants. The types are all defined in V8Value. * * @param key The key whose type to lookup. * * @return The Type of the value associated with this key */ public int getType(final String key) { v8.checkThread(); checkReleased(); checkKey(key); return v8.getType(v8.getV8RuntimePtr(), objectHandle, key); }
/** * Returns the value associated with this key. Values are Java Objects. * If the value is a primitive, its boxed type is returned. If the * value is a V8Value, it must be released. * * @param key The key whose value to return. * * @return The value associated with this key. */ public Object get(final String key) { v8.checkThread(); checkReleased(); checkKey(key); return v8.get(v8.getV8RuntimePtr(), V8_OBJECT, objectHandle, key); }
/** * Returns the double value associated with this key. If the value * associated with this key does not exist, or if it's not a double, then * V8ResultUndefined exception is thrown. * * @param key The key whose value to return. * * @return The double value associated with this key, or V8ResultUndefined * if the key does not exist or the value is not a double. */ public double getDouble(final String key) { v8.checkThread(); checkReleased(); checkKey(key); return v8.getDouble(v8.getV8RuntimePtr(), objectHandle, key); }
/** * Returns the integer value associated with this key. If the value * associated with this key does not exist, or if it's not an integer, then * V8ResultUndefined exception is thrown. * * @param key The key whose value to return. * * @return The integer value associated with this key, or V8ResultUndefined * if the key does not exist or the value is not an integer. */ public int getInteger(final String key) { v8.checkThread(); checkReleased(); checkKey(key); return v8.getInteger(v8.getV8RuntimePtr(), objectHandle, key); }
/** * Returns the boolean value associated with this key. If the value * associated with this key does not exist, or if it's not a boolean, then * V8ResultUndefined exception is thrown. * * @param key The key whose value to return. * * @return The boolean value associated with this key, or V8ResultUndefined * if the key does not exist or the value is not a boolean. */ public boolean getBoolean(final String key) { v8.checkThread(); checkReleased(); checkKey(key); return v8.getBoolean(v8.getV8RuntimePtr(), objectHandle, key); }
/** * Returns the String value associated with this key. If the value * associated with this key does not exist, or if it's not a String, then * V8ResultUndefined exception is thrown. * * @param key The key whose value to return. * * @return The String value associated with this key, or V8ResultUndefined * if the key does not exist or the value is not a String. */ public String getString(final String key) { v8.checkThread(); checkReleased(); checkKey(key); return v8.getString(v8.getV8RuntimePtr(), objectHandle, key); }
/** * Invokes a JavaScript function which does not return a result. * * @param name The name of the JS Function to call. * * @param parameters The parameters to pass to the function. Parameters must be released. */ public void executeVoidFunction(final String name, final V8Array parameters) { v8.checkThread(); checkReleased(); v8.checkRuntime(parameters); long parametersHandle = parameters == null ? 0 : parameters.getHandle(); v8.executeVoidFunction(v8.getV8RuntimePtr(), objectHandle, name, parametersHandle); }
/** * Invoke a JavaScript function and return the result as a Java Object. * * @param name The name of the JS Function to call. * * @param parameters The parameters to pass to the function. Parameters must be released. * * @return A Java Object representing the result of the function call. */ public Object executeFunction(final String name, final V8Array parameters) { v8.checkThread(); checkReleased(); v8.checkRuntime(parameters); long parametersHandle = parameters == null ? 0 : parameters.getHandle(); return v8.executeFunction(v8.getV8RuntimePtr(), UNKNOWN, objectHandle, name, parametersHandle); }
/** * Invoke a JavaScript function and return the result as a integer. If the * result is not an integer, or does not exist, then V8ResultUndefined is thrown. * * @param name The name of the JS Function to call. * * @param parameters The parameters to pass to the function. Parameters must be released. * * @return An integer representing the result of the function call or V8ResultUndefined * if the result is not an integer. */ public int executeIntegerFunction(final String name, final V8Array parameters) { v8.checkThread(); checkReleased(); v8.checkRuntime(parameters); long parametersHandle = parameters == null ? 0 : parameters.getHandle(); return v8.executeIntegerFunction(v8.getV8RuntimePtr(), getHandle(), name, parametersHandle); }
/** * Invoke a JavaScript function and return the result as a String. If the * result is not a String, or does not exist, then V8ResultUndefined is thrown. * * @param name The name of the JS Function to call. * * @param parameters The parameters to pass to the function. Parameters must be released. * * @return A String representing the result of the function call or V8ResultUndefined * if the result is not a String. */ public String executeStringFunction(final String name, final V8Array parameters) { v8.checkThread(); checkReleased(); v8.checkRuntime(parameters); long parametersHandle = parameters == null ? 0 : parameters.getHandle(); return v8.executeStringFunction(v8.getV8RuntimePtr(), getHandle(), name, parametersHandle); }