|
I have been puzzling over how to wrap the HashMap put method. I successfully (I thought) built prototypes, interfaces and an RPG wrapper to handle the call, but I must be doing something wrong because it is not working. It is returning a null value.
Java Prototypes:
*+++++++++++++++++++++++++++++++
* new_jMap
* Create a new Java Hashmap object
*
* Returns the new Java HashMap object
*+++++++++++++++++++++++++++++++
D new_jMap...
D PR like(jMap)
D ExtProc(*JAVA
D :'java.util.HashMap'
D :*CONSTRUCTOR)
*++++++++++++++++++++++++++++++
* jMap_put
* Add a key and a value to a hashmap
*
*++++++++++++++++++++++++++++++
D JMAP_put...
D PR like(jObject)
D EXTPROC(*JAVA
D :'java.util.HashMap'
D :'put')
D key like(jObject)
D value like(jObject)
And the RPG wrapper prototype:
D rre_jMap_put...
D PR like(jObject)
D prMap like(jMap)
D prKey like(jObject)
D prValue like(jObject)
RPG Wrapper program:
*-------------------------------------------
* Add elements to a Hashmap
*
*-------------------------------------------
P rre_jMap_put...
P B EXPORT
D rre_jMap_put...
D PI like(jObject)
D peMap like(jMap)
D peKey like(jobject)
D peValue like(jObject)
D
/free
peMap = JMAP_put(peMap:peKey:peValue);
return peMap;
/End-free
P E
Finally when I call it in my program (relevant code):
lReParam = new_jMap();
lkey = new_String('selectName');
lvalue = new_String('BALL');
lReParam = rre_jMap_put(lReParam:lkey:lvalue);
The thing that I am uncertain about is that when I code in Java, I act on the object directly rather than passing it back and forth (it may be a shorthand way, I don't know). So in Java I would do this:
HashMap reportParameters = new HashMap();
reportParameters.put("selectName", "BALL");
But even changing the RPG code above to this:
lReParam = new_jMap();
lkey = new_String('selectName');
lvalue = new_String('BALL');
rre_jMap_put(lReParam:lkey:lvalue);
Has the same result which is a null value for the key/value pair.
I am missing something. Any suggestions?
Thanks,
Pete
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.