TopicMapObject

All of the interfaces that represent constructs from the topic map are derived from a single base interface, org.tm4j.topicmap.TopicMapObject. This interface provides the following features:

The ID property of the TopicMapObject is an object identifier which is guarunteed to be session-unique. Storage mechanisms which are backed by a database may also guaruntee that this property value is persistent across sessions, but such persistence is not a requirement of the interface. Typically, the value of this property is generated automatically by the parser as an XTM file is read, however if your application creates new objects in the topic map, you must provide a value for this property.

Note

Note that calling getID on a TopicMapObject instance does not return the value of the id attribute on the XTM element which was parsed to create that instance. It will instead return some internal identifier string which may or may not be related to the original id attribute value. To get the value of the id attribute of the source XTM element, use getSourceLocators as described below.

The sourceLocators property stores the URI(s) of the topic map document element(s) which caused the creation of this object. This attribute may be used to determine the source topic map from which a particular object was created and may further be used as an identifier which will be persistant across multiple sessions, even for the in-memory storage implementation (providing that the URIs of the elements in the topic map file which is parsed to generate the in-memory store are not modified between sessions). This property allows multiple URIs because there are times when standard topic map operations such as merging and the suppression of duplicated names, occurrences and associations can lead to one TM4J object being the result of two or more source elements.

The topicMap property stores a pointer to the org.tm4j.topicmap.TopicMap object which the object is contained within. A TopicMapObject can only be contained in one TopicMap. When a new object is created it will be automatically assigned to the TopicMap from which the parent object came. An object cannot be moved to another TopicMap by changing the value of the topicmap property - the only way to move an object between topic maps is to create a copy of the object in the target topic map and delete it from the source topic map. Copying and deletion operations are described later in this guide (see the section called “Copying Topic Map Objects”).

The property-change listener interface is described in more detail in the section called “Property Change Listeners”.