ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Something strange about getFirstChild and getParent methods

Post new topic  Reply to topic
 Something strange about getFirstChild and getParent methods « View previous topic :: View next topic » 
Author Message
Irena
PostPosted: Sun Mar 10, 2002 5:34 am    Post subject: Reply with quote

Novice

Joined: 03 Feb 2002
Posts: 11
Location: IBM

I have the following function which gets an MbElement & traverses the path from this element to its first child, then to the first child of the first child & so on, till the leaf & then goes back to the same element.

public static void testfun1 (MbElement elem) {
try {
MbElement e = elem;
int i= 0;
while (e != null) {
print ("testfun1 " + i++ + " - " + e.getName ());
if (e.getFirstChild () == null)
break;
e = e.getFirstChild ();
}
while (e != null) {
print ("testfun1 " + --i + " - " + e.getName ());
if (<CONDITION>) {
print ("testfun1 condition true");
break;
}
e = e.getParent ();
}
print ("");
}
catch (MbException e) {
print ("MbException: " + e);
}
}

I try 3 different conditions instead of <CONDITION>:
1. e.getName ().equals (elem.getName ())
2. e == elem
3. e.equals (elem)

Here are the 3 corresponding outputs:
testfun1 0 - MRM
testfun1 1 - PROLOG
testfun1 2 - MESSAGETYPE
testfun1 2 - MESSAGETYPE
testfun1 1 - PROLOG
testfun1 0 - MRM
testfun1 condition true

testfun2 0 - MRM
testfun2 1 - PROLOG
testfun2 2 - MESSAGETYPE
testfun2 2 - MESSAGETYPE
testfun2 1 - PROLOG
testfun2 0 - MRM
testfun2 -1 - Root

testfun3 0 - MRM
testfun3 1 - PROLOG
testfun3 2 - MESSAGETYPE
testfun3 2 - MESSAGETYPE
testfun3 1 - PROLOG
testfun3 0 - MRM
testfun3 -1 - Root

It turns out, that "==" & "equals" return false when I compare the "MRM" element with itself & only the name comparison returns true.

Could anybody explain this strange phenomenon ? Even if a new MbElement object is allocated upon each call (which explains why "==" does not work), why does the "equals" not work ?

If I rename an element do I have any way to find it again ?

Thank you,
Irena.
Back to top
View user's profile Send private message Send e-mail
kolban
PostPosted: Sun Mar 10, 2002 7:04 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2001
Posts: 1072
Location: Fort Worth, TX, USA

See the is() method of the MbNode.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Something strange about getFirstChild and getParent methods
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.