public class V8ValueObject extends V8ValueReference implements IV8ValueObject
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
ERROR_THE_KEY_VALUE_PAIR_MUST_MATCH
The constant ERROR_THE_KEY_VALUE_PAIR_MUST_MATCH.
|
protected static java.lang.String |
FUNCTION_ADD |
protected static java.lang.String |
FUNCTION_DELETE |
protected static java.lang.String |
FUNCTION_GET |
protected static java.lang.String |
FUNCTION_HAS |
protected static java.lang.String |
FUNCTION_SET |
static java.lang.String |
METHOD_PREFIX_GET |
static java.lang.String |
METHOD_PREFIX_IS |
static java.lang.String |
METHOD_PREFIX_SET |
protected static java.lang.String |
PROPERTY_PROTOTYPE |
handle, INVALID_HANDLE, weak
OBJECT_CONVERTER, v8Runtime
DEFAULT_BATCH_SIZE, MIN_BATCH_SIZE
Modifier | Constructor and Description |
---|---|
protected |
V8ValueObject(V8Runtime v8Runtime,
long handle)
Instantiates a new V8 value object.
|
Modifier and Type | Method and Description |
---|---|
int |
batchGet(V8Value[] v8ValueKeys,
V8Value[] v8ValueValues,
int length)
Batch get a range of values by keys.
|
java.util.List<JavetCallbackContext> |
bind(java.lang.Object callbackReceiver)
Bind both functions via @V8Function and properties via @V8Property.
|
boolean |
bindFunction(JavetCallbackContext javetCallbackContext)
Binds function by name symbol and callback context.
|
boolean |
bindProperty(JavetCallbackContext javetCallbackContextGetter,
JavetCallbackContext javetCallbackContextSetter)
Bind property by getter and setter.
|
boolean |
delete(java.lang.Object key)
Delete property by key object.
|
boolean |
deletePrivateProperty(java.lang.String propertyName)
Delete private property by name string.
|
<Key extends V8Value,Value extends V8Value,E extends java.lang.Throwable> |
forEach(IJavetBiConsumer<Key,Value,E> consumer,
int batchSize)
Invoke the bi-consumer for each of the keys.
|
<Key extends V8Value,Value extends V8Value,E extends java.lang.Throwable> |
forEach(IJavetBiIndexedConsumer<Key,Value,E> consumer,
int batchSize)
Invoke the bi-indexed-consumer for each of the keys.
|
<T extends V8Value> |
get(java.lang.Object key)
Get property value by key object.
|
java.lang.Boolean |
getBoolean(java.lang.Object key)
Gets property value as boolean by key object.
|
java.lang.Double |
getDouble(java.lang.Object key)
Gets property value as double by key object.
|
int |
getIdentityHash()
Returns the identity hash for this object.
|
java.lang.Integer |
getInteger(java.lang.Object key)
Gets property value as integer by key object.
|
java.lang.Long |
getLong(java.lang.Object key)
Gets property value as long by key object.
|
IV8ValueArray |
getOwnPropertyNames()
Gets own property names.
|
<T extends V8Value> |
getPrivateProperty(java.lang.String propertyName)
Gets private property value by name string.
|
<T extends V8Value> |
getProperty(java.lang.Object key)
Gets property value by key object.
|
IV8ValueArray |
getPropertyNames()
Gets property names.
|
<T extends IV8ValueObject> |
getPrototype()
Gets prototype.
|
java.lang.String |
getString(java.lang.Object key)
Gets string by key object.
|
V8ValueReferenceType |
getType() |
boolean |
has(java.lang.Object value)
Has object property key by key object.
|
boolean |
hasInternalType(V8ValueInternalType internalType)
Has internal type.
|
boolean |
hasOwnProperty(java.lang.Object key)
Has own property key by key object.
|
boolean |
hasPrivateProperty(java.lang.String propertyName)
Has private property by name string.
|
<T extends V8Value> |
invokeExtended(java.lang.String functionName,
boolean returnResult,
java.lang.Object... objects)
Invoke function and return a V8 value by function name, return result, objects as arguments.
|
<T extends V8Value> |
invokeExtended(java.lang.String functionName,
boolean returnResult,
V8Value... v8Values)
Invoke function and return a V8 value by function name, return result, V8 values as arguments.
|
boolean |
sameValue(V8Value v8Value)
Same value.
|
boolean |
set(java.lang.Object... keysAndValues)
Set property by pairs of key object and value object.
|
boolean |
set(java.lang.Object key,
java.lang.Object value)
Set property by key object and value object.
|
boolean |
setBoolean(java.lang.Object key,
java.lang.Boolean value)
Set property by key object and value boolean.
|
boolean |
setDouble(java.lang.Object key,
java.lang.Double value)
Set property by key object and value double.
|
boolean |
setInteger(java.lang.Object key,
java.lang.Integer value)
Set property by key object and value integer.
|
boolean |
setLong(java.lang.Object key,
java.lang.Long value)
Set property by key object and value long.
|
boolean |
setNull(java.lang.Object key)
Set property to null by key object.
|
boolean |
setPrivateProperty(java.lang.String propertyName,
java.lang.Object propertyValue)
Set private property by name string and value object.
|
boolean |
setProperty(java.lang.Object key,
java.lang.Object value)
Set property by key object and value object.
|
boolean |
setPrototype(IV8ValueObject v8ValueObject)
Sets prototype.
|
boolean |
setString(java.lang.Object key,
java.lang.String value)
Set property by key object and value string.
|
boolean |
setUndefined(java.lang.Object key)
Set property to undefined by key object.
|
boolean |
strictEquals(V8Value v8Value)
Strict equals.
|
java.lang.String |
toJsonString()
To json string.
|
java.lang.String |
toProtoString()
To proto string.
|
int |
unbind(java.lang.Object callbackReceiver)
Unbind functions and properties by object.
|
protected boolean |
unbindFunction(java.lang.String functionName,
V8ValueSymbolType symbolType) |
boolean |
unbindProperty(JavetCallbackContext javetCallbackContext)
Unbind property by callback context.
|
protected boolean |
unbindProperty(java.lang.String propertyName,
V8ValueSymbolType symbolType) |
boolean |
unbindProperty(V8ValueString propertyName)
Unbind property by property name string.
|
boolean |
unbindProperty(V8ValueSymbol propertyName)
Unbind property by property name symbol.
|
addReference, checkV8Runtime, clearWeak, close, close, equals, getHandle, isClosed, isWeak, isWeak, removeReference, setWeak, toClone, toString
getV8Runtime
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
bindFunction, bindFunction, bindProperty, deleteNull, deleteUndefined, forEach, forEach, forEach, forEach, forEach, forEach, getBigInteger, getFloat, getNull, getObject, getOwnPropertyNameStrings, getPrivatePropertyBoolean, getPrivatePropertyDouble, getPrivatePropertyFloat, getPrivatePropertyInteger, getPrivatePropertyLong, getPrivatePropertyNull, getPrivatePropertyObject, getPrivatePropertyPrimitive, getPrivatePropertyString, getPrivatePropertyUndefined, getPrivatePropertyZonedDateTime, getPropertyBoolean, getPropertyDouble, getPropertyFloat, getPropertyInteger, getPropertyLong, getPropertyObject, getPropertyPrimitive, getPropertyString, getPropertyZonedDateTime, getUndefined, getZonedDateTime, hasNull, hasUndefined, invoke, invoke, invokeBigInteger, invokeBoolean, invokeDouble, invokeFloat, invokeInteger, invokeLong, invokeObject, invokeString, invokeVoid, invokeVoid, invokeZonedDateTime, isGeneratorObject, setPrivatePropertyNull, setPrivatePropertyUndefined, setPropertyNull, setPropertyUndefined, unbindFunction, unbindFunction, unbindFunction, unbindProperty
clearWeak, close, getHandle, isClosed, isWeak, isWeak, setWeak
asBoolean, asDouble, asInt, asLong, asString, equals, getV8Runtime, isNull, isNullOrUndefined, isUndefined
close
toClone, toClone
public static final java.lang.String METHOD_PREFIX_GET
public static final java.lang.String METHOD_PREFIX_IS
public static final java.lang.String METHOD_PREFIX_SET
protected static final java.lang.String ERROR_THE_KEY_VALUE_PAIR_MUST_MATCH
protected static final java.lang.String FUNCTION_ADD
protected static final java.lang.String FUNCTION_DELETE
protected static final java.lang.String FUNCTION_GET
protected static final java.lang.String FUNCTION_HAS
protected static final java.lang.String FUNCTION_SET
protected static final java.lang.String PROPERTY_PROTOTYPE
protected V8ValueObject(V8Runtime v8Runtime, long handle) throws JavetException
v8Runtime
- the V8 runtimehandle
- the handleJavetException
- the javet exceptionpublic int batchGet(V8Value[] v8ValueKeys, V8Value[] v8ValueValues, int length) throws JavetException
IV8ValueObject
batchGet
in interface IV8ValueObject
v8ValueKeys
- the V8 value keysv8ValueValues
- the V8 value valueslength
- the lengthJavetException
- the javet exceptionpublic java.util.List<JavetCallbackContext> bind(java.lang.Object callbackReceiver) throws JavetException
IV8ValueObject
bind
in interface IV8ValueObject
callbackReceiver
- the callback receiverJavetException
- the javet exceptionpublic boolean bindFunction(JavetCallbackContext javetCallbackContext) throws JavetException
IV8ValueObject
It is for creating a Java code based function in V8.
bindFunction
in interface IV8ValueObject
javetCallbackContext
- the javet callback contextJavetException
- the javet exceptionpublic boolean bindProperty(JavetCallbackContext javetCallbackContextGetter, JavetCallbackContext javetCallbackContextSetter) throws JavetException
IV8ValueObject
bindProperty
in interface IV8ValueObject
javetCallbackContextGetter
- the javet callback context getterjavetCallbackContextSetter
- the javet callback context setterJavetException
- the javet exceptionpublic boolean delete(java.lang.Object key) throws JavetException
IV8ValueObject
delete
in interface IV8ValueObject
key
- the keyJavetException
- the javet exceptionpublic boolean deletePrivateProperty(java.lang.String propertyName) throws JavetException
IV8ValueObject
deletePrivateProperty
in interface IV8ValueObject
propertyName
- the property nameJavetException
- the javet exceptionpublic <Key extends V8Value,Value extends V8Value,E extends java.lang.Throwable> int forEach(IJavetBiConsumer<Key,Value,E> consumer, int batchSize) throws JavetException, E extends java.lang.Throwable
IV8ValueObject
forEach
in interface IV8ValueObject
Key
- the type of keyValue
- the type of valueE
- the type of exceptionconsumer
- the consumerbatchSize
- the batch sizeJavetException
- the javet exceptionE
- the custom exceptionE extends java.lang.Throwable
public <Key extends V8Value,Value extends V8Value,E extends java.lang.Throwable> int forEach(IJavetBiIndexedConsumer<Key,Value,E> consumer, int batchSize) throws JavetException, E extends java.lang.Throwable
IV8ValueObject
forEach
in interface IV8ValueObject
Key
- the type of keyValue
- the type of valueE
- the type of exceptionconsumer
- the consumerbatchSize
- the batch sizeJavetException
- the javet exceptionE
- the custom exceptionE extends java.lang.Throwable
@CheckReturnValue public <T extends V8Value> T get(java.lang.Object key) throws JavetException
IV8ValueObject
The return value must be consumed, otherwise memory leak may occur.
get
in interface IV8ValueObject
T
- the type parameterkey
- the property keyJavetException
- the javet exceptionpublic java.lang.Boolean getBoolean(java.lang.Object key) throws JavetException
IV8ValueObject
getBoolean
in interface IV8ValueObject
key
- the keyJavetException
- the javet exceptionpublic java.lang.Double getDouble(java.lang.Object key) throws JavetException
IV8ValueObject
getDouble
in interface IV8ValueObject
key
- the keyJavetException
- the javet exceptionpublic int getIdentityHash() throws JavetException
IV8ValueObject
The return value will never be 0. Also, it is not guaranteed to be unique.
getIdentityHash
in interface IV8ValueObject
JavetException
- the javet exceptionpublic java.lang.Integer getInteger(java.lang.Object key) throws JavetException
IV8ValueObject
getInteger
in interface IV8ValueObject
key
- the keyJavetException
- the javet exceptionpublic java.lang.Long getLong(java.lang.Object key) throws JavetException
IV8ValueObject
getLong
in interface IV8ValueObject
key
- the keyJavetException
- the javet exception@CheckReturnValue public IV8ValueArray getOwnPropertyNames() throws JavetException
IV8ValueObject
The return value must be consumed, otherwise memory leak may occur.
getOwnPropertyNames
in interface IV8ValueObject
JavetException
- the javet exceptionpublic <T extends V8Value> T getPrivateProperty(java.lang.String propertyName) throws JavetException
IV8ValueObject
The return value must be consumed, otherwise memory leak may occur.
getPrivateProperty
in interface IV8ValueObject
T
- the type parameterpropertyName
- the property nameJavetException
- the javet exception@CheckReturnValue public <T extends V8Value> T getProperty(java.lang.Object key) throws JavetException
IV8ValueObject
The return value must be consumed, otherwise memory leak may occur.
getProperty
in interface IV8ValueObject
T
- the type parameterkey
- the keyJavetException
- the javet exception@CheckReturnValue public IV8ValueArray getPropertyNames() throws JavetException
IV8ValueObject
The return value must be consumed, otherwise memory leak may occur.
getPropertyNames
in interface IV8ValueObject
JavetException
- the javet exceptionpublic <T extends IV8ValueObject> T getPrototype() throws JavetException
IV8ValueObject
The return value must be consumed, otherwise memory leak may occur.
getPrototype
in interface IV8ValueObject
T
- the type parameterJavetException
- the javet exceptionpublic java.lang.String getString(java.lang.Object key) throws JavetException
IV8ValueObject
getString
in interface IV8ValueObject
key
- the keyJavetException
- the javet exceptionpublic V8ValueReferenceType getType()
getType
in interface IV8ValueReference
getType
in class V8ValueReference
public boolean has(java.lang.Object value) throws JavetException
IV8ValueObject
has
in interface IV8ValueObject
value
- the valueJavetException
- the javet exceptionpublic boolean hasInternalType(V8ValueInternalType internalType) throws JavetException
IV8ValueObject
This API reveals the V8 internal implementation detail. A typical JavaScript object may look the same in JavaScript (typeof), but is very different internally.
hasInternalType
in interface IV8ValueObject
internalType
- the internal typeJavetException
- the javet exceptionpublic boolean hasOwnProperty(java.lang.Object key) throws JavetException
IV8ValueObject
hasOwnProperty
in interface IV8ValueObject
key
- the keyJavetException
- the javet exceptionpublic boolean hasPrivateProperty(java.lang.String propertyName) throws JavetException
IV8ValueObject
hasPrivateProperty
in interface IV8ValueObject
propertyName
- the property nameJavetException
- the javet exception@CheckReturnValue public <T extends V8Value> T invokeExtended(java.lang.String functionName, boolean returnResult, java.lang.Object... objects) throws JavetException
IV8ValueObject
The return value must be consumed, otherwise memory leak may occur.
invokeExtended
in interface IV8ValueObject
T
- the type parameterfunctionName
- the function namereturnResult
- the return resultobjects
- the objectsJavetException
- the javet exception@CheckReturnValue public <T extends V8Value> T invokeExtended(java.lang.String functionName, boolean returnResult, V8Value... v8Values) throws JavetException
IV8ValueObject
The return value must be consumed, otherwise memory leak may occur.
invokeExtended
in interface IV8ValueObject
T
- the type parameterfunctionName
- the function namereturnResult
- the return resultv8Values
- the V8 valuesJavetException
- the javet exceptionpublic boolean sameValue(V8Value v8Value) throws JavetException
IV8Value
The behavior is different from JS behavior but is the same as Java behavior.
sameValue
in interface IV8Value
sameValue
in class V8ValueReference
v8Value
- the V8 valueJavetException
- the javet exceptionpublic boolean set(java.lang.Object key, java.lang.Object value) throws JavetException
IV8ValueObject
set
in interface IV8ValueObject
key
- the keyvalue
- the valueJavetException
- the javet exceptionpublic boolean set(java.lang.Object... keysAndValues) throws JavetException
IV8ValueObject
set
in interface IV8ValueObject
keysAndValues
- the keys and valuesJavetException
- the javet exceptionpublic boolean setBoolean(java.lang.Object key, java.lang.Boolean value) throws JavetException
IV8ValueObject
setBoolean
in interface IV8ValueObject
key
- the keyvalue
- the valueJavetException
- the javet exceptionpublic boolean setDouble(java.lang.Object key, java.lang.Double value) throws JavetException
IV8ValueObject
setDouble
in interface IV8ValueObject
key
- the keyvalue
- the valueJavetException
- the javet exceptionpublic boolean setInteger(java.lang.Object key, java.lang.Integer value) throws JavetException
IV8ValueObject
setInteger
in interface IV8ValueObject
key
- the keyvalue
- the valueJavetException
- the javet exceptionpublic boolean setLong(java.lang.Object key, java.lang.Long value) throws JavetException
IV8ValueObject
setLong
in interface IV8ValueObject
key
- the keyvalue
- the valueJavetException
- the javet exceptionpublic boolean setNull(java.lang.Object key) throws JavetException
IV8ValueObject
setNull
in interface IV8ValueObject
key
- the keyJavetException
- the javet exceptionpublic boolean setPrivateProperty(java.lang.String propertyName, java.lang.Object propertyValue) throws JavetException
IV8ValueObject
setPrivateProperty
in interface IV8ValueObject
propertyName
- the property namepropertyValue
- the property valueJavetException
- the javet exceptionpublic boolean setProperty(java.lang.Object key, java.lang.Object value) throws JavetException
IV8ValueObject
setProperty
in interface IV8ValueObject
key
- the keyvalue
- the valueJavetException
- the javet exceptionpublic boolean setPrototype(IV8ValueObject v8ValueObject) throws JavetException
IV8ValueObject
setPrototype
in interface IV8ValueObject
v8ValueObject
- the V8 value objectJavetException
- the javet exceptionpublic boolean setString(java.lang.Object key, java.lang.String value) throws JavetException
IV8ValueObject
setString
in interface IV8ValueObject
key
- the keyvalue
- the valueJavetException
- the javet exceptionpublic boolean setUndefined(java.lang.Object key) throws JavetException
IV8ValueObject
setUndefined
in interface IV8ValueObject
key
- the keyJavetException
- the javet exceptionpublic boolean strictEquals(V8Value v8Value) throws JavetException
IV8Value
The behavior is different from JS behavior but is the same as Java behavior.
strictEquals
in interface IV8Value
strictEquals
in class V8ValueReference
v8Value
- the V8 valueJavetException
- the javet exceptionpublic java.lang.String toJsonString()
IV8ValueObject
JS equivalent:
JSON.stringify(obj);
toJsonString
in interface IV8ValueObject
public java.lang.String toProtoString()
IV8ValueObject
toProtoString
in interface IV8ValueObject
public int unbind(java.lang.Object callbackReceiver) throws JavetException
IV8ValueObject
unbind
in interface IV8ValueObject
callbackReceiver
- the callback receiverJavetException
- the javet exceptionprotected boolean unbindFunction(java.lang.String functionName, V8ValueSymbolType symbolType) throws JavetException
JavetException
public boolean unbindProperty(JavetCallbackContext javetCallbackContext) throws JavetException
IV8ValueObject
unbindProperty
in interface IV8ValueObject
javetCallbackContext
- the javet callback contextJavetException
- the javet exceptionprotected boolean unbindProperty(java.lang.String propertyName, V8ValueSymbolType symbolType) throws JavetException
JavetException
public boolean unbindProperty(V8ValueString propertyName) throws JavetException
IV8ValueObject
unbindProperty
in interface IV8ValueObject
propertyName
- the property nameJavetException
- the javet exceptionpublic boolean unbindProperty(V8ValueSymbol propertyName) throws JavetException
IV8ValueObject
unbindProperty
in interface IV8ValueObject
propertyName
- the property nameJavetException
- the javet exception