Author |
Message
|
SOLOHERO |
Posted: Tue Sep 01, 2009 10:10 pm Post subject: encoding in javaCompute |
|
|
Centurion
Joined: 01 Feb 2007 Posts: 107
|
Sorry this might be a double post......
i got another problem here....in setting the encoding and ccsid in MQMD.
As u guys know they are type int.
how can i set a value to those fields..
if i am using the below statement it wont allow cause set value will take only string and i can see the value getting changed in the mqmd--encoding but when validating it throws cast exception.
note encoding is user defined value....
MbElement encod = outMessage.getRootElement().getFirstElementByPath("Properties/Encoding");
encod.setValue(encoding);
i tried using setSpecificType()..after parsing encoding to int but i cant see anyvalue .being set to encoding fied ...could some one guide me how and where am i going wrong..
MbElement encod = outMessage.getRootElement().getFirstElementByPath("Properties/Encoding");
encod.setSpecificType(encoding); _________________ Thanks |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Wed Sep 02, 2009 12:47 am Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
The setValue method takes an object as its parameter.
What happens if you make an Integer object out of the int primitive and pass this to the setValue method? |
|
Back to top |
|
 |
gs |
Posted: Wed Sep 02, 2009 12:48 am Post subject: |
|
|
 Master
Joined: 31 May 2007 Posts: 254 Location: Sweden
|
setValue actually takes an object as argument.
Code: |
MbElement ccsid = outMessage.getRootElement().getFirstElementByPath("MQMD/CodedCharSetId");
Integer charset = 1208;
ccsid.setValue(charset);
|
If you want to modify the MQMD, use that element instead of Properties as in your code. |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Wed Sep 02, 2009 12:51 am Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
gs wrote: |
Integer charset = 1208;
|
Should this not be:
Integer charset = new Integer(1208);
?
And a quick sanity check from the OP, why are you doing all this in Java? If you're doing simple transformations then ESQL will probably be easier and more efficient. |
|
Back to top |
|
 |
gs |
Posted: Wed Sep 02, 2009 1:03 am Post subject: |
|
|
 Master
Joined: 31 May 2007 Posts: 254 Location: Sweden
|
WMBDEV1 wrote: |
gs wrote: |
Integer charset = 1208;
|
Should this not be:
Integer charset = new Integer(1208);
?
|
Yes, I was lazy and used autoboxing Using the constructor is definitely better from a strict perspective. |
|
Back to top |
|
 |
SOLOHERO |
Posted: Wed Sep 02, 2009 4:29 pm Post subject: |
|
|
Centurion
Joined: 01 Feb 2007 Posts: 107
|
Thanks guys....i dont know why i was thinking it is string................ _________________ Thanks |
|
Back to top |
|
 |
|