Class JsArrayUtils

java.lang.Object
com.google.gwt.core.client.JsArrayUtils

public class JsArrayUtils extends Object
Utility class for manipulating JS arrays. These methods are not on other JavaScriptObject subclasses, such as JsArray, because adding new methods might break existing subtypes.
  • Method Details

    • readOnlyJsArray

      public static JsArrayInteger readOnlyJsArray(byte[] array)
      Take a Java array, and produce a JS array that is only used for reading. As this is actually a reference to the original array in prod mode, the source must not be modified while this copy is in use or you will get different behavior between DevMode and prod mode.
      Parameters:
      array - source array
      Returns:
      JS array, which may be a copy or an alias of the input array
    • readOnlyJsArray

      public static JsArrayNumber readOnlyJsArray(double[] array)
      Take a Java array, and produce a JS array that is only used for reading. As this is actually a reference to the original array in prod mode, the source must not be modified while this copy is in use or you will get different behavior between DevMode and prod mode.
      Parameters:
      array - source array
      Returns:
      JS array, which may be a copy or an alias of the input array
    • readOnlyJsArray

      public static JsArrayNumber readOnlyJsArray(float[] array)
      Take a Java array, and produce a JS array that is only used for reading. As this is actually a reference to the original array in prod mode, the source must not be modified while this copy is in use or you will get different behavior between DevMode and prod mode.
      Parameters:
      array - source array
      Returns:
      JS array, which may be a copy or an alias of the input array
    • readOnlyJsArray

      public static JsArrayInteger readOnlyJsArray(int[] array)
      Take a Java array, and produce a JS array that is only used for reading. As this is actually a reference to the original array in prod mode, the source must not be modified while this copy is in use or you will get different behavior between DevMode and prod mode.
      Parameters:
      array - source array
      Returns:
      JS array, which may be a copy or an alias of the input array
    • readOnlyJsArray

      public static JsArrayNumber readOnlyJsArray(long[] array)
      Take a Java array, and produce a JS array that is only used for reading. As this is actually a reference to the original array in prod mode, the source must not be modified while this copy is in use or you will get different behavior between DevMode and prod mode.

      NOTE: long values are not supported in JS, so long emulation is slow and this method assumes that all the values can be safely stored in a double.

      Parameters:
      array - source array - its values are assumed to be in the valid range for doubles -- if the values exceed 2^53, low-order bits will be lost
      Returns:
      JS array, which may be a copy or an alias of the input array
    • readOnlyJsArray

      public static JsArrayInteger readOnlyJsArray(short[] array)
      Take a Java array, and produce a JS array that is only used for reading. As this is actually a reference to the original array in prod mode, the source must not be modified while this copy is in use or you will get different behavior between DevMode and prod mode.
      Parameters:
      array - source array
      Returns:
      JS array, which may be a copy or an alias of the input array
    • readOnlyJsArray

      public static <T extends JavaScriptObject> JsArray<T> readOnlyJsArray(T[] array)
      Take a Java array, and produce a JS array that is only used for reading. As this is actually a reference to the original array in prod mode, the source must not be modified while this copy is in use or you will get different behavior between DevMode and prod mode.
      Parameters:
      array - source array
      Returns:
      JS array, which may be a copy or an alias of the input array