/** * Returns the type of element at this given index. * * @param index The index at which to lookup the type of. * * @return The type of the element at the index. */ public int getType(final int index) { v8.checkThread(); checkReleased(); return v8.getType(v8.getV8RuntimePtr(), getHandle(), index); }
/** * Gets the type of the array. Returns a 'type' if all the elements in the array * have the same type, otherwise UNDEFINED is returned. * * @return The type of all the elements of the array, or UNDEFINED if they * are not all the same type. */ public int getType() { v8.checkThread(); checkReleased(); return v8.getArrayType(v8.getV8RuntimePtr(), getHandle()); }
/** * Returns the length of this array. * * @return The length of the array. */ public int length() { v8.checkThread(); checkReleased(); return v8.arrayGetSize(v8.getV8RuntimePtr(), getHandle()); }
/** * Pushes null to the next available spot in the Array. In * particular, this[length] = null; * * @return The receiver. */ public V8Array pushNull() { v8.checkThread(); checkReleased(); v8.addArrayNullItem(v8.getV8RuntimePtr(), getHandle()); return this; }
/** * Pushes undefined to the next available spot in the Array. In * particular, this[length] = undefined; * * @return The receiver. */ public V8Array pushUndefined() { v8.checkThread(); checkReleased(); v8.addArrayUndefinedItem(v8.getV8RuntimePtr(), getHandle()); return this; }
/** * Returns the byte value associated at this index. If the value at * this index does not exist, or cannot be cast to a byte, then * V8ResultUndefined exception is thrown. * * @param index The index whose value to return * @return The byte value at this index or V8ResultUndefined * if the index does not exist or the value cannot be cast to a byte. */ public byte getByte(final int index) { v8.checkThread(); checkReleased(); return v8.arrayGetByte(v8.getV8RuntimePtr(), getHandle(), index); }
/** * Pushes an integer value to the next available spot in the Array. In * particular, this[length] = value; * * @param value The value to push to the array. * * @return The receiver. */ public V8Array push(final int value) { v8.checkThread(); checkReleased(); v8.addArrayIntItem(v8.getV8RuntimePtr(), getHandle(), value); return this; }
/** * Pushes a boolean value to the next available spot in the Array. In * particular, this[length] = value; * * @param value The value to push to the array. * * @return The receiver. */ public V8Array push(final boolean value) { v8.checkThread(); checkReleased(); v8.addArrayBooleanItem(v8.getV8RuntimePtr(), getHandle(), value); return this; }
/** * Pushes a double value to the next available spot in the Array. In * particular, this[length] = value; * * @param value The value to push to the array. * * @return The receiver. */ public V8Array push(final double value) { v8.checkThread(); checkReleased(); v8.addArrayDoubleItem(v8.getV8RuntimePtr(), getHandle(), value); return this; }
/** * Returns the integer value associated at this index. If the value * at this index does not exist, or if it's not an integer, then * V8ResultUndefined exception is thrown. * * @param index The index whose value to return. * * @return The integer value at this index or V8ResultUndefined * if the index does not exist or the value is not an integer. */ public int getInteger(final int index) { v8.checkThread(); checkReleased(); return v8.arrayGetInteger(v8.getV8RuntimePtr(), getHandle(), index); }
/** * Returns the double value associated at this index. If the value * at this index does not exist, or if it's not a double, then * V8ResultUndefined exception is thrown. * * @param index The index whose value to return. * * @return The double value at this index or V8ResultUndefined * if the index does not exist or the value is not a double. */ public double getDouble(final int index) { v8.checkThread(); checkReleased(); return v8.arrayGetDouble(v8.getV8RuntimePtr(), getHandle(), index); }
/** * Returns the String value associated at this index. If the value * at this index does not exist, or if it's not a String, then * V8ResultUndefined exception is thrown. * * @param index The index whose value to return. * * @return The String value at this index or V8ResultUndefined * if the index does not exist or the value is not a String. */ public String getString(final int index) { v8.checkThread(); checkReleased(); return v8.arrayGetString(v8.getV8RuntimePtr(), getHandle(), index); }
/** * Returns the boolean value associated at this index. If the value * at this index does not exist, or if it's not a boolean, then * V8ResultUndefined exception is thrown. * * @param index The index whose value to return. * * @return The boolean value at this index or V8ResultUndefined * if the index does not exist or the value is not a boolean. */ public boolean getBoolean(final int index) { v8.checkThread(); checkReleased(); return v8.arrayGetBoolean(v8.getV8RuntimePtr(), getHandle(), index); }
/** * Returns the booleans contained in a subset of a V8Array. If the subset * contains elements other than booleans, then a V8ResultUndefined exception * is thrown. Furthermore, if the subset is not entirely contained within the array, * then V8ResultUndefined exception is also thrown. * * @param index The starting index. * @param length The length. * * @return The booleans contained in the subset of the array, or V8ResultUndefined * exception. */ public boolean[] getBooleans(final int index, final int length) { v8.checkThread(); checkReleased(); return v8.arrayGetBooleans(v8.getV8RuntimePtr(), getHandle(), index, length); }
/** * Gets the type of a subset of the array. The subset is specified by a start index * and a length. UNDEFINED is returned if all the elements in the subset are not * of the same type. * * @param index The start index. * @param length The length. * * @return The type of the subset of the array or UNDEFINED if the subset is not * all the same type. */ public int getType(final int index, final int length) { v8.checkThread(); checkReleased(); return v8.getType(v8.getV8RuntimePtr(), getHandle(), index, length); }
/** * Returns the integers contained in a subset of a V8Array. If the subset * contains elements other than integers, then a V8ResultUndefined exception * is thrown. Furthermore, if the subset is not entirely contained within the array, * then V8ResultUndefined exception is also thrown. * * @param index The starting index. * @param length The length. * * @return The integers contained in the subset of the array, or V8ResultUndefined * exception. */ public int[] getIntegers(final int index, final int length) { v8.checkThread(); checkReleased(); return v8.arrayGetIntegers(v8.getV8RuntimePtr(), getHandle(), index, length); }
/** * Returns the Strings contained in a subset of a V8Array. If the subset * contains elements other than Strings, then a V8ResultUndefined exception * is thrown. Furthermore, if the subset is not entirely contained within the array, * then V8ResultUndefined exception is also thrown. * * @param index The starting index. * @param length The length. * * @return The Strings contained in the subset of the array, or V8ResultUndefined * exception. */ public String[] getStrings(final int index, final int length) { v8.checkThread(); checkReleased(); return v8.arrayGetStrings(v8.getV8RuntimePtr(), getHandle(), index, length); }
/** * Returns the bytes contained in a subset of a V8Array. If the subset * contains elements that cannot be cast to bytes, then a V8ResultUndefined exception * is thrown. Furthermore, if the subset is not entirely contained within the array, * then V8ResultUndefined exception is also thrown. * * @param index The starting index. * @param length The length. * * @return The bytes contained in the subset of the array, or V8ResultUndefined * exception. */ public byte[] getBytes(final int index, final int length) { v8.checkThread(); checkReleased(); return v8.arrayGetBytes(v8.getV8RuntimePtr(), getHandle(), index, length); }
/** * 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); }