public final class Array extends Object
This class should contain only static methods or fields.
Modifier and Type | Method and Description |
---|---|
static <T> T[] |
clone(T[] array)
Creates a copy of the specified array.
|
static <T> T[] |
cloneSubrange(T[] array,
int fromIndex,
int toIndex)
Creates a copy of a subrange of the specified array.
|
static <T> T[] |
createFrom(T[] array)
Creates a new array of the exact same type and length as a given array.
|
static <T> T[] |
createFrom(T[] array,
int length)
Creates an empty array of the exact same type as a given array, with the
specified length.
|
static Object |
initDim(Class<?> leafClassLiteral,
JavaScriptObject castableTypeMap,
JavaScriptObject elementTypeId,
int length,
int elementTypeCategory,
int dimensions)
Creates an array like "new T[a][b][c][][]" by passing in a native JSON
array, [a, b, c].
|
static Object |
initDims(Class<?> leafClassLiteral,
JavaScriptObject[] castableTypeMapExprs,
JavaScriptObject[] elementTypeIds,
int leafElementTypeCategory,
int[] dimExprs,
int count)
Creates an array like "new T[a][b][c][][]" by passing in a native JSON
array, [a, b, c].
|
static Object |
initValues(Class<?> arrayClass,
JavaScriptObject castableTypeMap,
JavaScriptObject elementTypeId,
int elementTypeCategory,
Object array)
Creates an array like "new T[][]{a,b,c,d}" by passing in a native JSON
array, [a, b, c, d].
|
static void |
nativeArraycopy(Object src,
int srcOfs,
Object dest,
int destOfs,
int len)
Copy an array using native Javascript.
|
static void |
nativeArrayInsert(Object src,
int srcOfs,
Object dest,
int destOfs,
int len)
Insert one array into another native Javascript.
|
static Object |
setCheck(Object array,
int index,
Object value)
Performs an array assignment, after validating the type of the value being
stored.
|
public static <T> T[] clone(T[] array)
public static <T> T[] cloneSubrange(T[] array, int fromIndex, int toIndex)
public static <T> T[] createFrom(T[] array)
public static <T> T[] createFrom(T[] array, int length)
public static Object initDim(Class<?> leafClassLiteral, JavaScriptObject castableTypeMap, JavaScriptObject elementTypeId, int length, int elementTypeCategory, int dimensions)
leafClassLiteral
- the class literal for the leaf classcastableTypeMap
- the map of types to which this array can be casted,
in the form of a JSON map objectelementTypeId
- the typeId of array elementselementTypeCategory
- whether the element type is java.lang.Object
(TYPE_JAVA_LANG_OBJECT
), is guaranteed to be a java object
(TYPE_JAVA_OBJECT
), is guaranteed to be a JSO
(TYPE_JSO
), can be either (TYPE_JAVA_OBJECT_OR_JSO
) or
or some primitive type TYPE_PRIMITIVE_BOOLEAN
, TYPE_PRIMITIVE_LONG
or
TYPE_PRIMITIVE_NUMBER
.length
- the length of the arraydimensions
- the number of dimensions of the arraypublic static Object initDims(Class<?> leafClassLiteral, JavaScriptObject[] castableTypeMapExprs, JavaScriptObject[] elementTypeIds, int leafElementTypeCategory, int[] dimExprs, int count)
leafClassLiteral
- the class literal for the leaf classcastableTypeMapExprs
- the JSON castableTypeMap of each dimension,
from highest to lowestelementTypeIds
- the elementTypeId of each dimension, from highest to lowestleafElementTypeCategory
- whether the element type is java.lang.Object
(TYPE_JAVA_LANG_OBJECT
), is guaranteed to be a java object
(TYPE_JAVA_OBJECT
), is guaranteed to be a JSO
(TYPE_JSO
), can be either (TYPE_JAVA_OBJECT_OR_JSO
) or
or some primitive type TYPE_PRIMITIVE_BOOLEAN
, TYPE_PRIMITIVE_LONG
or
TYPE_PRIMITIVE_NUMBER
.dimExprs
- the length of each dimension, from highest to lowerpublic static Object initValues(Class<?> arrayClass, JavaScriptObject castableTypeMap, JavaScriptObject elementTypeId, int elementTypeCategory, Object array)
arrayClass
- the class of the arraycastableTypeMap
- the map of types to which this array can be casted,
in the form of a JSON map objectelementTypeId
- the typeId of array elementselementTypeCategory
- whether the element type is java.lang.Object
(TYPE_JAVA_LANG_OBJECT
), is guaranteed to be a java object
(TYPE_JAVA_OBJECT
), is guaranteed to be a JSO
(TYPE_JSO
), can be either (TYPE_JAVA_OBJECT_OR_JSO
) or
or some primitive type TYPE_PRIMITIVE_BOOLEAN
, TYPE_PRIMITIVE_LONG
or
TYPE_PRIMITIVE_NUMBER
.array
- the JSON array that will be transformed into a GWT arraypublic static void nativeArraycopy(Object src, int srcOfs, Object dest, int destOfs, int len)
src
- source array for copysrcOfs
- offset into source arraydest
- destination array for copydestOfs
- offset into destination arraylen
- number of elements to copypublic static void nativeArrayInsert(Object src, int srcOfs, Object dest, int destOfs, int len)
src
- source array where the data is taken fromsrcOfs
- offset into source arraydest
- destination array for the data to be inserteddestOfs
- offset into destination arraylen
- number of elements to insertpublic static Object setCheck(Object array, int index, Object value)
If the elementTypeCategory is TYPE_JAVA_OBJECT
, this indicates a normal cast check
should be performed, using the elementTypeId as the cast destination type.
JavaScriptObjects cannot be stored in this case.
If the elementTypeId is TYPE_JAVA_LANG_OBJECT
, this is the cast target for the Object
type, in which case all types can be stored, including JavaScriptObject.
If the elementTypeId is TYPE_JSO
, this indicates that only JavaScriptObjects can be
stored.
If the elementTypeId is TYPE_JAVA_OBJECT_OR_JSO
, this indicates that both
JavaScriptObjects, and Java types can be stored. In the case of Java types, a normal cast check
should be performed, using the elementTypeId as the cast destination type.
This case is provided to support arrays declared with an interface type, which has dual
implementations (i.e. interface types which have both Java and JavaScriptObject
implementations).
Attempting to store an object that cannot satisfy the castability check
throws an ArrayStoreException
.
Copyright © 2018. All rights reserved.