From: Conal T. <con...@vu...> - 2008-03-13 00:54:36
|
On Tue, 2008-03-11 at 22:36 +1300, Xuân Baldauf wrote: > 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&amp;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?". What does "equals by ID" mean in the case of TMDM topic maps in which objects may have multiple ids? Would the comparison require that the two topic map items had at least one item identifier in common? > 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()". OK. I think it would be good to actually determine the existing semantics of equals() (in the existing providers), and if this is compatible with the requirements of equalsByID() (or can easily be made so), to use the name "equals" rather than "equalsByID". > > 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. :-) I don't get up there much, but you never know; I might well be. When are you planning to be in Auckland? -- Conal Tuohy New Zealand Electronic Text Centre www.nzetc.org |