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)
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 ?
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