How can I use qie.debug to see the values in a Java array?

0 votes
asked Jul 15, 2013 by rich-c-2789 (16,180 points)

How can I use qie.debug to see the values in a Java array?  I basically want to print the Java array and see a string representation of the array so that the values are readable.  Instead it looks something like this: 



1 Answer

+1 vote
Best answer


First, to provide clarity notice in the code below that there are three different variables.  The first is a java.util.ArrayList, the second is a Java array and the third is a JavaScript array.

var ArrayList = java.util.ArrayList;
var Arrays = java.util.Arrays;

var javaArrayList = new ArrayList();

var testMessage = qie.parseHL7String('MSH||\nRWC|1|text\nRWC|2|to\nRWC|3|test');
var javaArray = testMessage.getAllNodes('RWC-2'); //getAllNodes returns a Java String array (String[]).

var javasciptArray = ['123', '456', '951', 'Fish', 'Goat', 'Possum'];

qie.debug('The variable javaArrayList contains: ' + javaArrayList);
qie.debug('The variable javaArray contains: ' + Arrays.toString(javaArray));
qie.debug('The variable javasciptArray contains: ' + javasciptArray);

Second, note that we first needed access to the Arrays class. Next simply wrap the javaArray to be converted to a string in Arrays.toString().

The javaArrayList and javasciptArray do not need this special treament.  They are automatically convert to a string when the are concatenated to a string using the "+" operator.


answered Jul 15, 2013 by rich-c-2789 (16,180 points)
selected Dec 17, 2013 by ron-s-6919