org.tmapi.core
Interface TopicMapObject

All Known Subinterfaces:
Association, AssociationRole, Occurrence, ScopedObject, Topic, TopicMap, TopicName, Variant

public interface TopicMapObject

The base class for all objects in the TMAPI system which represent constructs in a topic map.

Every TopicMapObject may be created from any number of input sources (typically markup in some topic map interchange format), each of which may have a separate address. In addition, the TMAPI TopicMapObject may "wrap" one or more objects in an underlying topic map processing system.


Method Summary
 void addSourceLocator(Locator sourceLocator)
          Adds a Locator to the set of source locators for this object.
 boolean equals(java.lang.Object o)
          Returns true if the other object is equal to this one.
 java.lang.String getObjectId()
          Returns a topic map-specific identifier for this object.
 java.util.Set getSourceLocators()
          Returns the set of source locators for this object.
 TopicMap getTopicMap()
          Returns the topic map to which this object belongs.
 int hashCode()
          Returns the hashcode of the topic map object's object id
 void remove()
          Removes the object from its container.
 void removeSourceLocator(Locator sourceLocator)
          Removes a Locator from the set of source locators for this object.
 

Method Detail

getTopicMap

public TopicMap getTopicMap()
Returns the topic map to which this object belongs. If the object is an instance of the TopicMap interface, then it should return itself.

Returns:
The TopicMap object to which this object belongs.

getSourceLocators

public java.util.Set getSourceLocators()
Returns the set of source locators for this object. Source locators are identifiers for the object and can be freely assigned in order to be used to refer to the object. Note that on XTM import source locators MUST be assigned that refer to the XTM elements that gave rise to the object, providing the XTM element had an id attribute. The return value may be an empty Set, but is never null.

Returns:
An unmodifiable Set of Locator objects

addSourceLocator

public void addSourceLocator(Locator sourceLocator)
                      throws DuplicateSourceLocatorException
Adds a Locator to the set of source locators for this object. It is not allowed to have two TopicMapObjects in the same TopicMap with the same source locator. If the two objects are Topic objects, then they must be merged. If at least one of the two objects is not a Topic object, a DuplicateSourceLocatorException must be reported.

Parameters:
sourceLocator - the Locator to be added
Throws:
DuplicateSourceLocatorException - if there is already a TopicMapObject in the same TopicMap with this source locator.
See Also:
getSourceLocators()

removeSourceLocator

public void removeSourceLocator(Locator sourceLocator)
Removes a Locator from the set of source locators for this object.

Parameters:
sourceLocator - the Locator to be removed.
See Also:
getSourceLocators()

remove

public void remove()
            throws TMAPIException
Removes the object from its container.

Throws:
TMAPIException - if the object cannot be removed from the container. Derived interfaces may define specific circumstances under which a subclass of TMAPIException must be raised. Implementations MUST NOT use a TMAPIException to wrap a failure raised in the underlying engine - such errors must always be wrapped in a TMAPIRuntimeException.

getObjectId

public java.lang.String getObjectId()
Returns a topic map-specific identifier for this object. The identifier returned must be guaranteed to be unique across all TopicMapObject instances from the same TopicMap instance.

Returns:
the system-specific identifier as a String

equals

public boolean equals(java.lang.Object o)
Returns true if the other object is equal to this one. Equality must be the result of comparing the object ids of the two topic map objects. If o is not an instance of TopicMapObject the return value is false.

Returns:
(o instanceof TopicMapObject && this.getObjectId().equals(((TopicMapObject)o).getObjectId()))

hashCode

public int hashCode()
Returns the hashcode of the topic map object's object id

Returns:
this.getObjectId().hashCode()