org.tmapi.core
Interface Topic

All Superinterfaces:
Construct

public interface Topic
extends Construct

Represents a topic item.

Version:
$Rev: 123 $ - $Date: 2009-10-01 19:17:03 +0200 (Do, 01 Okt 2009) $
Author:
The TMAPI Project

Method Summary
 void addItemIdentifier(Locator itemIdentifier)
          Adds an item identifier to this topic.
 void addSubjectIdentifier(Locator subjectIdentifier)
          Adds a subject identifier to this topic.
 void addSubjectLocator(Locator subjectLocator)
          Adds a subject locator to this topic.
 void addType(Topic type)
          Adds a type to this topic.
 Name createName(java.lang.String value, java.util.Collection<Topic> scope)
          Creates a Name for this topic with the specified value, and scope.
 Name createName(java.lang.String value, Topic... scope)
          Creates a Name for this topic with the specified value, and scope.
 Name createName(Topic type, java.lang.String value, java.util.Collection<Topic> scope)
          Creates a Name for this topic with the specified type, value, and scope.
 Name createName(Topic type, java.lang.String value, Topic... scope)
          Creates a Name for this topic with the specified type, value, and scope.
 Occurrence createOccurrence(Topic type, Locator value, java.util.Collection<Topic> scope)
          Creates an Occurrence for this topic with the specified type, IRI value, and scope.
 Occurrence createOccurrence(Topic type, Locator value, Topic... scope)
          Creates an Occurrence for this topic with the specified type, IRI value, and scope.
 Occurrence createOccurrence(Topic type, java.lang.String value, java.util.Collection<Topic> scope)
          Creates an Occurrence for this topic with the specified type, string value, and scope.
 Occurrence createOccurrence(Topic type, java.lang.String value, Locator datatype, java.util.Collection<Topic> scope)
          Creates an Occurrence for this topic with the specified type, value, datatype, and scope.
 Occurrence createOccurrence(Topic type, java.lang.String value, Locator datatype, Topic... scope)
          Creates an Occurrence for this topic with the specified type, value, datatype, and scope.
 Occurrence createOccurrence(Topic type, java.lang.String value, Topic... scope)
          Creates an Occurrence for this topic with the specified type, string value, and scope.
 java.util.Set<Name> getNames()
          Returns the names of this topic.
 java.util.Set<Name> getNames(Topic type)
          Returns the Names of this topic where the name type is type.
 java.util.Set<Occurrence> getOccurrences()
          Returns the Occurrences of this topic.
 java.util.Set<Occurrence> getOccurrences(Topic type)
          Returns the Occurrences of this topic where the occurrence type is type.
 TopicMap getParent()
          Returns the TopicMap to which this topic belongs.
 Reifiable getReified()
          Returns the Construct which is reified by this topic.
 java.util.Set<Role> getRolesPlayed()
          Returns the roles played by this topic.
 java.util.Set<Role> getRolesPlayed(Topic type)
          Returns the roles played by this topic where the role type is type.
 java.util.Set<Role> getRolesPlayed(Topic type, Topic assocType)
          Returns the Roles played by this topic where the role type is type and the Association type is assocType.
 java.util.Set<Locator> getSubjectIdentifiers()
          Returns the subject identifiers assigned to this topic.
 java.util.Set<Locator> getSubjectLocators()
          Returns the subject locators assigned to this topic.
 java.util.Set<Topic> getTypes()
          Returns the types of which this topic is an instance of.
 void mergeIn(Topic other)
          Merges another topic into this topic.
 void remove()
          Removes this topic from the containing TopicMap instance.
 void removeSubjectIdentifier(Locator subjectIdentifier)
          Removes a subject identifier from this topic.
 void removeSubjectLocator(Locator subjectLocator)
          Removes a subject locator from this topic.
 void removeType(Topic type)
          Removes a type from this topic.
 
Methods inherited from interface org.tmapi.core.Construct
equals, getId, getItemIdentifiers, getTopicMap, hashCode, removeItemIdentifier
 

Method Detail

getParent

TopicMap getParent()
Returns the TopicMap to which this topic belongs.

Specified by:
getParent in interface Construct
Returns:
The topic map to which this topic belongs.
See Also:
Construct.getParent()

addItemIdentifier

void addItemIdentifier(Locator itemIdentifier)
Adds an item identifier to this topic.

If adding the specified item identifier would make this topic represent the same subject as another topic and the feature "automerge" (http://tmapi.org/features/automerge) is disabled, an IdentityConstraintException is thrown.

Specified by:
addItemIdentifier in interface Construct
Parameters:
itemIdentifier - The item identifier to be added; must not be null.
See Also:
Construct.addItemIdentifier(org.tmapi.core.Locator)

getSubjectIdentifiers

java.util.Set<Locator> getSubjectIdentifiers()
Returns the subject identifiers assigned to this topic. The return value may be empty but must never be null.

Returns:
An unmodifiable set of Locators representing the subject identifiers.

addSubjectIdentifier

void addSubjectIdentifier(Locator subjectIdentifier)
                          throws IdentityConstraintException,
                                 ModelConstraintException
Adds a subject identifier to this topic.

If adding the specified subject identifier would make this topic represent the same subject as another topic and the feature "automerge" (http://tmapi.org/features/automerge/) is disabled, an IdentityConstraintException is thrown.

Parameters:
subjectIdentifier - The subject identifier to be added; must not be null.
Throws:
IdentityConstraintException - If the feature "automerge" is disabled and adding the subject identifier would make this topic represent the same subject as another topic.
ModelConstraintException - If the subject identifier is null.

removeSubjectIdentifier

void removeSubjectIdentifier(Locator subjectIdentifier)
Removes a subject identifier from this topic.

Parameters:
subjectIdentifier - The subject identifier to be removed from this topic, if present (null is ignored).

getSubjectLocators

java.util.Set<Locator> getSubjectLocators()
Returns the subject locators assigned to this topic. The return value may be empty but must never be null.

Returns:
An unmodifiable set of Locators representing the subject locators.

addSubjectLocator

void addSubjectLocator(Locator subjectLocator)
                       throws IdentityConstraintException,
                              ModelConstraintException
Adds a subject locator to this topic.

If adding the specified subject locator would make this topic represent the same subject as another topic and the feature "automerge" (http://tmapi.org/features/automerge/) is disabled, an IdentityConstraintException is thrown.

Parameters:
subjectLocator - The subject locator to be added; must not be null.
Throws:
IdentityConstraintException - If the feature "automerge" is disabled and adding the subject locator would make this topic represent the same subject as another topic.
ModelConstraintException - If the subject locator is null.

removeSubjectLocator

void removeSubjectLocator(Locator subjectLocator)
Removes a subject locator from this topic.

Parameters:
subjectLocator - The subject locator to be removed from this topic, if present (null is ignored).

getNames

java.util.Set<Name> getNames()
Returns the names of this topic. The return value may be empty but must never be null.

Returns:
An unmodifable set of Names belonging to this topic.

getNames

java.util.Set<Name> getNames(Topic type)
Returns the Names of this topic where the name type is type.

This method returns the same result as the following code:

      Set<Name> names = new HashSet<Name>();
      for (Name name: topic.getNames()) {
          if (name.getType().equals(type)) {
              names.add(name);
          }
      }
 

The return value may be empty but must never be null.

Parameters:
type - The type of the Names to be returned; must not be null.
Returns:
An unmodifiable set of Names with the specified type.
Throws:
java.lang.IllegalArgumentException - If the type is null.

createName

Name createName(Topic type,
                java.lang.String value,
                Topic... scope)
                throws ModelConstraintException
Creates a Name for this topic with the specified type, value, and scope.

Parameters:
type - The name type; MUST NOT be null.
value - The string value of the name; MUST NOT be null.
scope - An optional array of themes, must not be null. If the array's length is 0, the name will be in the unconstrained scope.
Returns:
The newly created Name.
Throws:
ModelConstraintException - If either the type, the value, or scope is null.

createName

Name createName(Topic type,
                java.lang.String value,
                java.util.Collection<Topic> scope)
                throws ModelConstraintException
Creates a Name for this topic with the specified type, value, and scope.

Parameters:
type - The name type; MUST NOT be null.
value - The string value of the name; MUST NOT be null.
scope - A collection of themes. The collection may be empty if the name should be in the unconstrained scope.
Returns:
The newly created Name.
Throws:
ModelConstraintException - If either the type, the value, or scope is null.

createName

Name createName(java.lang.String value,
                Topic... scope)
                throws ModelConstraintException
Creates a Name for this topic with the specified value, and scope.

The created Name will have the default name type (a Topic with the subject identifier http://psi.topicmaps.org/iso13250/model/topic-name).

Parameters:
value - The string value of the name; MUST NOT be null.
scope - An optional array of themes, must not be null. If the array's length is 0, the name will be in the unconstrained scope.
Returns:
The newly created Name.
Throws:
ModelConstraintException - If either the value, or scope is null.

createName

Name createName(java.lang.String value,
                java.util.Collection<Topic> scope)
                throws ModelConstraintException
Creates a Name for this topic with the specified value, and scope.

The created Name will have the default name type (a Topic with the subject identifier http://psi.topicmaps.org/iso13250/model/topic-name).

Parameters:
value - The string value of the name; MUST NOT be null.
scope - A collection of themes. The collection may be empty if the name should be in the unconstrained scope.
Returns:
The newly created Name.
Throws:
ModelConstraintException - If either the value, or scope is null.

getOccurrences

java.util.Set<Occurrence> getOccurrences()
Returns the Occurrences of this topic. The return value may be empty but must never be null.

Returns:
An unmodifable set of Occurrences belonging to this topic.

getOccurrences

java.util.Set<Occurrence> getOccurrences(Topic type)
Returns the Occurrences of this topic where the occurrence type is type.

This method returns the same result as the following code:

      Set<Occurrence> occs = new HashSet<Occurrence>();
      for (Occurrence occ: topic.getOccurrences()) {
          if (occ.getType().equals(type)) {
              occs.add(occ);
          }
      }
 

The return value may be empty but must never be null.

Parameters:
type - The type of the Occurrences to be returned; must not be null.
Returns:
An unmodifiable set of Occurrences with the specified type.
Throws:
java.lang.IllegalArgumentException - If the type is null.

createOccurrence

Occurrence createOccurrence(Topic type,
                            java.lang.String value,
                            Topic... scope)
                            throws ModelConstraintException
Creates an Occurrence for this topic with the specified type, string value, and scope.

The newly created Occurrence will have the datatype xsd:string.

Parameters:
type - The occurrence type; MUST NOT be null.
value - The string value of the occurrence.
scope - An optional array of themes, must not be null. If the array's length is 0, the occurrence will be in the unconstrained scope.
Returns:
The newly created Occurrence.
Throws:
ModelConstraintException - If either the type, the value, or scope is null.

createOccurrence

Occurrence createOccurrence(Topic type,
                            java.lang.String value,
                            java.util.Collection<Topic> scope)
                            throws ModelConstraintException
Creates an Occurrence for this topic with the specified type, string value, and scope.

The newly created Occurrence will have the datatype xsd:string.

Parameters:
type - The occurrence type; MUST NOT be null.
value - The string value of the occurrence.
scope - A collection of themes. The collection may be empty if the occurrence should be in the unconstrained scope.
Returns:
The newly created Occurrence.
Throws:
ModelConstraintException - If either the type, the value, or scope is null.

createOccurrence

Occurrence createOccurrence(Topic type,
                            Locator value,
                            Topic... scope)
                            throws ModelConstraintException
Creates an Occurrence for this topic with the specified type, IRI value, and scope.

The newly created Occurrence will have the datatype xsd:anyURI.

Parameters:
type - The occurrence type; MUST NOT be null.
value - A locator which represents an IRI.
scope - An optional array of themes, must not be null. If the array's length is 0, the occurrence will be in the unconstrained scope.
Returns:
The newly created Occurrence.
Throws:
ModelConstraintException - If either the type, the value, or scope is null.

createOccurrence

Occurrence createOccurrence(Topic type,
                            Locator value,
                            java.util.Collection<Topic> scope)
                            throws ModelConstraintException
Creates an Occurrence for this topic with the specified type, IRI value, and scope.

The newly created Occurrence will have the datatype xsd:anyURI.

Parameters:
type - The occurrence type; MUST NOT be null.
value - A locator which represents an IRI.
scope - A collection of themes. The collection may be empty if the occurrence should be in the unconstrained scope.
Returns:
The newly created Occurrence.
Throws:
ModelConstraintException - If either the type, the value, or scope is null.

createOccurrence

Occurrence createOccurrence(Topic type,
                            java.lang.String value,
                            Locator datatype,
                            Topic... scope)
                            throws ModelConstraintException
Creates an Occurrence for this topic with the specified type, value, datatype, and scope.

The newly created Occurrence will have the datatype specified by datatype.

Parameters:
type - The occurrence type; MUST NOT be null.
value - A lexical string representation of the value.
datatype - A locator indicating the datatype of the value.
scope - An optional array of themes, must not be null. If the array's length is 0, the occurrence will be in the unconstrained scope.
Returns:
The newly created Occurrence.
Throws:
ModelConstraintException - If either the type, the value, the datatype or scope is null.

createOccurrence

Occurrence createOccurrence(Topic type,
                            java.lang.String value,
                            Locator datatype,
                            java.util.Collection<Topic> scope)
                            throws ModelConstraintException
Creates an Occurrence for this topic with the specified type, value, datatype, and scope.

The newly created Occurrence will have the datatype specified by datatype.

Parameters:
type - The occurrence type; MUST NOT be null.
value - A lexical string representation of the value.
datatype - A locator indicating the datatype of the value.
scope - A collection of themes. The collection may be empty if the occurrence should be in the unconstrained scope.
Returns:
The newly created Occurrence.
Throws:
ModelConstraintException - If either the type, the value, the datatype or scope is null.

getRolesPlayed

java.util.Set<Role> getRolesPlayed()
Returns the roles played by this topic. The return value may be empty but must never be null.

Returns:
An unmodifiable set of Roles played by this topic.

getRolesPlayed

java.util.Set<Role> getRolesPlayed(Topic type)
Returns the roles played by this topic where the role type is type.

This method returns the same result as the following code:

      Set<Role> roles = new HashSet<Role>();
      for (Role role: topic.getRolesPlayed()) {
          if (role.getType().equals(type)) {
              roles.add(role);
          }
      }
 

The return value may be empty but must never be null.

Parameters:
type - The type of the Roles to be returned; must not be null.
Returns:
An unmodifiable set of Roles with the specified type.
Throws:
java.lang.IllegalArgumentException - If the type is null.

getRolesPlayed

java.util.Set<Role> getRolesPlayed(Topic type,
                                   Topic assocType)
Returns the Roles played by this topic where the role type is type and the Association type is assocType.

This method returns the same result as the following code:

      Set<Role> roles = new HashSet<Role>();
      for (Role role: topic.getRolesPlayed(type)) {
          if (role.getParent().getType().equals(assocType)) {
              roles.add(role);
          }
      }
 

The return value may be empty but must never be null.

Parameters:
type - The type of the Roles to be returned; must not be null.
assocType - The type of the Association from which the returned roles must be part of; must not be null.
Returns:
An unmodifiable set of Roles with the specified type which are part of Associations with the specified assocType.
Throws:
java.lang.IllegalArgumentException - If the type or assocType is null.

getTypes

java.util.Set<Topic> getTypes()
Returns the types of which this topic is an instance of.

This method may return only those types which where added by addType(Topic) and may ignore type-instance relationships which are modelled as association.

The return value may be empty but must never be null.

Returns:
An unmodifiable set of Topics.

addType

void addType(Topic type)
             throws ModelConstraintException
Adds a type to this topic.

Implementations may or may not create an association for types added by this method. In any case, every type which was added by this method must be returned by the getTypes() method.

Parameters:
type - The type of which this topic should become an instance of; must not be null.
Throws:
ModelConstraintException - If the type is null.

removeType

void removeType(Topic type)
Removes a type from this topic.

Parameters:
type - The type to be removed from this topic, if present (null is ignored).

getReified

Reifiable getReified()
Returns the Construct which is reified by this topic.

Returns:
The Reifiable that is reified by this topic or null if this topic does not reify a statement.

mergeIn

void mergeIn(Topic other)
             throws ModelConstraintException
Merges another topic into this topic.

Merging a topic into this topic causes this topic to gain all of the characteristics of the other topic and to replace the other topic wherever it is used as type, theme, or reifier. After this method completes, other will have been removed from the TopicMap.

If this.equals(other) no changes are made to the topic.

NOTE: The other topic MUST belong to the same TopicMap instance as this topic!

Parameters:
other - The topic to be merged into this topic; must not be null.
Throws:
ModelConstraintException - If other is null.

remove

void remove()
            throws TopicInUseException
Removes this topic from the containing TopicMap instance.

This method throws a TopicInUseException if the topic plays a Role, is used as type of a Typed construct, or if it is used as theme for a Scoped construct, or if it reifies a Reifiable.

Specified by:
remove in interface Construct
Throws:
TopicInUseException - If the topic plays a Role or it is used as type, in a scope, or as reifier.
See Also:
Construct.remove()