Class TypedArrays
- java.lang.Object
-
- com.google.gwt.typedarrays.shared.TypedArrays
-
public class TypedArrays extends java.lang.ObjectFactory class for various typed arrays. Behavior of all other methods is undefined ifisSupported()returns false.In client code, the various types are implemented by JavaScriptObjects, so you cannot reliable use instanceof checks on any of the returned implementations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTypedArrays.ImplBase class of implementations for creating various typed array structures.
-
Constructor Summary
Constructors Constructor Description TypedArrays()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ArrayBuffercreateArrayBuffer(int length)Create a newArrayBufferoflengthbytes.static DataViewcreateDataView(ArrayBuffer buffer)Create a newDataViewinstance on anArrayBuffer.static DataViewcreateDataView(ArrayBuffer buffer, int byteOffset)static DataViewcreateDataView(ArrayBuffer buffer, int byteOffset, int byteLength)Create a newDataViewinstance on anArrayBuffer, starting at an offset ofbyteOffsetand continuing forlengthbytes.static Float32ArraycreateFloat32Array(int length)static Float32ArraycreateFloat32Array(ArrayBuffer buffer)Create aFloat32Arrayinstance onbuffer, starting at starting at the beginning of the buffer and continuing to the end (which must be an integral number of elements).static Float32ArraycreateFloat32Array(ArrayBuffer buffer, int byteOffset)Create aFloat32Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing to the end of the buffer (which must be an integral number of elements).static Float32ArraycreateFloat32Array(ArrayBuffer buffer, int byteOffset, int length)Create aFloat32Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing forlengthelements.static Float64ArraycreateFloat64Array(int length)static Float64ArraycreateFloat64Array(ArrayBuffer buffer)Create aFloat64Arrayinstance onbuffer, starting at starting at the beginning of the buffer and continuing to the end (which must be an integral number of elements).static Float64ArraycreateFloat64Array(ArrayBuffer buffer, int byteOffset)Create aFloat64Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing to the end of the buffer (which must be an integral number of elements).static Float64ArraycreateFloat64Array(ArrayBuffer buffer, int byteOffset, int length)Create aFloat64Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing forlengthelements.static Int16ArraycreateInt16Array(int length)static Int16ArraycreateInt16Array(ArrayBuffer buffer)Create aInt16Arrayinstance onbuffer, starting at starting at the beginning of the buffer and continuing to the end (which must be an integral number of elements).static Int16ArraycreateInt16Array(ArrayBuffer buffer, int byteOffset)Create aInt16Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing to the end of the buffer (which must be an integral number of elements).static Int16ArraycreateInt16Array(ArrayBuffer buffer, int byteOffset, int length)Create aInt16Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing forlengthelements.static Int32ArraycreateInt32Array(int length)static Int32ArraycreateInt32Array(ArrayBuffer buffer)Create aInt32Arrayinstance onbuffer, starting at starting at the beginning of the buffer and continuing to the end (which must be an integral number of elements).static Int32ArraycreateInt32Array(ArrayBuffer buffer, int byteOffset)Create aInt32Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing to the end of the buffer (which must be an integral number of elements).static Int32ArraycreateInt32Array(ArrayBuffer buffer, int byteOffset, int length)Create aInt32Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing forlengthelements.static Int8ArraycreateInt8Array(int length)static Int8ArraycreateInt8Array(ArrayBuffer buffer)Create aInt8Arrayinstance onbuffer, starting at starting at the beginning of the buffer and continuing to the end.static Int8ArraycreateInt8Array(ArrayBuffer buffer, int byteOffset)Create aInt8Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing to the end of the buffer (which must be an integral number of elements).static Int8ArraycreateInt8Array(ArrayBuffer buffer, int byteOffset, int length)Create aInt8Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing forlengthelements.static Uint16ArraycreateUint16Array(int length)static Uint16ArraycreateUint16Array(ArrayBuffer buffer)Create aUint16Arrayinstance onbuffer, starting at starting at the beginning of the buffer and continuing to the end (which must be an integral number of elements).static Uint16ArraycreateUint16Array(ArrayBuffer buffer, int byteOffset)Create aUint16Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing to the end of the buffer (which must be an integral number of elements).static Uint16ArraycreateUint16Array(ArrayBuffer buffer, int byteOffset, int length)Create aUint16Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing forlengthelements.static Uint32ArraycreateUint32Array(int length)static Uint32ArraycreateUint32Array(ArrayBuffer buffer)Create aUint32Arrayinstance onbuffer, starting at starting at the beginning of the buffer and continuing to the end (which must be an integral number of elements).static Uint32ArraycreateUint32Array(ArrayBuffer buffer, int byteOffset)Create aUint32Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing to the end of the buffer (which must be an integral number of elements).static Uint32ArraycreateUint32Array(ArrayBuffer buffer, int byteOffset, int length)Create aUint32Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing forlengthelements.static Uint8ArraycreateUint8Array(int length)static Uint8ArraycreateUint8Array(ArrayBuffer buffer)Create aUint8Arrayinstance onbuffer, starting at starting at the beginning of the buffer and continuing to the end (which must be an integral number of elements).static Uint8ArraycreateUint8Array(ArrayBuffer buffer, int byteOffset)Create aUint8Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing to the end of the buffer.static Uint8ArraycreateUint8Array(ArrayBuffer buffer, int byteOffset, int length)Create aUint8Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing forlengthelements.static Uint8ClampedArraycreateUint8ClampedArray(int length)static Uint8ClampedArraycreateUint8ClampedArray(ArrayBuffer buffer)Create aUint8ClampedArrayinstance onbuffer, starting at starting at the beginning of the buffer and continuing to the end.static Uint8ClampedArraycreateUint8ClampedArray(ArrayBuffer buffer, int byteOffset)Create aUint8ClampedArrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing to the end of the buffer.static Uint8ClampedArraycreateUint8ClampedArray(ArrayBuffer buffer, int byteOffset, int length)Create aUint8ClampedArrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing forlengthelements.static booleanisSupported()Check if the current environment supports typed arrays.
-
-
-
Method Detail
-
createArrayBuffer
public static ArrayBuffer createArrayBuffer(int length)
Create a newArrayBufferoflengthbytes.- Parameters:
length- length of buffer in bytes- Returns:
- an
ArrayBufferinstance
-
createDataView
public static DataView createDataView(ArrayBuffer buffer)
Create a newDataViewinstance on anArrayBuffer.- Parameters:
buffer-ArrayBuffer- Returns:
DataViewinstance
-
createDataView
public static DataView createDataView(ArrayBuffer buffer, int byteOffset)
- Parameters:
buffer-ArrayBufferbyteOffset- offset into buffer- Returns:
DataViewinstance
-
createDataView
public static DataView createDataView(ArrayBuffer buffer, int byteOffset, int byteLength)
Create a newDataViewinstance on anArrayBuffer, starting at an offset ofbyteOffsetand continuing forlengthbytes.- Parameters:
buffer-ArrayBufferbyteOffset- offset into bufferbyteLength- length of view in bytes- Returns:
DataViewinstance
-
createFloat32Array
public static Float32Array createFloat32Array(ArrayBuffer buffer)
Create aFloat32Arrayinstance onbuffer, starting at starting at the beginning of the buffer and continuing to the end (which must be an integral number of elements).- Parameters:
buffer- underlyingArrayBuffer- Returns:
- an
Float32Arrayinstance
-
createFloat32Array
public static Float32Array createFloat32Array(ArrayBuffer buffer, int byteOffset)
Create aFloat32Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing to the end of the buffer (which must be an integral number of elements).- Parameters:
buffer- underlyingArrayBufferbyteOffset- byte offset from the start ofbuffer- Returns:
- an
Float32Arrayinstance
-
createFloat32Array
public static Float32Array createFloat32Array(ArrayBuffer buffer, int byteOffset, int length)
Create aFloat32Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing forlengthelements.- Parameters:
buffer- underlyingArrayBufferbyteOffset- byte offset from the start ofbufferlength- number of elements in the resulting array- Returns:
- an
Float32Arrayinstance
-
createFloat32Array
public static Float32Array createFloat32Array(int length)
- Parameters:
length- size of array- Returns:
- a
Float32Arrayinstance
-
createFloat64Array
public static Float64Array createFloat64Array(ArrayBuffer buffer)
Create aFloat64Arrayinstance onbuffer, starting at starting at the beginning of the buffer and continuing to the end (which must be an integral number of elements).Note that Safari does not currently support Float64 Arrays!
- Parameters:
buffer- underlyingArrayBuffer- Returns:
- an
Float64Arrayinstance
-
createFloat64Array
public static Float64Array createFloat64Array(ArrayBuffer buffer, int byteOffset)
Create aFloat64Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing to the end of the buffer (which must be an integral number of elements).Note that Safari does not currently support Float64 Arrays!
- Parameters:
buffer- underlyingArrayBufferbyteOffset- byte offset from the start ofbuffer- Returns:
- an
Float64Arrayinstance
-
createFloat64Array
public static Float64Array createFloat64Array(ArrayBuffer buffer, int byteOffset, int length)
Create aFloat64Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing forlengthelements.Note that Safari does not currently support Float64 Arrays!
- Parameters:
buffer- underlyingArrayBufferbyteOffset- byte offset from the start ofbufferlength- number of elements in the resulting array- Returns:
- an
Float64Arrayinstance
-
createFloat64Array
public static Float64Array createFloat64Array(int length)
Create aFloat64Arrayinstance oflengthelements, backed by a newArrayBuffer.Note that Safari does not currently support Float64 Arrays!
- Parameters:
length- size of array- Returns:
- a
Float64Arrayinstance
-
createInt16Array
public static Int16Array createInt16Array(ArrayBuffer buffer)
Create aInt16Arrayinstance onbuffer, starting at starting at the beginning of the buffer and continuing to the end (which must be an integral number of elements).- Parameters:
buffer- underlyingArrayBuffer- Returns:
- an
Int16Arrayinstance
-
createInt16Array
public static Int16Array createInt16Array(ArrayBuffer buffer, int byteOffset)
Create aInt16Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing to the end of the buffer (which must be an integral number of elements).- Parameters:
buffer- underlyingArrayBufferbyteOffset- byte offset from the start ofbuffer- Returns:
- an
Int16Arrayinstance
-
createInt16Array
public static Int16Array createInt16Array(ArrayBuffer buffer, int byteOffset, int length)
Create aInt16Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing forlengthelements.- Parameters:
buffer- underlyingArrayBufferbyteOffset- byte offset from the start ofbufferlength- number of elements in the resulting array- Returns:
- an
Int16Arrayinstance
-
createInt16Array
public static Int16Array createInt16Array(int length)
- Parameters:
length- size of array- Returns:
- a
Int16Arrayinstance
-
createInt32Array
public static Int32Array createInt32Array(ArrayBuffer buffer)
Create aInt32Arrayinstance onbuffer, starting at starting at the beginning of the buffer and continuing to the end (which must be an integral number of elements).- Parameters:
buffer- underlyingArrayBuffer- Returns:
- an
Int32Arrayinstance
-
createInt32Array
public static Int32Array createInt32Array(ArrayBuffer buffer, int byteOffset)
Create aInt32Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing to the end of the buffer (which must be an integral number of elements).- Parameters:
buffer- underlyingArrayBufferbyteOffset- byte offset from the start ofbuffer- Returns:
- an
Int32Arrayinstance
-
createInt32Array
public static Int32Array createInt32Array(ArrayBuffer buffer, int byteOffset, int length)
Create aInt32Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing forlengthelements.- Parameters:
buffer- underlyingArrayBufferbyteOffset- byte offset from the start ofbufferlength- number of elements in the resulting array- Returns:
- an
Int32Arrayinstance
-
createInt32Array
public static Int32Array createInt32Array(int length)
- Parameters:
length- size of array- Returns:
- a
Int32Arrayinstance
-
createInt8Array
public static Int8Array createInt8Array(ArrayBuffer buffer)
Create aInt8Arrayinstance onbuffer, starting at starting at the beginning of the buffer and continuing to the end.- Parameters:
buffer- underlyingArrayBuffer- Returns:
- an
Int8Arrayinstance
-
createInt8Array
public static Int8Array createInt8Array(ArrayBuffer buffer, int byteOffset)
Create aInt8Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing to the end of the buffer (which must be an integral number of elements).- Parameters:
buffer- underlyingArrayBufferbyteOffset- byte offset from the start ofbuffer- Returns:
- an
Int8Arrayinstance
-
createInt8Array
public static Int8Array createInt8Array(ArrayBuffer buffer, int byteOffset, int length)
Create aInt8Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing forlengthelements.- Parameters:
buffer- underlyingArrayBufferbyteOffset- byte offset from the start ofbufferlength- number of elements in the resulting array- Returns:
- an
Int8Arrayinstance
-
createInt8Array
public static Int8Array createInt8Array(int length)
- Parameters:
length- size of array- Returns:
- a
Int8Arrayinstance
-
createUint16Array
public static Uint16Array createUint16Array(ArrayBuffer buffer)
Create aUint16Arrayinstance onbuffer, starting at starting at the beginning of the buffer and continuing to the end (which must be an integral number of elements).- Parameters:
buffer- underlyingArrayBuffer- Returns:
- an
Uint16Arrayinstance
-
createUint16Array
public static Uint16Array createUint16Array(ArrayBuffer buffer, int byteOffset)
Create aUint16Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing to the end of the buffer (which must be an integral number of elements).- Parameters:
buffer- underlyingArrayBufferbyteOffset- byte offset from the start ofbuffer- Returns:
- an
Uint16Arrayinstance
-
createUint16Array
public static Uint16Array createUint16Array(ArrayBuffer buffer, int byteOffset, int length)
Create aUint16Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing forlengthelements.- Parameters:
buffer- underlyingArrayBufferbyteOffset- byte offset from the start ofbufferlength- number of elements in the resulting array- Returns:
- an
Uint16Arrayinstance
-
createUint16Array
public static Uint16Array createUint16Array(int length)
- Parameters:
length- size of array- Returns:
- a
Uint16Arrayinstance
-
createUint32Array
public static Uint32Array createUint32Array(ArrayBuffer buffer)
Create aUint32Arrayinstance onbuffer, starting at starting at the beginning of the buffer and continuing to the end (which must be an integral number of elements).- Parameters:
buffer- underlyingArrayBuffer- Returns:
- an
Uint32Arrayinstance
-
createUint32Array
public static Uint32Array createUint32Array(ArrayBuffer buffer, int byteOffset)
Create aUint32Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing to the end of the buffer (which must be an integral number of elements).- Parameters:
buffer- underlyingArrayBufferbyteOffset- byte offset from the start ofbuffer- Returns:
- an
Uint32Arrayinstance
-
createUint32Array
public static Uint32Array createUint32Array(ArrayBuffer buffer, int byteOffset, int length)
Create aUint32Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing forlengthelements.- Parameters:
buffer- underlyingArrayBufferbyteOffset- byte offset from the start ofbufferlength- number of elements in the resulting array- Returns:
- an
Uint32Arrayinstance
-
createUint32Array
public static Uint32Array createUint32Array(int length)
- Parameters:
length- size of array- Returns:
- a
Uint32Arrayinstance
-
createUint8Array
public static Uint8Array createUint8Array(ArrayBuffer buffer)
Create aUint8Arrayinstance onbuffer, starting at starting at the beginning of the buffer and continuing to the end (which must be an integral number of elements).- Parameters:
buffer- underlyingArrayBuffer- Returns:
- an
Uint8Arrayinstance
-
createUint8Array
public static Uint8Array createUint8Array(ArrayBuffer buffer, int byteOffset)
Create aUint8Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing to the end of the buffer.- Parameters:
buffer- underlyingArrayBufferbyteOffset- byte offset from the start ofbuffer- Returns:
- an
Uint8Arrayinstance
-
createUint8Array
public static Uint8Array createUint8Array(ArrayBuffer buffer, int byteOffset, int length)
Create aUint8Arrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing forlengthelements.- Parameters:
buffer- underlyingArrayBufferbyteOffset- byte offset from the start ofbufferlength- number of elements in the resulting array- Returns:
- an
Uint8Arrayinstance
-
createUint8Array
public static Uint8Array createUint8Array(int length)
- Parameters:
length- size of array- Returns:
- a
Uint8Arrayinstance
-
createUint8ClampedArray
public static Uint8ClampedArray createUint8ClampedArray(ArrayBuffer buffer)
Create aUint8ClampedArrayinstance onbuffer, starting at starting at the beginning of the buffer and continuing to the end.- Parameters:
buffer- underlyingArrayBuffer- Returns:
- an
Uint8ClampedArrayinstance
-
createUint8ClampedArray
public static Uint8ClampedArray createUint8ClampedArray(ArrayBuffer buffer, int byteOffset)
Create aUint8ClampedArrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing to the end of the buffer.- Parameters:
buffer- underlyingArrayBufferbyteOffset- byte offset from the start ofbuffer- Returns:
- an
Uint8ClampedArrayinstance
-
createUint8ClampedArray
public static Uint8ClampedArray createUint8ClampedArray(ArrayBuffer buffer, int byteOffset, int length)
Create aUint8ClampedArrayinstance onbuffer, starting atbyteOffsetinto the buffer, continuing forlengthelements.- Parameters:
buffer- underlyingArrayBufferbyteOffset- byte offset from the start ofbufferlength- number of elements in the resulting array- Returns:
- an
Uint8ClampedArrayinstance
-
createUint8ClampedArray
public static Uint8ClampedArray createUint8ClampedArray(int length)
- Parameters:
length- size of array- Returns:
- a
Uint8ClampedArrayinstance
-
isSupported
public static boolean isSupported()
Check if the current environment supports typed arrays. Behavior of the variouscreateXXXmethods is undefined if this method returnsfalse, but will typically throw some exception.- Returns:
- true if typed arrays are support.
-
-