Author |
Message
|
christian witschel |
Posted: Sat Sep 15, 2007 12:39 am Post subject: Java Equivalent of SET OutputRoot.MQRFH2.usr = null; |
|
|
Apprentice
Joined: 07 Dec 2005 Posts: 27
|
Hi,
I am looking for the java equivalent of removing a complete part of the logical tree.
in ESQL
SET OutputRoot.MQRFH2.usr = null;
sets usr to null and also removes any children of usr from the tree.
in Java I can do:
refOutput.getFirstElementByPath("/MQRFH2/usr").setValue(null);
but the children remain.
Please do not tell me that to this I need to create a new message and filter out this part of the tree. I also tried googling and searching this forum with no luck.
thanks for your help. |
|
Back to top |
|
 |
jefflowrey |
Posted: Sat Sep 15, 2007 3:42 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
setValue(null) is equivalent to the ESQL
Set ... VALUE = null
And both do exactly what you say - leave the element intact in the tree.
You can detach the MbElement you want. I think you can also just set the MbElement itself to NULL. Either way you need to get a reference to it first as a separate variable
MbElement deleteMe = refOutput.getFirstElementByPath("/MQRFH2/usr");
deleteMe.detach()
or
deleteMe= null;
(not as sure that the later will work). _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
christian witschel |
Posted: Sat Sep 15, 2007 5:19 am Post subject: |
|
|
Apprentice
Joined: 07 Dec 2005 Posts: 27
|
sorry dude,
I just debugged again and found that
Before:
MQRFH2
Version = 2
Format = MQSTR
Encoding = 273
CodedCharSetId = 1208
Flags = 0
NameValueCCSID = 1208
mcd
Type
Msd
Set
Fmt
jms
Dst
Rto
usr
hostdate
hosttime
file
boname
bocount
ControlData
MRM
SET OutputRoot.MQRFH2.usr = null;
After :
MQRFH2
Version = 2
Format = MQSTR
Encoding = 273
CodedCharSetId = 1208
Flags = 0
NameValueCCSID = 1208
mcd
Type
Msd
Set
Fmt
jms
Dst
Rto
MRM
So this line actually does remove all children of usr as well. The java couterpart does not. why? |
|
Back to top |
|
 |
jefflowrey |
Posted: Sat Sep 15, 2007 5:52 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Under the covers, ESQL probably does a few more things when you assign a tree element to NULL.
If you use .detach(), that will remove the element (and consequently all of it's children) from the tree.
It was just a guess, that I wasn't sure would work, that assigning it to NULL in Java would be the equivalent. You could probably achieve the same thing as detach() if you could set the nextSibling of the previous sibling of the usr tree to null.
But detach is a lot simpler. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
mgk |
Posted: Sat Sep 15, 2007 8:22 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Jeff is spot on here.
Under the covers ESQL calls the equivalent of detach when you assign NULL to an element.
Regards,
MGk _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
christian witschel |
Posted: Sun Sep 16, 2007 4:33 am Post subject: |
|
|
Apprentice
Joined: 07 Dec 2005 Posts: 27
|
Thank you very much, doing
MbElemnt m = refOutput.getFirstElementByPath("/MQRFH2/usr");
m.detach();
m = null;
did the trick. |
|
Back to top |
|
 |
|