|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Traverse Environment Tree using Java Compute Node |
« View previous topic :: View next topic » |
Author |
Message
|
gaurav.udgir |
Posted: Thu May 21, 2009 6:23 am Post subject: Traverse Environment Tree using Java Compute Node |
|
|
Apprentice
Joined: 18 May 2009 Posts: 32
|
Hi All,
I would like to traverse a Environment Tree using a Java Compute Node and need to access the values in the code. I will be getting a structure like
Field1
subfield1
subfield2
...
subfieldn
Field2
subfield1
subfield2
...
subfieldn
I will not get how many number of sub-fields will be present in each field type record. I need to calculate these number of subfields under each Field. If some one is having some sample code or any hints, please help.
Regards,
Gaurav |
|
Back to top |
|
 |
Vitor |
Posted: Thu May 21, 2009 6:28 am Post subject: Re: Traverse Environment Tree using Java Compute Node |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
gaurav.udgir wrote: |
any hints, please help. |
Look at this the same way you would if it was a message structure.
It's straightforward to move through an unknown number of children in a tree (well it is in ESQL, Java who knows? Not me! ). Just go round the siblings until you run out.
Someone who knows Java may be able to offer actual code. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Thu May 21, 2009 7:01 am Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
As Vitor says, you can use getFirstChild() and getNextSibling() to navigate the tree.
Examples of these methods are shown below:
Code: |
MbMessage message = assembly.getGlobalEnvironment();
MbElement element = message.getRootElement();
MeElement child = element.getFirstChild();
MbElement sibling = element.getNextSibling();
|
It should be easy for you to then navigate the tree by putting these lines into a recursive method and adding some base case checks in there.
I've done this in ESQL before... have you considering doing it in ESQL? I think it will perform better for you (if you are just doing trivial tree navigation). |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|