Class TypedArrays
- java.lang.Object
-
- com.google.gwt.typedarrays.shared.TypedArrays
-
public class TypedArrays extends java.lang.Object
Factory 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 class
TypedArrays.Impl
Base 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 ArrayBuffer
createArrayBuffer(int length)
Create a newArrayBuffer
oflength
bytes.static DataView
createDataView(ArrayBuffer buffer)
Create a newDataView
instance on anArrayBuffer
.static DataView
createDataView(ArrayBuffer buffer, int byteOffset)
static DataView
createDataView(ArrayBuffer buffer, int byteOffset, int byteLength)
Create a newDataView
instance on anArrayBuffer
, starting at an offset ofbyteOffset
and continuing forlength
bytes.static Float32Array
createFloat32Array(int length)
static Float32Array
createFloat32Array(ArrayBuffer buffer)
Create aFloat32Array
instance onbuffer
, starting at starting at the beginning of the buffer and continuing to the end (which must be an integral number of elements).static Float32Array
createFloat32Array(ArrayBuffer buffer, int byteOffset)
Create aFloat32Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing to the end of the buffer (which must be an integral number of elements).static Float32Array
createFloat32Array(ArrayBuffer buffer, int byteOffset, int length)
Create aFloat32Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing forlength
elements.static Float64Array
createFloat64Array(int length)
static Float64Array
createFloat64Array(ArrayBuffer buffer)
Create aFloat64Array
instance onbuffer
, starting at starting at the beginning of the buffer and continuing to the end (which must be an integral number of elements).static Float64Array
createFloat64Array(ArrayBuffer buffer, int byteOffset)
Create aFloat64Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing to the end of the buffer (which must be an integral number of elements).static Float64Array
createFloat64Array(ArrayBuffer buffer, int byteOffset, int length)
Create aFloat64Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing forlength
elements.static Int16Array
createInt16Array(int length)
static Int16Array
createInt16Array(ArrayBuffer buffer)
Create aInt16Array
instance onbuffer
, starting at starting at the beginning of the buffer and continuing to the end (which must be an integral number of elements).static Int16Array
createInt16Array(ArrayBuffer buffer, int byteOffset)
Create aInt16Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing to the end of the buffer (which must be an integral number of elements).static Int16Array
createInt16Array(ArrayBuffer buffer, int byteOffset, int length)
Create aInt16Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing forlength
elements.static Int32Array
createInt32Array(int length)
static Int32Array
createInt32Array(ArrayBuffer buffer)
Create aInt32Array
instance onbuffer
, starting at starting at the beginning of the buffer and continuing to the end (which must be an integral number of elements).static Int32Array
createInt32Array(ArrayBuffer buffer, int byteOffset)
Create aInt32Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing to the end of the buffer (which must be an integral number of elements).static Int32Array
createInt32Array(ArrayBuffer buffer, int byteOffset, int length)
Create aInt32Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing forlength
elements.static Int8Array
createInt8Array(int length)
static Int8Array
createInt8Array(ArrayBuffer buffer)
Create aInt8Array
instance onbuffer
, starting at starting at the beginning of the buffer and continuing to the end.static Int8Array
createInt8Array(ArrayBuffer buffer, int byteOffset)
Create aInt8Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing to the end of the buffer (which must be an integral number of elements).static Int8Array
createInt8Array(ArrayBuffer buffer, int byteOffset, int length)
Create aInt8Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing forlength
elements.static Uint16Array
createUint16Array(int length)
static Uint16Array
createUint16Array(ArrayBuffer buffer)
Create aUint16Array
instance onbuffer
, starting at starting at the beginning of the buffer and continuing to the end (which must be an integral number of elements).static Uint16Array
createUint16Array(ArrayBuffer buffer, int byteOffset)
Create aUint16Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing to the end of the buffer (which must be an integral number of elements).static Uint16Array
createUint16Array(ArrayBuffer buffer, int byteOffset, int length)
Create aUint16Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing forlength
elements.static Uint32Array
createUint32Array(int length)
static Uint32Array
createUint32Array(ArrayBuffer buffer)
Create aUint32Array
instance onbuffer
, starting at starting at the beginning of the buffer and continuing to the end (which must be an integral number of elements).static Uint32Array
createUint32Array(ArrayBuffer buffer, int byteOffset)
Create aUint32Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing to the end of the buffer (which must be an integral number of elements).static Uint32Array
createUint32Array(ArrayBuffer buffer, int byteOffset, int length)
Create aUint32Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing forlength
elements.static Uint8Array
createUint8Array(int length)
static Uint8Array
createUint8Array(ArrayBuffer buffer)
Create aUint8Array
instance onbuffer
, starting at starting at the beginning of the buffer and continuing to the end (which must be an integral number of elements).static Uint8Array
createUint8Array(ArrayBuffer buffer, int byteOffset)
Create aUint8Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing to the end of the buffer.static Uint8Array
createUint8Array(ArrayBuffer buffer, int byteOffset, int length)
Create aUint8Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing forlength
elements.static Uint8ClampedArray
createUint8ClampedArray(int length)
static Uint8ClampedArray
createUint8ClampedArray(ArrayBuffer buffer)
Create aUint8ClampedArray
instance onbuffer
, starting at starting at the beginning of the buffer and continuing to the end.static Uint8ClampedArray
createUint8ClampedArray(ArrayBuffer buffer, int byteOffset)
Create aUint8ClampedArray
instance onbuffer
, starting atbyteOffset
into the buffer, continuing to the end of the buffer.static Uint8ClampedArray
createUint8ClampedArray(ArrayBuffer buffer, int byteOffset, int length)
Create aUint8ClampedArray
instance onbuffer
, starting atbyteOffset
into the buffer, continuing forlength
elements.static boolean
isSupported()
Check if the current environment supports typed arrays.
-
-
-
Method Detail
-
createArrayBuffer
public static ArrayBuffer createArrayBuffer(int length)
Create a newArrayBuffer
oflength
bytes.- Parameters:
length
- length of buffer in bytes- Returns:
- an
ArrayBuffer
instance
-
createDataView
public static DataView createDataView(ArrayBuffer buffer)
Create a newDataView
instance on anArrayBuffer
.- Parameters:
buffer
-ArrayBuffer
- Returns:
DataView
instance
-
createDataView
public static DataView createDataView(ArrayBuffer buffer, int byteOffset)
- Parameters:
buffer
-ArrayBuffer
byteOffset
- offset into buffer- Returns:
DataView
instance
-
createDataView
public static DataView createDataView(ArrayBuffer buffer, int byteOffset, int byteLength)
Create a newDataView
instance on anArrayBuffer
, starting at an offset ofbyteOffset
and continuing forlength
bytes.- Parameters:
buffer
-ArrayBuffer
byteOffset
- offset into bufferbyteLength
- length of view in bytes- Returns:
DataView
instance
-
createFloat32Array
public static Float32Array createFloat32Array(ArrayBuffer buffer)
Create aFloat32Array
instance 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
Float32Array
instance
-
createFloat32Array
public static Float32Array createFloat32Array(ArrayBuffer buffer, int byteOffset)
Create aFloat32Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing to the end of the buffer (which must be an integral number of elements).- Parameters:
buffer
- underlyingArrayBuffer
byteOffset
- byte offset from the start ofbuffer
- Returns:
- an
Float32Array
instance
-
createFloat32Array
public static Float32Array createFloat32Array(ArrayBuffer buffer, int byteOffset, int length)
Create aFloat32Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing forlength
elements.- Parameters:
buffer
- underlyingArrayBuffer
byteOffset
- byte offset from the start ofbuffer
length
- number of elements in the resulting array- Returns:
- an
Float32Array
instance
-
createFloat32Array
public static Float32Array createFloat32Array(int length)
- Parameters:
length
- size of array- Returns:
- a
Float32Array
instance
-
createFloat64Array
public static Float64Array createFloat64Array(ArrayBuffer buffer)
Create aFloat64Array
instance 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
Float64Array
instance
-
createFloat64Array
public static Float64Array createFloat64Array(ArrayBuffer buffer, int byteOffset)
Create aFloat64Array
instance onbuffer
, starting atbyteOffset
into 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
- underlyingArrayBuffer
byteOffset
- byte offset from the start ofbuffer
- Returns:
- an
Float64Array
instance
-
createFloat64Array
public static Float64Array createFloat64Array(ArrayBuffer buffer, int byteOffset, int length)
Create aFloat64Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing forlength
elements.Note that Safari does not currently support Float64 Arrays!
- Parameters:
buffer
- underlyingArrayBuffer
byteOffset
- byte offset from the start ofbuffer
length
- number of elements in the resulting array- Returns:
- an
Float64Array
instance
-
createFloat64Array
public static Float64Array createFloat64Array(int length)
Create aFloat64Array
instance oflength
elements, backed by a newArrayBuffer
.Note that Safari does not currently support Float64 Arrays!
- Parameters:
length
- size of array- Returns:
- a
Float64Array
instance
-
createInt16Array
public static Int16Array createInt16Array(ArrayBuffer buffer)
Create aInt16Array
instance 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
Int16Array
instance
-
createInt16Array
public static Int16Array createInt16Array(ArrayBuffer buffer, int byteOffset)
Create aInt16Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing to the end of the buffer (which must be an integral number of elements).- Parameters:
buffer
- underlyingArrayBuffer
byteOffset
- byte offset from the start ofbuffer
- Returns:
- an
Int16Array
instance
-
createInt16Array
public static Int16Array createInt16Array(ArrayBuffer buffer, int byteOffset, int length)
Create aInt16Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing forlength
elements.- Parameters:
buffer
- underlyingArrayBuffer
byteOffset
- byte offset from the start ofbuffer
length
- number of elements in the resulting array- Returns:
- an
Int16Array
instance
-
createInt16Array
public static Int16Array createInt16Array(int length)
- Parameters:
length
- size of array- Returns:
- a
Int16Array
instance
-
createInt32Array
public static Int32Array createInt32Array(ArrayBuffer buffer)
Create aInt32Array
instance 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
Int32Array
instance
-
createInt32Array
public static Int32Array createInt32Array(ArrayBuffer buffer, int byteOffset)
Create aInt32Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing to the end of the buffer (which must be an integral number of elements).- Parameters:
buffer
- underlyingArrayBuffer
byteOffset
- byte offset from the start ofbuffer
- Returns:
- an
Int32Array
instance
-
createInt32Array
public static Int32Array createInt32Array(ArrayBuffer buffer, int byteOffset, int length)
Create aInt32Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing forlength
elements.- Parameters:
buffer
- underlyingArrayBuffer
byteOffset
- byte offset from the start ofbuffer
length
- number of elements in the resulting array- Returns:
- an
Int32Array
instance
-
createInt32Array
public static Int32Array createInt32Array(int length)
- Parameters:
length
- size of array- Returns:
- a
Int32Array
instance
-
createInt8Array
public static Int8Array createInt8Array(ArrayBuffer buffer)
Create aInt8Array
instance onbuffer
, starting at starting at the beginning of the buffer and continuing to the end.- Parameters:
buffer
- underlyingArrayBuffer
- Returns:
- an
Int8Array
instance
-
createInt8Array
public static Int8Array createInt8Array(ArrayBuffer buffer, int byteOffset)
Create aInt8Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing to the end of the buffer (which must be an integral number of elements).- Parameters:
buffer
- underlyingArrayBuffer
byteOffset
- byte offset from the start ofbuffer
- Returns:
- an
Int8Array
instance
-
createInt8Array
public static Int8Array createInt8Array(ArrayBuffer buffer, int byteOffset, int length)
Create aInt8Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing forlength
elements.- Parameters:
buffer
- underlyingArrayBuffer
byteOffset
- byte offset from the start ofbuffer
length
- number of elements in the resulting array- Returns:
- an
Int8Array
instance
-
createInt8Array
public static Int8Array createInt8Array(int length)
- Parameters:
length
- size of array- Returns:
- a
Int8Array
instance
-
createUint16Array
public static Uint16Array createUint16Array(ArrayBuffer buffer)
Create aUint16Array
instance 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
Uint16Array
instance
-
createUint16Array
public static Uint16Array createUint16Array(ArrayBuffer buffer, int byteOffset)
Create aUint16Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing to the end of the buffer (which must be an integral number of elements).- Parameters:
buffer
- underlyingArrayBuffer
byteOffset
- byte offset from the start ofbuffer
- Returns:
- an
Uint16Array
instance
-
createUint16Array
public static Uint16Array createUint16Array(ArrayBuffer buffer, int byteOffset, int length)
Create aUint16Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing forlength
elements.- Parameters:
buffer
- underlyingArrayBuffer
byteOffset
- byte offset from the start ofbuffer
length
- number of elements in the resulting array- Returns:
- an
Uint16Array
instance
-
createUint16Array
public static Uint16Array createUint16Array(int length)
- Parameters:
length
- size of array- Returns:
- a
Uint16Array
instance
-
createUint32Array
public static Uint32Array createUint32Array(ArrayBuffer buffer)
Create aUint32Array
instance 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
Uint32Array
instance
-
createUint32Array
public static Uint32Array createUint32Array(ArrayBuffer buffer, int byteOffset)
Create aUint32Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing to the end of the buffer (which must be an integral number of elements).- Parameters:
buffer
- underlyingArrayBuffer
byteOffset
- byte offset from the start ofbuffer
- Returns:
- an
Uint32Array
instance
-
createUint32Array
public static Uint32Array createUint32Array(ArrayBuffer buffer, int byteOffset, int length)
Create aUint32Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing forlength
elements.- Parameters:
buffer
- underlyingArrayBuffer
byteOffset
- byte offset from the start ofbuffer
length
- number of elements in the resulting array- Returns:
- an
Uint32Array
instance
-
createUint32Array
public static Uint32Array createUint32Array(int length)
- Parameters:
length
- size of array- Returns:
- a
Uint32Array
instance
-
createUint8Array
public static Uint8Array createUint8Array(ArrayBuffer buffer)
Create aUint8Array
instance 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
Uint8Array
instance
-
createUint8Array
public static Uint8Array createUint8Array(ArrayBuffer buffer, int byteOffset)
Create aUint8Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing to the end of the buffer.- Parameters:
buffer
- underlyingArrayBuffer
byteOffset
- byte offset from the start ofbuffer
- Returns:
- an
Uint8Array
instance
-
createUint8Array
public static Uint8Array createUint8Array(ArrayBuffer buffer, int byteOffset, int length)
Create aUint8Array
instance onbuffer
, starting atbyteOffset
into the buffer, continuing forlength
elements.- Parameters:
buffer
- underlyingArrayBuffer
byteOffset
- byte offset from the start ofbuffer
length
- number of elements in the resulting array- Returns:
- an
Uint8Array
instance
-
createUint8Array
public static Uint8Array createUint8Array(int length)
- Parameters:
length
- size of array- Returns:
- a
Uint8Array
instance
-
createUint8ClampedArray
public static Uint8ClampedArray createUint8ClampedArray(ArrayBuffer buffer)
Create aUint8ClampedArray
instance onbuffer
, starting at starting at the beginning of the buffer and continuing to the end.- Parameters:
buffer
- underlyingArrayBuffer
- Returns:
- an
Uint8ClampedArray
instance
-
createUint8ClampedArray
public static Uint8ClampedArray createUint8ClampedArray(ArrayBuffer buffer, int byteOffset)
Create aUint8ClampedArray
instance onbuffer
, starting atbyteOffset
into the buffer, continuing to the end of the buffer.- Parameters:
buffer
- underlyingArrayBuffer
byteOffset
- byte offset from the start ofbuffer
- Returns:
- an
Uint8ClampedArray
instance
-
createUint8ClampedArray
public static Uint8ClampedArray createUint8ClampedArray(ArrayBuffer buffer, int byteOffset, int length)
Create aUint8ClampedArray
instance onbuffer
, starting atbyteOffset
into the buffer, continuing forlength
elements.- Parameters:
buffer
- underlyingArrayBuffer
byteOffset
- byte offset from the start ofbuffer
length
- number of elements in the resulting array- Returns:
- an
Uint8ClampedArray
instance
-
createUint8ClampedArray
public static Uint8ClampedArray createUint8ClampedArray(int length)
- Parameters:
length
- size of array- Returns:
- a
Uint8ClampedArray
instance
-
isSupported
public static boolean isSupported()
Check if the current environment supports typed arrays. Behavior of the variouscreateXXX
methods is undefined if this method returnsfalse
, but will typically throw some exception.- Returns:
- true if typed arrays are support.
-
-