Class Uint8ArrayNative

All Implemented Interfaces:
ArrayBufferView, Uint8Array, Uint8ClampedArray

public final class Uint8ArrayNative extends ArrayBufferViewNative implements Uint8ClampedArray
JS native implementation of Uint8Array and, where natively supported, Uint8ClampedArray.

This should generally not be referenced directly -- see TypedArrays and JsUtils.

  • Constructor Details

    • Uint8ArrayNative

      protected Uint8ArrayNative()
  • Method Details

    • create

      public static Uint8ArrayNative create(ArrayBuffer buffer)
      Create a Uint8Array instance.
      Parameters:
      buffer -
      Returns:
      a Uint8Array instance
    • create

      public static Uint8ArrayNative create(ArrayBuffer buffer, int byteOffset)
      Create a Uint8Array instance.
      Parameters:
      buffer -
      byteOffset -
      Returns:
      a Uint8Array instance
    • create

      public static Uint8ArrayNative create(ArrayBuffer buffer, int byteOffset, int length)
      Create a Uint8Array instance.
      Parameters:
      buffer -
      byteOffset -
      length -
      Returns:
      a Uint8Array instance
    • create

      public static Uint8ArrayNative create(int length)
      Create a Uint8Array instance.
      Parameters:
      length -
      Returns:
      a Uint8Array instance
    • create

      public static Uint8ArrayNative create(int[] array)
      Create a Uint8Array instance from an array.
      Parameters:
      array - an array of initial values
      Returns:
      a Uint8Array instance
    • create

      public static Uint8ArrayNative create(JavaScriptObject array)
      Create a Uint8Array instance from a JavaScript array-like object.
      Parameters:
      array - a JS array or array-like object
      Returns:
      a Uint8Array instance
    • create

      public static Uint8ArrayNative create(short[] array)
      Create a Uint8Array instance from an array.
      Parameters:
      array - an array of initial values
      Returns:
      a Uint8Array instance
    • createClamped

      public static Uint8ArrayNative createClamped(ArrayBuffer buffer)
      Create a Uint8ClampedArray instance. Must only be called if the environment natively supports clamped arrays -- otherwise Uint8ClampedArrayNativeEmul should be used instead.
      Parameters:
      buffer -
      Returns:
      a Uint8Array instance
    • createClamped

      public static Uint8ArrayNative createClamped(ArrayBuffer buffer, int byteOffset)
      Create a Uint8ClampedArray instance. Must only be called if the environment natively supports clamped arrays -- otherwise Uint8ClampedArrayNativeEmul should be used instead.
      Parameters:
      buffer -
      byteOffset -
      Returns:
      a Uint8Array instance
    • createClamped

      public static Uint8ArrayNative createClamped(ArrayBuffer buffer, int byteOffset, int length)
      Create a Uint8ClampedArray instance. Must only be called if the environment natively supports clamped arrays -- otherwise Uint8ClampedArrayNativeEmul should be used instead.
      Parameters:
      buffer -
      byteOffset -
      length -
      Returns:
      a Uint8Array instance
    • createClamped

      public static Uint8ArrayNative createClamped(int length)
      Create a Uint8ClampedArray instance. Must only be called if the environment natively supports clamped arrays -- otherwise Uint8ClampedArrayNativeEmul should be used instead.
      Parameters:
      length -
      Returns:
      a Uint8Array instance
    • createClamped

      public static Uint8ArrayNative createClamped(int[] array)
      Create a Uint8Array instance from an array. Must only be called if the environment natively supports clamped arrays -- otherwise Uint8ClampedArrayNativeEmul should be used instead.
      Parameters:
      array - an array of initial values
      Returns:
      a Uint8Array instance
    • createClamped

      public static Uint8ArrayNative createClamped(JavaScriptObject array)
      Create a Uint8ClampedArray instance from a JavaScript array-like object. Must only be called if the environment natively supports clamped arrays -- otherwise Uint8ClampedArrayNativeEmul should be used instead.
      Parameters:
      array - a JS array or array-like object
      Returns:
      a Uint8ClampedArray instance
    • createClamped

      public static Uint8ArrayNative createClamped(short[] array)
      Create a Uint8Array instance from an array. Must only be called if the environment natively supports clamped arrays -- otherwise Uint8ClampedArrayNativeEmul should be used instead.
      Parameters:
      array - an array of initial values
      Returns:
      a Uint8Array instance
    • get

      public short get(int index)
      Description copied from interface: Uint8Array
      Retrieve one element of this view.
      Specified by:
      get in interface Uint8Array
      Parameters:
      index -
      Returns:
      the requested element, 0-255
    • length

      public int length()
      Description copied from interface: Uint8Array
      The length in elements of this view.
      Specified by:
      length in interface Uint8Array
      Returns:
      non-negative length
    • set

      public void set(int index, int value)
      Description copied from interface: Uint8Array
      Set one element in this view.
      Specified by:
      set in interface Uint8Array
      Parameters:
      index -
      value -
    • set

      public void set(int[] array)
      Description copied from interface: Uint8Array
      Set multiple elements in this view from an array, storing starting at 0.
      Specified by:
      set in interface Uint8Array
      Parameters:
      array -
    • set

      public void set(int[] array, int offset)
      Description copied from interface: Uint8Array
      Set multiple elements in this view from an array, storing starting at the requested offset.
      Specified by:
      set in interface Uint8Array
      Parameters:
      array -
      offset -
    • set

      public void set(short[] array)
      Description copied from interface: Uint8Array
      Set multiple elements in this view from an array, storing starting at 0.
      Specified by:
      set in interface Uint8Array
      Parameters:
      array -
    • set

      public void set(short[] array, int offset)
      Description copied from interface: Uint8Array
      Set multiple elements in this view from an array, storing starting at the requested offset.
      Specified by:
      set in interface Uint8Array
      Parameters:
      array -
      offset -
    • set

      public void set(Uint8Array array)
      Description copied from interface: Uint8Array
      Set multiple elements in this view from another view, storing starting at 0.
      Specified by:
      set in interface Uint8Array
      Parameters:
      array -
    • set

      public void set(Uint8Array array, int offset)
      Description copied from interface: Uint8Array
      Set multiple elements in this view from another view, storing starting at the requested offset.
      Specified by:
      set in interface Uint8Array
      Parameters:
      array -
      offset -
    • subarray

      public Uint8ArrayNative subarray(int begin)
      Description copied from interface: Uint8ClampedArray
      Create a new view from the same array, from offset to the end of this view. These offset is clamped to legal indices into this view, so it is not an error to specify an invalid index.
      Specified by:
      subarray in interface Uint8Array
      Specified by:
      subarray in interface Uint8ClampedArray
      Parameters:
      begin - offset into this view if non-negative; if negative, an index from the end of this view
      Returns:
      a new Uint8ClampedArray instance
    • subarray

      public Uint8ArrayNative subarray(int begin, int end)
      Description copied from interface: Uint8ClampedArray
      Create a new view from the same array, from offset to (but not including) end in this view. These indices are clamped to legal indices into this view, so it is not an error to specify invalid indices.
      Specified by:
      subarray in interface Uint8Array
      Specified by:
      subarray in interface Uint8ClampedArray
      Parameters:
      begin - offset into this view if non-negative; if negative, an index from the end of this view
      end - offset into this view if non-negative; if negative, an index from the end of this view
      Returns:
      a new Uint8ClampedArray instance