public class V8ValueTypedArray extends V8ValueObject implements IV8ValueTypedArray
E.g.:
try (V8ValueArrayBuffer v8ValueArrayBuffer = v8ValueTypedArray.getArrayBuffer()) { long[] longs = new long[v8ValueArrayBuffer.getLength()]; v8ValueArrayBuffer.toLongs(longs); // ... }
Or, play with ByteBuffer directly. 1. Get array buffer and apply try-with-resource. 2. Get native ByteBuffer. 3. Set order of the native ByteBuffer to native order. 4. Get typed buffer by type. 5. Read from or write to the typed buffer.
E.g:
try (V8ValueArrayBuffer v8ValueArrayBuffer = v8ValueTypedArray.getArrayBuffer()) { LongBuffer longBuffer = v8ValueArrayBuffer.getByteBuffer().order(ByteOrder.nativeOrder()).asLongBuffer(); // ... }
Modifier and Type | Field and Description |
---|---|
static int |
EIGHT_BYTES_PER_VALUE
The constant EIGHT_BYTES_PER_VALUE.
|
static int |
FOUR_BYTES_PER_VALUE
The constant FOUR_BYTES_PER_VALUE.
|
static int |
ONE_BYTE_PER_VALUE
The constant ONE_BYTE_PER_VALUE.
|
static java.lang.String |
PROPERTY_BUFFER
The constant PROPERTY_BUFFER.
|
static java.lang.String |
PROPERTY_BYTE_LENGTH
The constant PROPERTY_BYTE_LENGTH.
|
static java.lang.String |
PROPERTY_BYTE_OFFSET
The constant PROPERTY_BYTE_OFFSET.
|
static java.lang.String |
PROPERTY_NAME
The constant PROPERTY_NAME.
|
protected int |
sizeInBytes
The Size in bytes.
|
static int |
TWO_BYTES_PER_VALUE
The constant TWO_BYTES_PER_VALUE.
|
protected V8ValueReferenceType |
type
The Type.
|
static int |
ZERO_BYTE_PER_VALUE
The constant ZERO_BYTE_PER_VALUE.
|
ERROR_THE_KEY_VALUE_PAIR_MUST_MATCH, FUNCTION_ADD, FUNCTION_DELETE, FUNCTION_GET, FUNCTION_HAS, FUNCTION_SET, METHOD_PREFIX_GET, METHOD_PREFIX_IS, METHOD_PREFIX_SET, PROPERTY_PROTOTYPE
handle, INVALID_HANDLE, weak
OBJECT_CONVERTER, v8Runtime
DEFAULT_BATCH_SIZE, MIN_BATCH_SIZE
Modifier and Type | Method and Description |
---|---|
boolean |
fromBytes(byte[] bytes)
From byte array.
|
boolean |
fromDoubles(double[] doubles)
From double array.
|
boolean |
fromFloats(float[] floats)
From float array.
|
boolean |
fromIntegers(int[] integers)
From integer array.
|
boolean |
fromLongs(long[] longs)
From long array.
|
boolean |
fromShorts(short[] shorts)
From short array.
|
<T extends V8Value> |
get(java.lang.Object key)
Get property value by key object.
|
V8ValueArrayBuffer |
getBuffer() |
int |
getByteLength() |
int |
getByteOffset() |
int |
getLength() |
int |
getSizeInBytes() |
V8ValueReferenceType |
getType() |
boolean |
isValid() |
protected void |
setType(V8ValueReferenceType type)
Sets type.
|
byte[] |
toBytes()
To byte array.
|
double[] |
toDoubles()
To double array.
|
float[] |
toFloats()
To float array.
|
int[] |
toIntegers()
To int array.
|
long[] |
toLongs()
To long array.
|
short[] |
toShorts()
To short array.
|
batchGet, bind, bindFunction, bindProperty, delete, deletePrivateProperty, forEach, forEach, getBoolean, getDouble, getIdentityHash, getInteger, getLong, getOwnPropertyNames, getPrivateProperty, getProperty, getPropertyNames, getPrototype, getString, has, hasInternalType, hasOwnProperty, hasPrivateProperty, invokeExtended, invokeExtended, sameValue, set, set, setBoolean, setDouble, setInteger, setLong, setNull, setPrivateProperty, setProperty, setPrototype, setString, setUndefined, strictEquals, toJsonString, toProtoString, unbind, unbindFunction, unbindProperty, unbindProperty, unbindProperty, unbindProperty
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
batchGet, bind, bindFunction, bindFunction, bindFunction, bindProperty, bindProperty, delete, deleteNull, deletePrivateProperty, deleteUndefined, forEach, forEach, forEach, forEach, forEach, forEach, forEach, forEach, getBigInteger, getBoolean, getDouble, getFloat, getIdentityHash, getInteger, getLong, getNull, getObject, getOwnPropertyNames, getOwnPropertyNameStrings, getPrivateProperty, getPrivatePropertyBoolean, getPrivatePropertyDouble, getPrivatePropertyFloat, getPrivatePropertyInteger, getPrivatePropertyLong, getPrivatePropertyNull, getPrivatePropertyObject, getPrivatePropertyPrimitive, getPrivatePropertyString, getPrivatePropertyUndefined, getPrivatePropertyZonedDateTime, getProperty, getPropertyBoolean, getPropertyDouble, getPropertyFloat, getPropertyInteger, getPropertyLong, getPropertyNames, getPropertyObject, getPropertyPrimitive, getPropertyString, getPropertyZonedDateTime, getPrototype, getString, getUndefined, getZonedDateTime, has, hasInternalType, hasNull, hasOwnProperty, hasPrivateProperty, hasUndefined, invoke, invoke, invokeBigInteger, invokeBoolean, invokeDouble, invokeExtended, invokeExtended, invokeFloat, invokeInteger, invokeLong, invokeObject, invokeString, invokeVoid, invokeVoid, invokeZonedDateTime, isGeneratorObject, set, set, setBoolean, setDouble, setInteger, setLong, setNull, setPrivateProperty, setPrivatePropertyNull, setPrivatePropertyUndefined, setProperty, setPropertyNull, setPropertyUndefined, setPrototype, setString, setUndefined, toJsonString, toProtoString, unbind, unbindFunction, unbindFunction, unbindFunction, unbindProperty, unbindProperty, unbindProperty, unbindProperty
clearWeak, close, getHandle, isClosed, isWeak, isWeak, setWeak
asBoolean, asDouble, asInt, asLong, asString, equals, getV8Runtime, isNull, isNullOrUndefined, isUndefined, sameValue, strictEquals
close
toClone, toClone
public static final java.lang.String PROPERTY_BYTE_LENGTH
public static final java.lang.String PROPERTY_BUFFER
public static final java.lang.String PROPERTY_BYTE_OFFSET
public static final java.lang.String PROPERTY_NAME
public static final int ONE_BYTE_PER_VALUE
public static final int TWO_BYTES_PER_VALUE
public static final int FOUR_BYTES_PER_VALUE
public static final int EIGHT_BYTES_PER_VALUE
public static final int ZERO_BYTE_PER_VALUE
protected int sizeInBytes
protected V8ValueReferenceType type
public boolean fromBytes(byte[] bytes) throws JavetException
bytes
- the byte arrayJavetException
- the javet exceptionpublic boolean fromDoubles(double[] doubles) throws JavetException
doubles
- the double arrayJavetException
- the javet exceptionpublic boolean fromFloats(float[] floats) throws JavetException
floats
- the float arrayJavetException
- the javet exceptionpublic boolean fromIntegers(int[] integers) throws JavetException
integers
- the integer arrayJavetException
- the javet exceptionpublic boolean fromLongs(long[] longs) throws JavetException
longs
- the long arrayJavetException
- the javet exceptionpublic boolean fromShorts(short[] shorts) throws JavetException
shorts
- the short arrayJavetException
- the javet exceptionpublic <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
get
in class V8ValueObject
T
- the type parameterkey
- the property keyJavetException
- the javet exception@CheckReturnValue public V8ValueArrayBuffer getBuffer() throws JavetException
getBuffer
in interface IV8ValueTypedArray
JavetException
public int getByteLength() throws JavetException
getByteLength
in interface IV8ValueTypedArray
JavetException
public int getByteOffset() throws JavetException
getByteOffset
in interface IV8ValueTypedArray
JavetException
public int getLength() throws JavetException
getLength
in interface IV8ValueTypedArray
JavetException
public int getSizeInBytes()
getSizeInBytes
in interface IV8ValueTypedArray
public V8ValueReferenceType getType()
getType
in interface IV8ValueReference
getType
in class V8ValueObject
public boolean isValid()
isValid
in interface IV8ValueTypedArray
protected void setType(V8ValueReferenceType type)
type
- the typepublic byte[] toBytes() throws JavetException
JavetException
- the javet exceptionpublic double[] toDoubles() throws JavetException
JavetException
- the javet exceptionpublic float[] toFloats() throws JavetException
JavetException
- the javet exceptionpublic int[] toIntegers() throws JavetException
JavetException
- the javet exceptionpublic long[] toLongs() throws JavetException
JavetException
- the javet exceptionpublic short[] toShorts() throws JavetException
JavetException
- the javet exception