public class V8Scope extends java.lang.Object implements IV8Creatable, IJavetClosable
Usage 1 without V8 runtime
try (V8Scope v8Scope = new V8Scope()) {
V8ValueObject v8ValueObject = v8Scope.add(v8Runtime.createV8ValueObject());
// v8ValueObject will be closed automatically if there is an exception thrown.
v8Scope.setEscapable();
// v8ValueObject will not be closed.
return v8ValueObject;
}
Usage 2 with V8 runtime
try (V8Scope v8Scope = v8Runtime.getV8Scope()) {
V8ValueObject v8ValueObject = v8Scope.createV8ValueObject();
// v8ValueObject will be closed automatically if there is an exception thrown.
v8Scope.setEscapable();
// v8ValueObject will not be closed.
return v8ValueObject;
}
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
closed
The Closed.
|
protected static java.lang.String |
ERROR_MESSAGE_V8_RUNTIME_CANNOT_BE_EMPTY
The constant ERROR_MESSAGE_V8_RUNTIME_CANNOT_BE_EMPTY.
|
protected boolean |
escapable
The Escapable.
|
protected V8Runtime |
v8Runtime
The V8 runtime.
|
protected java.util.List<V8Value> |
values
The Values.
|
| Constructor and Description |
|---|
V8Scope()
Instantiates a new V8 scope.
|
| Modifier and Type | Method and Description |
|---|---|
<T extends V8Value> |
add(T value)
Add a value.
|
void |
close() |
V8Module |
createV8Module(java.lang.String moduleName,
IV8ValueObject iV8ValueObject)
Create a V8 synthetic module.
|
V8ValueArray |
createV8ValueArray()
Create V8 value array.
|
V8ValueArrayBuffer |
createV8ValueArrayBuffer(java.nio.ByteBuffer byteBuffer)
Create V8 value array buffer from a native byte buffer.
|
V8ValueArrayBuffer |
createV8ValueArrayBuffer(int length)
Create V8 value array buffer from a given length.
|
V8ValueBigInteger |
createV8ValueBigInteger(java.math.BigInteger bigInteger)
Create V8 value big integer.
|
V8ValueBigInteger |
createV8ValueBigInteger(java.lang.String bigIntegerValue)
Create V8 value big integer.
|
V8ValueBoolean |
createV8ValueBoolean(boolean booleanValue)
Create V8 value boolean.
|
V8ValueBooleanObject |
createV8ValueBooleanObject(boolean booleanValue)
Create V8 value boolean object.
|
V8ValueDataView |
createV8ValueDataView(V8ValueArrayBuffer v8ValueArrayBuffer)
Create V8 value data view.
|
V8ValueDouble |
createV8ValueDouble(double doubleValue)
Create V8 value double.
|
V8ValueDoubleObject |
createV8ValueDoubleObject(double doubleValue)
Create V8 value double object.
|
V8ValueError |
createV8ValueError(V8ValueErrorType v8ValueErrorType,
java.lang.String message)
Create V8 value error by type and message.
|
V8ValueFunction |
createV8ValueFunction(JavetCallbackContext javetCallbackContext)
Create V8 value function.
|
V8ValueFunction |
createV8ValueFunction(java.lang.String codeString)
Create V8 value function.
|
V8ValueInteger |
createV8ValueInteger(int integerValue)
Create V8 value integer.
|
V8ValueIntegerObject |
createV8ValueIntegerObject(int intValue)
Create V8 value int object.
|
V8ValueLong |
createV8ValueLong(long longValue)
Create V8 value long.
|
V8ValueLongObject |
createV8ValueLongObject(long longValue)
Create V8 value long object.
|
V8ValueMap |
createV8ValueMap()
Create V8 value map.
|
V8ValueNull |
createV8ValueNull()
Create V8 value null.
|
V8ValueObject |
createV8ValueObject()
Create V8 value object.
|
V8ValuePromise |
createV8ValuePromise()
Create V8 value promise.
|
V8ValueProxy |
createV8ValueProxy(V8Value v8Value)
Create V8 value proxy.
|
V8ValueSet |
createV8ValueSet()
Create V8 value set.
|
V8ValueString |
createV8ValueString(java.lang.String str)
Create V8 value string.
|
V8ValueStringObject |
createV8ValueStringObject(java.lang.String str)
Create V8 value string object from string.
|
V8ValueSymbol |
createV8ValueSymbol(java.lang.String description,
boolean global)
Create V8 value symbol.
|
V8ValueTypedArray |
createV8ValueTypedArray(V8ValueReferenceType type,
int length)
Create V8 value typed array.
|
V8ValueUndefined |
createV8ValueUndefined()
Create V8 value undefined.
|
V8ValueZonedDateTime |
createV8ValueZonedDateTime(long jsTimestamp)
Create V8 value zoned date time.
|
V8ValueZonedDateTime |
createV8ValueZonedDateTime(java.time.ZonedDateTime zonedDateTime)
Create V8 value zoned date time.
|
<T extends V8Value> |
get(int index)
Gets a value by index.
|
boolean |
isClosed()
Is closed.
|
boolean |
isEscapable()
Is escapable.
|
V8Scope |
setEscapable()
Sets escapable to true.
|
V8Scope |
setEscapable(boolean escapable)
Sets escapable.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreateV8ValueProxy, createV8ValueSymbolprotected static final java.lang.String ERROR_MESSAGE_V8_RUNTIME_CANNOT_BE_EMPTY
protected boolean closed
protected boolean escapable
protected V8Runtime v8Runtime
protected java.util.List<V8Value> values
public <T extends V8Value> T add(T value)
T - the type parametervalue - the valuepublic void close()
throws JavetException
close in interface IJavetClosableclose in interface java.lang.AutoCloseableJavetExceptionpublic V8Module createV8Module(java.lang.String moduleName, IV8ValueObject iV8ValueObject) throws JavetException
IV8CreatablecreateV8Module in interface IV8CreatablemoduleName - the module nameiV8ValueObject - the V8 value object to be exportedJavetException - the javet exceptionpublic V8ValueArray createV8ValueArray() throws JavetException
IV8CreatablecreateV8ValueArray in interface IV8CreatableJavetException - the javet exceptionpublic V8ValueArrayBuffer createV8ValueArrayBuffer(int length) throws JavetException
IV8CreatablecreateV8ValueArrayBuffer in interface IV8Creatablelength - the lengthJavetException - the javet exceptionpublic V8ValueArrayBuffer createV8ValueArrayBuffer(java.nio.ByteBuffer byteBuffer) throws JavetException
IV8CreatablecreateV8ValueArrayBuffer in interface IV8CreatablebyteBuffer - the byte bufferJavetException - the javet exceptionpublic V8ValueBigInteger createV8ValueBigInteger(java.math.BigInteger bigInteger) throws JavetException
IV8CreatablecreateV8ValueBigInteger in interface IV8CreatablebigInteger - the big integerJavetException - the javet exceptionpublic V8ValueBigInteger createV8ValueBigInteger(java.lang.String bigIntegerValue) throws JavetException
IV8CreatablecreateV8ValueBigInteger in interface IV8CreatablebigIntegerValue - the big integer valueJavetException - the javet exceptionpublic V8ValueBoolean createV8ValueBoolean(boolean booleanValue) throws JavetException
IV8CreatablecreateV8ValueBoolean in interface IV8CreatablebooleanValue - the boolean valueJavetException - the javet exceptionpublic V8ValueBooleanObject createV8ValueBooleanObject(boolean booleanValue) throws JavetException
IV8CreatablecreateV8ValueBooleanObject in interface IV8CreatablebooleanValue - the boolean valueJavetException - the javet exceptionpublic V8ValueDataView createV8ValueDataView(V8ValueArrayBuffer v8ValueArrayBuffer) throws JavetException
IV8CreatablecreateV8ValueDataView in interface IV8Creatablev8ValueArrayBuffer - the V8 value array bufferJavetException - the javet exceptionpublic V8ValueDouble createV8ValueDouble(double doubleValue) throws JavetException
IV8CreatablecreateV8ValueDouble in interface IV8CreatabledoubleValue - the double valueJavetException - the javet exceptionpublic V8ValueDoubleObject createV8ValueDoubleObject(double doubleValue) throws JavetException
IV8CreatablecreateV8ValueDoubleObject in interface IV8CreatabledoubleValue - the double valueJavetException - the javet exceptionpublic V8ValueError createV8ValueError(V8ValueErrorType v8ValueErrorType, java.lang.String message) throws JavetException
IV8CreatablecreateV8ValueError in interface IV8Creatablev8ValueErrorType - the V8 value error typemessage - the messageJavetException - the javet exceptionpublic V8ValueFunction createV8ValueFunction(JavetCallbackContext javetCallbackContext) throws JavetException
IV8CreatablecreateV8ValueFunction in interface IV8CreatablejavetCallbackContext - the javet callback contextJavetException - the javet exceptionpublic V8ValueFunction createV8ValueFunction(java.lang.String codeString) throws JavetException
IV8CreatablecreateV8ValueFunction in interface IV8CreatablecodeString - the code stringJavetException - the javet exceptionpublic V8ValueInteger createV8ValueInteger(int integerValue) throws JavetException
IV8CreatablecreateV8ValueInteger in interface IV8CreatableintegerValue - the integer valueJavetException - the javet exceptionpublic V8ValueIntegerObject createV8ValueIntegerObject(int intValue) throws JavetException
IV8CreatablecreateV8ValueIntegerObject in interface IV8CreatableintValue - the int valueJavetException - the javet exceptionpublic V8ValueLong createV8ValueLong(long longValue) throws JavetException
IV8CreatablecreateV8ValueLong in interface IV8CreatablelongValue - the long valueJavetException - the javet exceptionpublic V8ValueLongObject createV8ValueLongObject(long longValue) throws JavetException
IV8CreatablecreateV8ValueLongObject in interface IV8CreatablelongValue - the long valueJavetException - the javet exceptionpublic V8ValueMap createV8ValueMap() throws JavetException
IV8CreatablecreateV8ValueMap in interface IV8CreatableJavetException - the javet exceptionpublic V8ValueNull createV8ValueNull()
IV8CreatablecreateV8ValueNull in interface IV8Creatablepublic V8ValueObject createV8ValueObject() throws JavetException
IV8CreatablecreateV8ValueObject in interface IV8CreatableJavetException - the javet exceptionpublic V8ValuePromise createV8ValuePromise() throws JavetException
IV8CreatablecreateV8ValuePromise in interface IV8CreatableJavetException - the javet exceptionpublic V8ValueProxy createV8ValueProxy(V8Value v8Value) throws JavetException
IV8CreatablecreateV8ValueProxy in interface IV8Creatablev8Value - the V8 valueJavetException - the javet exceptionpublic V8ValueSet createV8ValueSet() throws JavetException
IV8CreatablecreateV8ValueSet in interface IV8CreatableJavetException - the javet exceptionpublic V8ValueString createV8ValueString(java.lang.String str) throws JavetException
IV8CreatablecreateV8ValueString in interface IV8Creatablestr - the strJavetException - the javet exceptionpublic V8ValueStringObject createV8ValueStringObject(java.lang.String str) throws JavetException
IV8CreatablecreateV8ValueStringObject in interface IV8Creatablestr - the strJavetException - the javet exceptionpublic V8ValueSymbol createV8ValueSymbol(java.lang.String description, boolean global) throws JavetException
IV8CreatablecreateV8ValueSymbol in interface IV8Creatabledescription - the descriptionglobal - the globalJavetException - the javet exceptionpublic V8ValueTypedArray createV8ValueTypedArray(V8ValueReferenceType type, int length) throws JavetException
IV8CreatablecreateV8ValueTypedArray in interface IV8Creatabletype - the typelength - the lengthJavetException - the javet exceptionpublic V8ValueUndefined createV8ValueUndefined()
IV8CreatablecreateV8ValueUndefined in interface IV8Creatablepublic V8ValueZonedDateTime createV8ValueZonedDateTime(long jsTimestamp) throws JavetException
IV8CreatablecreateV8ValueZonedDateTime in interface IV8CreatablejsTimestamp - the js timestampJavetException - the javet exceptionpublic V8ValueZonedDateTime createV8ValueZonedDateTime(java.time.ZonedDateTime zonedDateTime) throws JavetException
IV8CreatablecreateV8ValueZonedDateTime in interface IV8CreatablezonedDateTime - the zoned date timeJavetException - the javet exceptionpublic <T extends V8Value> T get(int index)
T - the type parameterindex - the indexpublic boolean isClosed()
IJavetClosableisClosed in interface IJavetClosablepublic boolean isEscapable()
public V8Scope setEscapable()
public V8Scope setEscapable(boolean escapable)
escapable - the escapable