public class LayeredTopic extends Topic
A LayeredTopic is a collection of topics in different layers that together merge with each other. Note that the collection may contain two topics which do not directly merge with each other but with the addition to some other topics, they all merge together. These topics are stored in an ordered collection with topics of top layers first and bottom layers last. Topics of same layer are ordered according to the smallest (lexicographically) subject identifier. This is somewhat arbitrary but will give a consistent ordering instead of random order.
When information is queried, the collection with all the individual topics is iterated and depending on the data being queried, either the first non null value is restored or all values are combined. Example of the former case is getting the base name and example for the latter case is getting subject identifiers. In general methods that return a collection of something combine the results from all individual topics (removing duplicates) and methods that return a single value return the first non null value encountered. Because topics are ordered in the topic collection, information from top layers is returned before information of bottom layers when only one non null value is returned.
Methods that modify a LayeredTopic actually modify one of the individual topics. The topic to be modified is chosen to be a topic of the selected layer of the layer stack. If such a topic does not exist one is generated in the layer. In case there are several such topics, one of them is chosen. Also the parameters to the modifying methods might not exist in the layer, in which case stubs of them are automatically generated.
| Modifier and Type | Class and Description |
|---|---|
(package private) class |
LayeredTopic.LayerOrderComparator
Comparator used to order the topics LayeredTopic consists of.
|
static class |
LayeredTopic.TopicKeyMaker |
| Modifier and Type | Field and Description |
|---|---|
private int |
hashCode |
protected LayerStack |
layerStack
The layer stack for this topic
|
protected java.util.Vector<Topic> |
topics
The topics this LayeredTopic consists of
|
| Constructor and Description |
|---|
LayeredTopic(java.util.Collection<Topic> topics,
LayerStack layerStack)
Creates a new instance of LayeredTopic.
|
LayeredTopic(Topic t,
LayerStack layerStack)
Creates a new instance of LayeredTopic.
|
| Modifier and Type | Method and Description |
|---|---|
private void |
_addAssociations(java.util.HashSet<Association> associations,
KeyedHashMap<LayeredTopic,java.util.Vector<LayeredTopic>> players,
java.util.Vector<LayeredTopic> roles,
java.util.Vector<LayeredTopic> chosen,
LayeredTopic type)
Adds LayeredAssociations into associations set based on the possible players
for each role given in the players map.
|
void |
addSubjectIdentifier(Locator l)
Adds a subject identifier for the topic.
|
void |
addType(Topic type)
Adds a topic type.
|
protected void |
ambiguity(java.lang.String s) |
Topic |
copyStubTo(TopicMap tm)
Copies a stub of this topic to the given topic map.
|
protected java.util.Set<Topic> |
createScope(java.util.Set<Topic> layeredScope,
Layer l)
Creates a scope from a collection of LayeredTopics that can be used for the
given layer.
|
protected java.util.Set<Topic> |
createScope(java.util.Set<Topic> layeredScope,
Layer l,
boolean copyTopics)
Creates a scope from a collection of LayeredTopics that can be used for the
given layer.
|
boolean |
equals(java.lang.Object o)
Two LayeredTopics are equal if their topics collections are equal.
|
java.util.Collection<Association> |
getAssociations()
Returns associations of this topic.
|
java.util.Collection<Association> |
getAssociations(Topic type)
See notes in getAssociations().
|
java.util.Collection<Association> |
getAssociations(Topic type,
Topic role)
See notes in getAssociations().
|
java.util.Collection<Association> |
getAssociationsWithRole()
Gets associations that have this topic as role.
|
java.util.Collection<Association> |
getAssociationsWithType()
Gets associations that have this topic as type.
|
java.lang.String |
getBaseName()
Gets the topic base name or null if no base name has been set.
|
Topic |
getBaseNameSource()
Returns the layer that is being used to get the base name for this topic.
|
java.util.Hashtable<Topic,java.lang.String> |
getData(Topic type)
Returns a Hashtable mapping data versions to data content.
|
java.lang.String |
getData(Topic type,
Topic version)
Gets data with the specified type and version.
|
Tuples.T3<Topic,Topic,Topic> |
getDataSource(Topic type,
Topic version)
Returns the topic that is used to get data with specified type and version and
the type and version topics for the source topic layer.
|
java.util.Collection<Topic> |
getDataTypes()
Gets all used data types.
|
long |
getDependentEditTime() |
long |
getEditTime() |
java.lang.String |
getID()
Returns the id of the first topic in the topics collection with layer name
hash code as prefix.
|
LayerStack |
getLayerStack() |
java.util.Set<Topic> |
getScopeOfLayeredScope(Topic t,
java.util.Set<Topic> layeredScope)
Tries to find a variant scope in the given (non layered) topic that matches
the scope consisting of LayeredTopics.
|
java.util.Collection<Locator> |
getSubjectIdentifiers()
Gets all the subject identifiers of all the topics that this layered topic
consists of.
|
Locator |
getSubjectLocator()
Gets the topic subject locator or null if it has not been set.
|
Topic |
getSubjectLocatorSource() |
Topic |
getTopicForLayer(Layer l)
Gets one of the topics of given layer that is part of this layered
topic or null if no such topic exists.
|
Topic |
getTopicForSelectedLayer()
Gets one of the topics of the selected layer that is part of this layered
topic or null if no such topic exists.
|
TopicMap |
getTopicMap()
Gets the topic map this topic belongs to.
|
java.util.Collection<Topic> |
getTopicsForAllLayers()
Get all topics this layered topic consists of in the order they appear
in layers.
|
java.util.Collection<Topic> |
getTopicsForLayer(Layer l)
Get all topics of the given layer that are part of this LayeredTopic.
|
java.util.Collection<Topic> |
getTopicsForSelectedLayer()
Get all topics of selected layer that are part of this LayeredTopic.
|
java.util.Collection<Topic> |
getTopicsWithDataType()
Gets topics which have data with this topic as type.
|
java.util.Collection<Topic> |
getTopicsWithDataVersion()
Gets topics which have data with this topic as version.
|
java.util.Collection<Topic> |
getTopicsWithVariantScope()
Gets topics which have variants with this topic in scope.
|
java.util.Collection<Topic> |
getTypes()
Gets all topic types.
|
java.lang.String |
getVariant(java.util.Set<Topic> scope)
Gets a variant with the specified scope.
|
java.util.Set<java.util.Set<Topic>> |
getVariantScopes()
Gets the scopes of all variant names.
|
Tuples.T2<Topic,java.util.Set<Topic>> |
getVariantSource(java.util.Set<Topic> scope)
Returns the layer that is used to get the variant for the given scope.
|
int |
hashCode() |
boolean |
isDeleteAllowed()
Returns true if and only if remove() can be called without it throwing TopicInUseException.
|
boolean |
isOfType(Topic type)
Checks if this topic is of the specified type.
|
boolean |
isRemoved()
Returns true if this topic has been removed from the topic map it belonged to.
|
private java.util.HashSet<java.lang.String> |
makeKeySet(java.util.Collection<Topic> topics)
Makes a set having one key for each topic in the given collection.
|
boolean |
mergesWithTopic(Topic topic)
Checks if this topic would merge with the topic given as parameter.
|
void |
remakeLayered()
Remakes the collection of topics this layered topic consists of.
|
void |
remakeLayered(Topic t)
Remake this LayeredTopic using the given topic as the base.
|
void |
remove()
Removes this topic.
|
void |
removeData(Topic type)
Removes all data with the specified type.
|
void |
removeData(Topic type,
Topic version)
Removes data with specified type and version.
|
void |
removeSubjectIdentifier(Locator l)
Removes a subject identifier.
|
void |
removeType(Topic type)
Removes a topic type.
|
void |
removeVariant(java.util.Set<Topic> scope)
Removes a variant name with the specified scope.
|
void |
reorderLayers()
Sort the topics collection.
|
protected AmbiguityResolution |
resolveAmbiguity(java.lang.String event) |
protected AmbiguityResolution |
resolveAmbiguity(java.lang.String event,
java.lang.String msg) |
void |
setBaseName(java.lang.String name)
Sets the topic base name.
|
void |
setData(Topic type,
java.util.Hashtable<Topic,java.lang.String> versionData)
Sets several data values.
|
void |
setData(Topic type,
Topic version,
java.lang.String value)
Sets data with specified type and version.
|
void |
setDependentEditTime(long time) |
void |
setEditTime(long time) |
void |
setSubjectLocator(Locator l)
Sets the topic subject locator overwriting possible previous value.
|
void |
setVariant(java.util.Set<Topic> scope,
java.lang.String name)
Sets the variant with the specified scope.
|
getData, getDisplayName, getDisplayName, getFirstSubjectIdentifier, getName, getOneSubjectIdentifier, getSortName, setDisplayName, toStringprotected java.util.Vector<Topic> topics
protected LayerStack layerStack
private int hashCode
public LayeredTopic(java.util.Collection<Topic> topics, LayerStack layerStack)
public LayeredTopic(Topic t, LayerStack layerStack)
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectprotected void ambiguity(java.lang.String s)
protected AmbiguityResolution resolveAmbiguity(java.lang.String event)
protected AmbiguityResolution resolveAmbiguity(java.lang.String event, java.lang.String msg)
public void remakeLayered()
throws TopicMapException
TopicMapExceptionremakeLayered(Topic)private java.util.HashSet<java.lang.String> makeKeySet(java.util.Collection<Topic> topics)
public void remakeLayered(Topic t) throws TopicMapException
TopicMapExceptionpublic java.util.Collection<Topic> getTopicsForSelectedLayer()
public java.util.Collection<Topic> getTopicsForLayer(Layer l)
public java.util.Collection<Topic> getTopicsForAllLayers()
public Topic getTopicForSelectedLayer()
public Topic getTopicForLayer(Layer l)
public void reorderLayers()
public java.lang.String getID()
throws TopicMapException
getID in class TopicTopicMapExceptionpublic java.util.Collection<Locator> getSubjectIdentifiers() throws TopicMapException
getSubjectIdentifiers in class TopicTopicMapExceptionpublic Topic copyStubTo(TopicMap tm) throws TopicMapException
TopicMapExceptionpublic void addSubjectIdentifier(Locator l) throws TopicMapException
TopicaddSubjectIdentifier in class TopicTopicMapExceptionpublic void removeSubjectIdentifier(Locator l) throws TopicMapException
TopicremoveSubjectIdentifier in class TopicTopicMapExceptionpublic Topic getBaseNameSource() throws TopicMapException
TopicMapExceptionpublic java.lang.String getBaseName()
throws TopicMapException
TopicgetBaseName in class TopicTopicMapExceptionpublic void setBaseName(java.lang.String name)
throws TopicMapException
TopicsetBaseName in class TopicTopicMapExceptionpublic java.util.Collection<Topic> getTypes() throws TopicMapException
TopicgetTypes in class TopicTopicMapExceptionpublic void addType(Topic type) throws TopicMapException
TopicaddType in class TopicTopicMapExceptionpublic void removeType(Topic type) throws TopicMapException
TopicremoveType in class TopicTopicMapExceptionpublic boolean isOfType(Topic type) throws TopicMapException
TopicisOfType in class TopicTopicMapExceptionprotected java.util.Set<Topic> createScope(java.util.Set<Topic> layeredScope, Layer l) throws TopicMapException
TopicMapExceptionprotected java.util.Set<Topic> createScope(java.util.Set<Topic> layeredScope, Layer l, boolean copyTopics) throws TopicMapException
TopicMapExceptionpublic java.util.Set<Topic> getScopeOfLayeredScope(Topic t, java.util.Set<Topic> layeredScope) throws TopicMapException
TopicMapExceptionpublic Tuples.T2<Topic,java.util.Set<Topic>> getVariantSource(java.util.Set<Topic> scope) throws TopicMapException
TopicMapExceptionpublic java.lang.String getVariant(java.util.Set<Topic> scope) throws TopicMapException
TopicgetVariant in class TopicTopicMapExceptionpublic void setVariant(java.util.Set<Topic> scope, java.lang.String name) throws TopicMapException
TopicsetVariant in class TopicTopicMapExceptionpublic java.util.Set<java.util.Set<Topic>> getVariantScopes() throws TopicMapException
TopicgetVariantScopes in class TopicTopicMapExceptionpublic void removeVariant(java.util.Set<Topic> scope) throws TopicMapException
TopicremoveVariant in class TopicTopicMapExceptionpublic Tuples.T3<Topic,Topic,Topic> getDataSource(Topic type, Topic version) throws TopicMapException
TopicMapExceptionpublic java.lang.String getData(Topic type, Topic version) throws TopicMapException
TopicgetData in class TopicTopicMapExceptionpublic java.util.Hashtable<Topic,java.lang.String> getData(Topic type) throws TopicMapException
TopicgetData in class TopicTopicMapExceptionpublic java.util.Collection<Topic> getDataTypes() throws TopicMapException
TopicgetDataTypes in class TopicTopicMapExceptionpublic void setData(Topic type, java.util.Hashtable<Topic,java.lang.String> versionData) throws TopicMapException
TopicsetData in class TopicTopicMapExceptionpublic void setData(Topic type, Topic version, java.lang.String value) throws TopicMapException
TopicsetData in class TopicTopicMapExceptionpublic void removeData(Topic type, Topic version) throws TopicMapException
TopicremoveData in class TopicTopicMapExceptionpublic void removeData(Topic type) throws TopicMapException
TopicremoveData in class TopicTopicMapExceptionpublic Topic getSubjectLocatorSource() throws TopicMapException
TopicMapExceptionpublic Locator getSubjectLocator() throws TopicMapException
TopicgetSubjectLocator in class TopicTopicMapExceptionpublic void setSubjectLocator(Locator l) throws TopicMapException
TopicsetSubjectLocator in class TopicTopicMapExceptionpublic TopicMap getTopicMap()
TopicgetTopicMap in class Topicpublic LayerStack getLayerStack()
private void _addAssociations(java.util.HashSet<Association> associations, KeyedHashMap<LayeredTopic,java.util.Vector<LayeredTopic>> players, java.util.Vector<LayeredTopic> roles, java.util.Vector<LayeredTopic> chosen, LayeredTopic type) throws TopicMapException
TopicMapExceptionpublic java.util.Collection<Association> getAssociations() throws TopicMapException
getAssociations in class TopicTopicMapExceptionpublic java.util.Collection<Association> getAssociations(Topic type) throws TopicMapException
getAssociations in class TopicTopicMapExceptionpublic java.util.Collection<Association> getAssociations(Topic type, Topic role) throws TopicMapException
getAssociations in class TopicTopicMapExceptionpublic void remove()
throws TopicMapException
Topicremove in class TopicTopicMapExceptionpublic long getEditTime()
throws TopicMapException
getEditTime in class TopicTopicMapExceptionpublic void setEditTime(long time)
throws TopicMapException
setEditTime in class TopicTopicMapExceptionpublic long getDependentEditTime()
throws TopicMapException
getDependentEditTime in class TopicTopicMapExceptionpublic void setDependentEditTime(long time)
throws TopicMapException
setDependentEditTime in class TopicTopicMapExceptionpublic boolean isRemoved()
throws TopicMapException
TopicisRemoved in class TopicTopicMapExceptionpublic boolean isDeleteAllowed()
throws TopicMapException
TopicisDeleteAllowed in class TopicTopicMapExceptionpublic java.util.Collection<Topic> getTopicsWithDataType() throws TopicMapException
TopicgetTopicsWithDataType in class TopicTopicMapExceptionpublic java.util.Collection<Association> getAssociationsWithType() throws TopicMapException
TopicgetAssociationsWithType in class TopicTopicMapExceptionpublic java.util.Collection<Association> getAssociationsWithRole() throws TopicMapException
TopicgetAssociationsWithRole in class TopicTopicMapExceptionpublic java.util.Collection<Topic> getTopicsWithDataVersion() throws TopicMapException
TopicgetTopicsWithDataVersion in class TopicTopicMapExceptionpublic java.util.Collection<Topic> getTopicsWithVariantScope() throws TopicMapException
TopicgetTopicsWithVariantScope in class TopicTopicMapExceptionpublic boolean mergesWithTopic(Topic topic) throws TopicMapException
TopicmergesWithTopic in class TopicTopicMapExceptionCopyright 2004-2015 Wandora Team