java_array_from_acl
java_array_from_acl (arr, descriptor)
This function converts the ACL array arr to a Java object and returns the Java object. The class of the Java object is specified by the descriptor.
The arr is an ACL array. It can be a normal array or an associative array, depending on the value of the descriptor.
The descriptor is either a fully-qualified class name, such as java.util.HashMap, or a class descriptor, such as java/util/HashMap or [I. The class descriptor follows Sun's Java Native Interface Specification. descriptor must be the name or the descriptor of one of the following classes:
• A class that implements the java.util.Map interface. For example:
java.util.HashMap
java.util.HashTable
The arr must be an ACL associative array. After the conversion, both the key and the value of each element in the newly created Java Map object will be Java String objects.
• A class that implements the java.util.List interface. For example:
java.util.ArrayList
java.util.Vector
The arr must be an ACL normal array. After the conversion, each element in the newly created Java List object will be a Java String object.
• A one dimensional primitive type array. The arr must be an ACL normal array.
Class descriptors for primitive type arrays are:
boolean
|
[Z
|
byte
|
[B
|
char
|
[C
|
short
|
[S
|
int
|
[I
|
long
|
[L
|
float
|
[F
|
double
|
[D
|
• A one dimensional String array.
The class descriptor for the Java String array is:
[Ljava/lang/String;
This function returns the newly created Java object. It returns 0 if the array conversion failed.
local arr[];
# Create an ACL associative array
arr["cereal"] = "breakfast";
arr["steak"] = "dinner";
# Convert the ACL array to a HashMap object
local obj = java_array_from_acl(arr, "java/util/HashMap");
if (obj != 0) {
# Get the size of this HashMap object
response("size = " . java_instance(obj, "size"));
java_delete(obj);
}
Related Topics