access a Dictionary in Java

Support/help with CloverETL (4.9) and CloverDX (5.0 or newer) implementation problems

CloverDM
Posts: 12
Joined: Wed Jan 27, 2016 12:22 pm

access a Dictionary in Java

Postby CloverDM » Wed Jan 27, 2016 12:29 pm

I am very new to the Clover

How to set a Value in a Dictionary which type is a Map.

How can i insert a key say ''retry" and the value into it , I am using JavaCustomComponent ,

How can i do it in Java ?

Thanks,

imriskal
Posts: 397
Joined: Wed Aug 15, 2012 8:18 am

Re: access a Dictionary in Java

Postby imriskal » Wed Feb 03, 2016 11:07 am

Hi,

The common syntax in CTL would look like this:

Code: Select all

dictionary.myEntry["retry"] = "myValue";

When you type this into a CTL editor, you have an option to convert your CTL code into Java code, see the screenshot.
convert.png
convert.png (31.04 KiB) Viewed 2713 times

Converting the CTL code above, you will get the following:

Code: Select all

java.util.Map<java.lang.String,java.lang.String> tmpVar0 = CTLUtils.toMap(getGraph().getDictionary().getValue("myEntry"), java.lang.String.class);

boolean tmpVar1 = false;

if (tmpVar0 == null) {
   tmpVar0 = new java.util.LinkedHashMap<java.lang.String,java.lang.String>();
   tmpVar1 = true;
}

tmpVar0.put("retry", "myValue");

if (tmpVar1) {
   getGraph().getDictionary().setValue("myEntry", tmpVar0);
}

Hope this helps.
---
Lubos Imriska
CloverCARE Support
CloverDX

Visit us online at http://www.cloverdx.com

CloverDM
Posts: 12
Joined: Wed Jan 27, 2016 12:22 pm

Re: access a Dictionary in Java

Postby CloverDM » Wed Feb 10, 2016 5:35 pm

:) Thanks ,really helped.


cron