Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 10473

Re: extract data from hash map for target structure mapping

$
0
0

Hi Mike,

 

I just tried a sample of your code and I got a compiler error for the UDF that builds the HashMap:

GlobalContainer globalContainer1 = container.getGlobalContainer();
AbstractTrace trace = container.getTrace();
HashMap<String, ArrayList<String>> matTuple =  new HashMap<String, ArrayList<String>>();
ArrayList<String> valSetOne = new ArrayList<String>();
valSetOne.add("Apple");  matTuple.put("A", valSetOne);    trace.addInfo("executed get" + valSetOne[0]);     globalContainer1.setParameter("matmap", matTuple); 
return"";

The code in line 09 is invalid because you cannot reference a String value in an ArrayList<String> like you can with a regular array... you have to use valSetOne.get(0) instead.  Also instead of having return ""; in the last line I would change that for result.addValue(""); I used that code and it works. The last thing I did was remove the setup of the trace object in line 02 since it should be working with this below.  Here is the buildMap code I used that worked in my system:

GlobalContainer globalContainer1 = container.getGlobalContainer();
HashMap<String, ArrayList<String>> matTuple =  new HashMap<String, ArrayList<String>>();
ArrayList<String> valSetOne = new ArrayList<String>();
valSetOne.add("Apple");
matTuple.put("A", valSetOne);
globalContainer1.setParameter("matmap", matTuple);
result.addValue("");

 

 

Regards,

Ryan Crosby


Viewing all articles
Browse latest Browse all 10473

Trending Articles