From: Xuân B. <xua...@ba...> - 2008-03-11 09:37:43
|
Conal Tuohy wrote: > On Tue, 2008-03-11 at 16:39 +1300, Xuân Baldauf wrote: > > >> If I remember correctly, I think >> http://tm4j.cvs.sourceforge.net/tm4j/tm4j/src/org/tm4j/topicmap/tmdm/tm4j1/TopicMapObjectImpl.java?revision=1.5&view=markup#l_126 is the reason for equalsByID(). This provider is a bridge between XML Topic Maps (in the style of TM4J 0.9.x) and TMDM (in the style of TM4J2). TMDM in general, and the TM4J2-implementation of TMDM in particular, does not require a TopicMapObject to have exactly one ID. Consequently, getID() is not defined, strictly speaking. If getID() is called anyways, some compatibility magic auto-creates an ID if no ID cannot be found or somehow inferred. However, this is a kludge (as a read-only method has a state-changing behaviour), and should be avoided, especially if the only purpose of calling getID() is comparing whether two TopicMapObjects are equal in some sense (which should be read-only-process in turn). You do not want to have an OutOfMemoryError just because you called getID(). >> > > Why not just use the equals() method then, Xuan? > Personally, I do not care about the name. However, care should be taken because we have multiple notions of equality in topic maps and in TM4J (like: Are two Topic objects, which are merged, equal? Are two Topic objects, which are not yet merged, but should be merged, equal?). > Isn't that the purpose of equalsByID()? > Maybe, maybe not. The purpose of equalsByID() is "If I would take the IDs of the two topic map items involved and compare them, would that comparison yield true?". Whether this definition happens to be equivalent or not to other definitions of equality: I do not know, and this is out of the scope of equalsByID(), and this is because I chose "equalsByID()" as name and not "equals()". > Or is there some difference in semantics between equals() and > equalsByID()? > Depends on the intended semantics of equals() and, as they do not seem to be defined currently (like equals() is not overriden), a difference between equals() and equalsByID() is also not defined. ciao, Xuân. P.S.: If you happen to be in Auckland in the next months, then just drop me a note, then we can meet in person. :-) |