cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Passing list of params from Java to ACL

kristian.vantas
1-Newbie

Passing list of params from Java to ACL

Hi adepters,

I'm trying to pass off a list of parameters from java to an acl function. The acl function expects the list of params like so:

function myFunction(filename, params[]) {
...
if(define (params["Param1"]) {
# do something
}
...
}

My java method call looks like this:

Acl.func("myAcl::myFunction",filename);

I'm a beginner/novice with Acl, so I don't understand how to pass off the params. Here's some of my ideas but I haven't tried the right variation yet that works:

Acl.func("myAcl::myFunction",filename,"Param1=MyValue,Param2=MyValue");
Acl.func("myAcl::myFunction",filename, "-Param1 MyValue", "-Param2 MyValue");
Acl.func("myAcl::myFunction",filename, "Param1('MyValue'), Param2('MyValue')");
Acl.func("myAcl::myFunction",filename, "MyValue", "MyValue");

Thanks in advance!

1 REPLY 1

Hi Kristian--



You could rewrite myFunction to take the list of params as a delimited
string (somewhat like what you tried in your first "Acl.func" call). You
would then have to convert the delimited list to the desired array in
the function. It would look something like this:



function myFunction(filename, paramlist) {

# split up params into proper array

local param_entries[], params[], tokens[];

split(paramlist, param_entries, ",");

for (p in param_entries) {

split(param_entries[p],tokens,"=");

params[tokens[1]] = tokens[2];

}



# now do whatever you want with params array

...

}



If you are pulling the array from ACL (as opposed to pushing it from
Java), you can use the java_array_to_acl() function to convert a Java
array (or Map or List) to the corresponding ACL object. For example, if
you have a java method DOMhandler.getAllElements() that returns an
array, you can convert it to ACL by doing something like this (in ACL):



function checkElements(doc) {

# create Java object, equivalent to "new DOMhandler(doc)"

local handler = java_constructor("DOMhandler", Acl.DOMDocument(doc));

# call getAllElements method and store reference to the Java array it
returns

local jarray = java_instance(handler, "getAllElements");

# convert Java array to ACL array

local aclarray[];

java_array_to_acl(jarray, aclarray);

...

}



Also, there is a discussion of Java and ACL arrays in the online help
topic "Java and ACL". Type "help 1381" on the command line in Arbortext
to see this topic.



--Clay



Clay Helberg

Senior Consultant

TerraXML


Top Tags