org.tm4j.topicmap.unified
Class UnifiedTopic

java.lang.Object
  extended byorg.tm4j.topicmap.unified.UnifiedTopicMapObject
      extended byorg.tm4j.topicmap.unified.UnifiedTopic
All Implemented Interfaces:
Topic, TopicMapObject

public class UnifiedTopic
extends UnifiedTopicMapObject
implements Topic


Field Summary
 
Fields inherited from class org.tm4j.topicmap.unified.UnifiedTopicMapObject
m_tm
 
Constructor Summary
UnifiedTopic(UnifiedTopicMap tm, Topic t)
           
 
Method Summary
 void addMergedTopic(Topic t)
          Adds the specified topic to the set of merged topics.
 void addName(BaseName bn)
          Adds another name to the set of names of this Topic.
 void addOccurrence(Occurrence bn)
          Adds an occurrence to this Topic.
 void addSubjectIndicator(Locator sind)
          Adds a subject indicator to this topic.
 void addType(Topic t)
          Adds a new topic into the set of those defining the type of this topic.
 BaseName createName(java.lang.String id)
          Creates a new BaseName as a child of this Topic.
 BaseName createName(java.lang.String id, java.lang.String nameString)
          Creates a new BaseName as a child of this Topic
 BaseName createName(java.lang.String id, java.lang.String nameString, Topic[] scope)
          Creates a new BaseName as a child of this Topic
 Occurrence createOccurrence(java.lang.String id)
          Creates a new Occurrence as a child of this Topic.
 Occurrence createOccurrence(java.lang.String id, Locator resourceLocator, Topic type, Locator ref, Topic[] themes)
           
 Occurrence createOccurrence(java.lang.String id, Locator resourceLocator, Topic type, java.lang.String data, Topic[] themes)
           
 boolean equals(java.lang.Object other)
           
 Topic getBaseTopic()
          Gets the topic with which this topic is merged if any.
 java.util.Collection getMergedTopics()
          Returns a collection of all of the other topics which were merged with this topic due to identity matches or topic map naming constraints.
 java.util.Collection getNames()
          Retrieves a collection of the base names of this topic and any merged topics.
 java.util.Collection getNames(boolean includeMerged)
          Retrieves the collection of the base names of this topic and, if so specified, of any merged topics.
 java.util.Collection getOccurrences()
          Returns the occurrences for this topic and any merged topics.
 java.util.Collection getOccurrences(boolean includeMerged)
          Returns the occurrences for this topic and, if so specified, of any merged topics.
 TopicMap getParent()
          Returns the TopicMap object which contains this Topic object.
 java.util.Set getResourceLocators()
           
 java.util.Collection getRolesPlayed()
          Gets the Member objects which define roles played by this topic in associations.
 java.util.Collection getRolesPlayed(boolean includeMerged)
          Gets the Member objects which define roles played by this topic in associations.
 java.util.Collection getScopedNames()
          Generates a list of all names of the topic and all merged topics, qualified by the scope of the names and of the topic itself.
 java.util.Collection getScopedNames(boolean includeMerged)
          Generates a list of all names of the topic, qualified by the scope of the names and of the topic itself.
 Locator getSubject()
          Retrieves the reference to the resource which is the subject of this topic.
 Locator getSubject(boolean includeMerged)
          Retrieves the reference to the resource which is the subject of this topic.
 java.util.Collection getSubjectIndicators()
          Returns the subject indicators for this topic and all merged topics.
 java.util.Collection getSubjectIndicators(boolean includeMerged)
          Returns the subject indicators for this topic and, optionally, for all merged topics.
 java.util.Collection getTypes()
          Returns the Topics defining the type of this topic and all merged topics.
 java.util.Collection getTypes(boolean includeMerged)
          Returns the Topics defining the type of this topic and, optionally, of all merged topics.
 boolean isOfType(Locator l)
          Determines whether this topic is typed by a topic whose subject is or whose subject is indicated by subjectOrIndicator.
 boolean isOfType(Topic t)
          Determines whether the specified topic is one of the types of this topic.
 void setNames(BaseName[] names)
          Sets the names of this Topic.
 void setOccurrences(Occurrence[] names)
          Sets the list of occurrences for this Topic.
 void setSubject(Locator l)
          Sets the reference to the subject of this topic.
 void setSubjectIndicators(Locator[] sinds)
          Sets the collection of subject indicators for this topic.
 void setTypes(Topic[] types)
          Defines the type of this topic.
protected  java.util.Collection toUnifiedTopics(java.util.Collection c)
          Converts a collection of "raw" topics into a collection of UnifiedTopic objects.
 
Methods inherited from class org.tm4j.topicmap.unified.UnifiedTopicMapObject
addMultiValuePropertyChangeListener, addMultiValuePropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addSourceLocator, addVetoableChangeListener, destroy, fireMultiValuePropertyChange, fireMultiValuePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, getBaseObject, getID, getResourceLocator, getSourceLocators, getTopicMap, hashCode, removeMultiValuePropertyChangeListener, removePropertyChangeListener, removePropertyChangeListener, removeSourceLocator, removeVetoableChangeListener, setID, setResourceLocator, unsupported
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.tm4j.topicmap.TopicMapObject
addMultiValuePropertyChangeListener, addMultiValuePropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addSourceLocator, addVetoableChangeListener, destroy, fireMultiValuePropertyChange, fireMultiValuePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getID, getResourceLocator, getSourceLocators, getTopicMap, removeMultiValuePropertyChangeListener, removePropertyChangeListener, removePropertyChangeListener, removeSourceLocator, removeVetoableChangeListener, setID, setResourceLocator
 

Constructor Detail

UnifiedTopic

public UnifiedTopic(UnifiedTopicMap tm,
                    Topic t)
Method Detail

getResourceLocators

public java.util.Set getResourceLocators()

getSubject

public Locator getSubject()
Description copied from interface: Topic
Retrieves the reference to the resource which is the subject of this topic.

Specified by:
getSubject in interface Topic
Returns:
The resource reference as a Locator, or null if no resource represents the subject which this topic reifies.

setSubject

public void setSubject(Locator l)
Description copied from interface: Topic
Sets the reference to the subject of this topic.

Specified by:
setSubject in interface Topic
Parameters:
l - The locator of the resource that is the subject which this topic reifies.

getSubject

public Locator getSubject(boolean includeMerged)
Description copied from interface: Topic
Retrieves the reference to the resource which is the subject of this topic.

Specified by:
getSubject in interface Topic
Parameters:
includeMerged - if true, then the subject defined by any one of the topics merged with this topic will be returned, otherwise a value will only be returned if it was specified on this Topic instance.
Returns:
the resource reference as a Locator or null if there is no subject locator.

getSubjectIndicators

public java.util.Collection getSubjectIndicators()
Description copied from interface: Topic
Returns the subject indicators for this topic and all merged topics. This method is a shorthand for getSubjectIndicators(true).

Specified by:
getSubjectIndicators in interface Topic
Returns:
An unmodifiable collection of Locators representing the subject indicators for this topic. If no subject indicators are currently defined on this topic (or merged topics), the returned collection is empty; it is never null.

getSubjectIndicators

public java.util.Collection getSubjectIndicators(boolean includeMerged)
Description copied from interface: Topic
Returns the subject indicators for this topic and, optionally, for all merged topics.

Specified by:
getSubjectIndicators in interface Topic
Parameters:
includeMerged - if true, then the subject indicators of all merged topics are included in the returned collection, otherwise only the subject indicators of this topic are returned.
Returns:
An unmodifiable collection of Locators representing the subject indicators for this topic. If no subject indicators are currently defined on this topic (or merged topics), the returned collection is empty; it is never null.

addSubjectIndicator

public void addSubjectIndicator(Locator sind)
Description copied from interface: Topic
Adds a subject indicator to this topic.

Specified by:
addSubjectIndicator in interface Topic
Parameters:
sind - the subject indicator reference to be added.

setSubjectIndicators

public void setSubjectIndicators(Locator[] sinds)
Description copied from interface: Topic
Sets the collection of subject indicators for this topic.

Specified by:
setSubjectIndicators in interface Topic
Parameters:
sinds - the subject indicator references, as an array of Locators.

getTypes

public java.util.Collection getTypes()
Description copied from interface: Topic
Returns the Topics defining the type of this topic and all merged topics. This method is shorthand for getTypes(true).

Specified by:
getTypes in interface Topic
Returns:
An unmodifiable Collection of the Topics defining the type of this topic and all merged topics. If no types are currently defined on this topic (or merged topics), the returned collection is empty; it is never null.

getTypes

public java.util.Collection getTypes(boolean includeMerged)
Description copied from interface: Topic
Returns the Topics defining the type of this topic and, optionally, of all merged topics.

Specified by:
getTypes in interface Topic
Parameters:
includeMerged - If true then the types of all merged topics are included in the returned collection, otherwise, only the typing topics defined on this topic are returned.
Returns:
An unmodifiable Collection of the Topics defining the type of this topic and, if includeMergedTopics is set to true, of all merged topics. If no subject indicators are currently defined on this topic (or merged topics), the returned collection is empty; it is never null.

addType

public void addType(Topic t)
Description copied from interface: Topic
Adds a new topic into the set of those defining the type of this topic.

Specified by:
addType in interface Topic
Parameters:
t - The typing topic to be added.

setTypes

public void setTypes(Topic[] types)
Description copied from interface: Topic
Defines the type of this topic.

Specified by:
setTypes in interface Topic
Parameters:
types - the new set of topics to define the type of this topic. If this is null, all the existing typing topics of this topic are removed.

toUnifiedTopics

protected java.util.Collection toUnifiedTopics(java.util.Collection c)
Converts a collection of "raw" topics into a collection of UnifiedTopic objects. This algorithm ensures that merged topics are not duplicated in the results set.


isOfType

public boolean isOfType(Topic t)
Description copied from interface: Topic
Determines whether the specified topic is one of the types of this topic.

Specified by:
isOfType in interface Topic
Parameters:
t - the topic to be compared to this topic's typing topics.
Returns:
true if type is among the topics defining this topic's type, false otherwise.

isOfType

public boolean isOfType(Locator l)
Description copied from interface: Topic
Determines whether this topic is typed by a topic whose subject is or whose subject is indicated by subjectOrIndicator.

This method will return true if one of the following conditions hold:

Specified by:
isOfType in interface Topic
Returns:
true if subjectOrIndicator meets the above conditions, false otherwise.

getNames

public java.util.Collection getNames()
Description copied from interface: Topic
Retrieves a collection of the base names of this topic and any merged topics. This function is shorthand for getNames(true).

Specified by:
getNames in interface Topic
Returns:
An unmodifiable collection of BaseNames defined on this topic and any merged topics. If no base names are currently defined on this topic (or merged topics), the returned collection is empty; it is never null.

getNames

public java.util.Collection getNames(boolean includeMerged)
Description copied from interface: Topic
Retrieves the collection of the base names of this topic and, if so specified, of any merged topics.

Specified by:
getNames in interface Topic
Parameters:
includeMerged - If true, the names of all merged topics are included in the returned collection. Otherwise, the collection contains only the names defined specifically on this topic.
Returns:
An unmodifiable collection of BaseNames defined on this topic and, optionally, any merged topics. If no base names are currently defined on this topic (or merged topics), the returned collection is empty; it is never null.

addName

public void addName(BaseName bn)
Description copied from interface: Topic
Adds another name to the set of names of this Topic.

Specified by:
addName in interface Topic
Parameters:
bn - the name to be added.

setNames

public void setNames(BaseName[] names)
Description copied from interface: Topic
Sets the names of this Topic.

Specified by:
setNames in interface Topic
Parameters:
names - the new set of names to be assigned to this topic. If this is null, all the existing names of this topic are removed.

createName

public BaseName createName(java.lang.String id)
Description copied from interface: Topic
Creates a new BaseName as a child of this Topic.

Specified by:
createName in interface Topic
Parameters:
id - the unique object id to be assigned to the new BaseName object. If this parameter is null, the back-end will assign an ID to the newly created object.

createName

public BaseName createName(java.lang.String id,
                           java.lang.String nameString)
Description copied from interface: Topic
Creates a new BaseName as a child of this Topic

Specified by:
createName in interface Topic
Parameters:
id - the unique object id to be assigned to the new BaseName object. If this parameter is null, the back-end will assign an ID to the newly created object.
nameString - the string to be assigned to the new BaseName as content.
Returns:
a new BaseName object.

createName

public BaseName createName(java.lang.String id,
                           java.lang.String nameString,
                           Topic[] scope)
Description copied from interface: Topic
Creates a new BaseName as a child of this Topic

Specified by:
createName in interface Topic
Parameters:
id - the unique object id to be assigned to the new BaseName object. If this parameter is null, the back-end will assign an ID to the newly created object.
nameString - the string to be assigned to the new BaseName as content.
scope - the topics to be assigned to the scope of the new BaseName.
Returns:
a new BaseName object.

getOccurrences

public java.util.Collection getOccurrences()
Description copied from interface: Topic
Returns the occurrences for this topic and any merged topics. This function is shorthand for getOccurrences(true).

Specified by:
getOccurrences in interface Topic
Returns:
A collection of the Occurrences for this topic and for any merged topics. The returned collection is a copy of the internal set of occurrences of the topic — modifying the collection has no effect on the occurrence set of the Topic. If no occurrences are currently defined on this topic (or merged topics), the returned collection is empty; it is never null.

getOccurrences

public java.util.Collection getOccurrences(boolean includeMerged)
Description copied from interface: Topic
Returns the occurrences for this topic and, if so specified, of any merged topics.

Specified by:
getOccurrences in interface Topic
Parameters:
includeMerged - if true, then the occurrences of all merged topics are included in the returned collection. Otherwise, the collection contains only the occurrences defined specifically for this topic.
Returns:
A collection of the Occurrences for this topic and for any merged topics. The returned collection is a copy of the internal set of occurrences of the topic — modifying the collection has no effect on the occurrence set of the Topic. If no occurrences are currently defined on this topic (or merged topics), the returned collection is empty; it is never null.

addOccurrence

public void addOccurrence(Occurrence bn)
Description copied from interface: Topic
Adds an occurrence to this Topic.

Specified by:
addOccurrence in interface Topic
Parameters:
bn - The Occurrence to be added.

setOccurrences

public void setOccurrences(Occurrence[] names)
Description copied from interface: Topic
Sets the list of occurrences for this Topic.

Specified by:
setOccurrences in interface Topic
Parameters:
names - the new set of occurrences to be associated with this topic. If this is null, all the existing occurrences of this topic are removed.

createOccurrence

public Occurrence createOccurrence(java.lang.String id)
Description copied from interface: Topic
Creates a new Occurrence as a child of this Topic.

Specified by:
createOccurrence in interface Topic
Parameters:
id - the unique object id to be assigned to the new Occurrence object. If this parameter is null, the back-end will assign an ID to the newly created object.

createOccurrence

public Occurrence createOccurrence(java.lang.String id,
                                   Locator resourceLocator,
                                   Topic type,
                                   Locator ref,
                                   Topic[] themes)
                            throws DuplicateObjectIDException,
                                   DuplicateResourceLocatorException,
                                   java.beans.PropertyVetoException
Specified by:
createOccurrence in interface Topic
Throws:
DuplicateObjectIDException
DuplicateResourceLocatorException
java.beans.PropertyVetoException

createOccurrence

public Occurrence createOccurrence(java.lang.String id,
                                   Locator resourceLocator,
                                   Topic type,
                                   java.lang.String data,
                                   Topic[] themes)
                            throws DuplicateObjectIDException,
                                   DuplicateResourceLocatorException,
                                   java.beans.PropertyVetoException
Specified by:
createOccurrence in interface Topic
Throws:
DuplicateObjectIDException
DuplicateResourceLocatorException
java.beans.PropertyVetoException

getRolesPlayed

public java.util.Collection getRolesPlayed()
Description copied from interface: Topic
Gets the Member objects which define roles played by this topic in associations. The roles played by all merged topics are also included. This function is shorthand for getRolesPlayed(true).

Specified by:
getRolesPlayed in interface Topic
Returns:
A Collection of the Member objects representing roles played by this Topic in Associations.

getRolesPlayed

public java.util.Collection getRolesPlayed(boolean includeMerged)
Description copied from interface: Topic
Gets the Member objects which define roles played by this topic in associations.

Specified by:
getRolesPlayed in interface Topic
Parameters:
includeMerged - If true then the roles played by all merged topics are included in the returned collection.

getMergedTopics

public java.util.Collection getMergedTopics()
Description copied from interface: Topic
Returns a collection of all of the other topics which were merged with this topic due to identity matches or topic map naming constraints.

Specified by:
getMergedTopics in interface Topic
Returns:
An unmodifiable collection of original Topics that were topic merged with this topic. If no topics were merged with this topic, the returned collection is empty; it is never null.

getBaseTopic

public Topic getBaseTopic()
Description copied from interface: Topic
Gets the topic with which this topic is merged if any.

Specified by:
getBaseTopic in interface Topic
Returns:
The topic that this topic is merged with, or null if the topic has not merged with any other.

getScopedNames

public java.util.Collection getScopedNames()
Description copied from interface: Topic
Generates a list of all names of the topic and all merged topics, qualified by the scope of the names and of the topic itself. This is equivalent to getScopedNames(true). Each qualified name is generated as follows:
    <sorted-scope-list>.<name-string>
Where <sorted-scope-list> is a list of all themes SGML identifiers sorted in ascending alphabetical order, with a period separator between each identifier.

Specified by:
getScopedNames in interface Topic
Returns:
A collection of strings containing the scoped names, as described above. If no names are currently defined on this topic (or merged topics), the returned collection is empty; it is never null.

getScopedNames

public java.util.Collection getScopedNames(boolean includeMerged)
Description copied from interface: Topic
Generates a list of all names of the topic, qualified by the scope of the names and of the topic itself. Each qualified name is generated as follows:
    <sorted-scope-list>.<name-string>
Where <sorted-scope-list> is a list of all themes SGML identifiers sorted in ascending alphabetical order, with a period separator between each identifier.

Specified by:
getScopedNames in interface Topic
Parameters:
includeMerged - If true, the scoped names of all topics merged with this topic are returned. Otherwise, only the scoped names of this topic are returned.
Returns:
A collection of strings containing the scoped names, as described above. If no names are currently defined on this topic (or merged topics), the returned collection is empty; it is never null.

getParent

public TopicMap getParent()
Description copied from interface: Topic
Returns the TopicMap object which contains this Topic object.

Specified by:
getParent in interface Topic
Returns:
The topic map that this topic is contained in.

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class UnifiedTopicMapObject

addMergedTopic

public void addMergedTopic(Topic t)
Description copied from interface: Topic
Adds the specified topic to the set of merged topics.

Specified by:
addMergedTopic in interface Topic
Parameters:
t - the topic to be added to the merge set.