public final class Array extends Object
This class should contain only static methods or fields.
Modifier and Type | Method and Description |
---|---|
static Object |
ensureNotNull(Object array) |
static Object |
initMultidimensionalArray(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 |
initUnidimensionalArray(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 |
setCheck(Object array,
int index,
Object value)
Performs an array assignment, after validating the type of the value being
stored.
|
static Object |
stampJavaTypeInfo(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 <T> T[] |
stampJavaTypeInfo(Object array,
T[] referenceType) |
public static <T> T[] stampJavaTypeInfo(Object array, T[] referenceType)
public static Object initUnidimensionalArray(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 initMultidimensionalArray(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 stampJavaTypeInfo(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 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.